gam.path {sesem} | R Documentation |
Prints and displays spatial sem results using gam models
Description
This function fits generalized additive models (gam) of the path coefficient vs. lag distance relationship for each path in the spatial SEM model. Gam functions and figures are produced. Requires function mgcv
Usage
gam.path(spatial_model_results, path.type = "directed",selectpath = "none selected",
plot.points = T, se.plot = T, lwd.pred = 2, lty.pred = 1, lwd.se = 2, lty.se = 3,
cex = 1, cex.axis = 1, cex.lab = 1, xlab = "Lag Distance",
ylab = "Unst. Path Coeff.", yaxt = "s", xaxt = "s")
Arguments
spatial_model_results |
a list object produced by function runModels |
path.type |
An option to select the paths to be plotted. "directed" = only directed paths plotted; "undirected" = only undirected correlations plotted; "both" = all paths plotted; "user" = allows user to specify particular paths and a particular order for plotting. Argument selectpath must also be provided with path.type="user" |
selectpath |
An option to select specific paths for plotting. Usage is as follows: selectpath==c(5,18,16,23,29) where values refer to path numbers. Path numbers can be obtained using spatial_model_results[[2]] |
plot.points |
Should points for individual models be plotted? |
se.plot |
Should standard error lines for each gam model be plotted? |
lwd.pred |
width of the predicted line from the gam model |
lty.pred |
format of the predicted line from the gam model |
lwd.se |
width of the standard error line |
lty.se |
format of the standard error line |
cex |
point size |
cex.axis |
axis font size |
cex.lab |
label font size |
xlab |
x-axis label |
ylab |
y-axis label |
yaxt |
argument to suppress plotting of y-axis if set to "n" |
xaxt |
argument to suppress plotting of x-axis if set to "n" |
Details
Generalized additive models (gam) allow flexible modeling of nonlinear relationships with minimal assumptions about the shape of those relationships. This function utilizes the gam fitting function in library mgcv to fit and display gam models of the relationships between lag distance and unstandardized path coefficients. This is an alternative to the lowess smoothed lines available in function plot.path. Potential advantages of the gam models include the ability to obtain predictions for lag distance values intermediate between modeled lag distances.
Author(s)
Eric Lamb
References
Lamb, E. G., K. Mengersen, K. J. Stewart, U. Attanayake, and S. D. Siciliano. 2014. Spatially explicit structural equation modeling. Ecology 95:2434-2442.
Rosseel, Y. 2012 lavaan: an R package for structural equation modeling. Journal of Statistical Software 48:1-36
Wood, S.N. 2011 Fast stable restricted maximum likelihood and marginal likelihood estimation of semiparametric generalized linear models. Journal of the Royal Statistical Society (B) 73(1):3-36
Wood, S.N. 2006 Generalized Additive Models: An Introduction with R. Chapman and Hall/CRC
See Also
sem
, gam
, make.covar
, runModels
,
modelsummary
, plotmodelfit
, plotpath
Examples
#data=truelove
#distancematrix<-calc.dist(truelove)
#Truelove_bins<-make.bin(distancematrix,type="ALL",p.dist=20)
#binsize<-Truelove_bins[1][[1]] #truelove lowland bin sizes
#binname<-Truelove_bins[2][[1]] #truelove lowland bin names
#covariances<-make.covar(truelove,distancematrix,binsize,binname)
#covariances
# path model for the truelove dataset
#spatial_model<-'
# Gram ~ Moisture
# N_Fix ~ Bryoph + Lich + SoilCrust
# SoilCrust ~ Bryoph + Lich + Gram + Shrubs + Forbs
# Bryoph ~ Gram + Shrubs + Forbs + Moisture
# Lich ~ Moisture + Forbs + Gram + Shrubs + Bryoph
# Forbs ~ Moisture
# Gram ~~ Forbs
# Shrubs ~ Moisture
# Gram ~~ Shrubs
# Shrubs ~~ Forbs
# '
#
#results<-runModels(spatial_model,covariances)
#The above script produces the sesem object stored as truelove_results
data=truelove_results
gam.path(truelove_results)
truelove_results[[2]]# list of path names
gam.path(truelove_results,path.type="user",selectpath=c(5,7,8))