gam.path: Prints and displays spatial sem results using gam models

Description Usage Arguments Details Author(s) References See Also Examples

View source: R/sesem1.0.2.r

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

1
2
3
4
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#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))

Example output

            path.name gam.dev.exp gam.s.edf gam.s.Ref.df gam.s.F gam.s.pvalue
1     Gram ~ Moisture       0.967     8.101        8.783  52.377        0.000
2      N_Fix ~ Bryoph       0.814     4.506        5.531  14.838        0.000
3        N_Fix ~ Lich       0.366     2.157        2.690   4.219        0.022
4   N_Fix ~ SoilCrust       0.725     5.963        7.120   6.076        0.001
5  SoilCrust ~ Bryoph       0.912     6.243        7.397  24.288        0.000
6    SoilCrust ~ Lich       0.421     4.764        5.826   1.812        0.146
7    SoilCrust ~ Gram       0.572     4.061        5.009   4.860        0.004
8  SoilCrust ~ Shrubs       0.668     5.529        6.671   4.989        0.002
9   SoilCrust ~ Forbs       0.052     1.000        1.000   1.271        0.271
10      Bryoph ~ Gram       0.927     6.954        8.033  26.334        0.000
11    Bryoph ~ Shrubs       0.655     4.542        5.571   5.907        0.001
12     Bryoph ~ Forbs       0.367     1.000        1.000  13.313        0.001
13  Bryoph ~ Moisture       0.667     6.103        7.260   4.452        0.004
14    Lich ~ Moisture       0.294     1.980        2.470   3.062        0.054
15       Lich ~ Forbs       0.444     2.375        2.959   4.955        0.009
16        Lich ~ Gram       0.648     5.862        7.018   4.220        0.006
17      Lich ~ Shrubs       0.879     7.843        8.652  12.896        0.000
18      Lich ~ Bryoph       0.935     7.058        8.118  29.450        0.000
19   Forbs ~ Moisture       0.131     1.798        2.242   0.953        0.378
20  Shrubs ~ Moisture       0.814     7.201        8.228   8.291        0.000
   max.path.value
1         100.000
2          92.242
3         100.000
4          35.030
5          82.545
6          79.636
7           4.000
8          82.545
9         100.000
10         37.939
11         29.212
12          4.000
13         88.364
14         39.879
15         47.636
16        100.000
17          4.000
18         92.242
19         47.636
20         17.576
   parameter.number         parameter.name
1                 1        Gram ~ Moisture
2                 2         N_Fix ~ Bryoph
3                 3           N_Fix ~ Lich
4                 4      N_Fix ~ SoilCrust
5                 5     SoilCrust ~ Bryoph
6                 6       SoilCrust ~ Lich
7                 7       SoilCrust ~ Gram
8                 8     SoilCrust ~ Shrubs
9                 9      SoilCrust ~ Forbs
10               10          Bryoph ~ Gram
11               11        Bryoph ~ Shrubs
12               12         Bryoph ~ Forbs
13               13      Bryoph ~ Moisture
14               14        Lich ~ Moisture
15               15           Lich ~ Forbs
16               16            Lich ~ Gram
17               17          Lich ~ Shrubs
18               18          Lich ~ Bryoph
19               19       Forbs ~ Moisture
20               20          Gram ~~ Forbs
21               21      Shrubs ~ Moisture
22               22         Gram ~~ Shrubs
23               23        Forbs ~~ Shrubs
24               24           Gram ~~ Gram
25               25         N_Fix ~~ N_Fix
26               26 SoilCrust ~~ SoilCrust
27               27       Bryoph ~~ Bryoph
28               28           Lich ~~ Lich
29               29         Forbs ~~ Forbs
30               30       Shrubs ~~ Shrubs
31               31   Moisture ~~ Moisture
           path.name gam.dev.exp gam.s.edf gam.s.Ref.df gam.s.F gam.s.pvalue
1 SoilCrust ~ Bryoph       0.912     6.243        7.397  24.288        0.000
2   SoilCrust ~ Gram       0.572     4.061        5.009   4.860        0.004
3 SoilCrust ~ Shrubs       0.668     5.529        6.671   4.989        0.002
  max.path.value
1         82.545
2          4.000
3         82.545

sesem documentation built on May 1, 2019, 9:17 p.m.