Learn R Programming

sesem (version 1.0.1)

runModels: Run a spatial SEM analysis

Description

Given a path model (spatial_model) specified using lavaan syntax, and a list object containing covariance matrices generated by make.covar, runs an sem model using function sem from the lavaan package for each lag distance bin.

Usage

runModels(spatial_model,covdata)

Arguments

spatial_model
a path model specified using lavaan syntax. See the lavaan help pages for details.
covdata
a list object containing covariance matrices and other descriptors as produced by make.covar

Value

  • 1a table of model fit estimates for each model. Values available in this table include the following: "fmin","chisq","df","pvalue","baseline.chisq","baseline.df","baseline.pvalue","cfi","tli","nnfi", "rfi","nfi","pnfi","ifi","rni","logl","unrestricted.logl","npar","aic","bic","ntotal","bic2","rmsea","rmsea.ci.lower","rmsea.ci.upper","rmsea.pvalue","rmr","rmr_nomean","srmr","srmr_nomean","cn_05","cn_01","gfi","agfi","pgfi","mfi","ecvi". See the lavaan documentation for an explanation of each value.
  • 2table containing a vector of parameter numbers and a character vector containing the names of the paths included in each model.
  • 3a table of unstandardized path coefficient estimates for each path in each model
  • 4standard error of unstandardized path coefficient estimates for each path in each model
  • 5p-values for each unstandardized path coefficient estimate for each path in each model
  • 6standardized parameter estimates for each path in each model
  • 7character vector containing list of names of dependent variables within the models
  • 8r-square values for each dependent variable in each model
  • 9names of each path for which there is a modification index value
  • 10modification index values for each potential path addition for each model
  • 11a copy of the bin.summary table in the input covdata object

Details

Given a path model (spatial_model) specified using lavaan syntax, and a list object containing covariance matrices generated by make.covar, runs an sem model using function sem from the lavaan package for each lag distance bin. Produces a list object containing the model results.

References

Lamb, E. G., K. Mengersen, K. J. Stewart, U. Attanayake, and S. D. Siciliano. Submitted. Spatially explicit structural equation modeling. Ecology. Rosseel, Y. 2012 lavaan: an R package for structural equation modeling. Journal of Statistical Software 48:1-36.

See Also

sem, make.covar, modelsummary, plotmodelfit, plotpath

Examples

Run this code
data=truelove
truelove_red<-truelove[c(1:60),c(1:7)]
distancematrix<-calc.dist(truelove_red)
Truelove_bins<-make.bin(distancematrix,type="ALL",p.dist=10)
binsize<-Truelove_bins[1][[1]] #truelove lowland bin sizes
binname<-Truelove_bins[2][[1]] #truelove lowland bin names

plotbin(distancematrix,binsize)

covariances<-make.covar(truelove_red,distancematrix,binsize,binname)
covariances

# reduced path model for the truelove dataset

spatial_model<-'
	N_Fix ~ Bryoph + Lich + SoilCrust
	SoilCrust ~ Bryoph + Lich	
	Lich ~ Bryoph + Moisture
	Bryoph ~ Moisture
	'

results<-runModels(spatial_model,covariances)
plotmodelfit(results,rmsea_err=FALSE)

Run the code above in your browser using DataLab