Description Usage Arguments Details Value Note Author(s) References See Also Examples
View source: R/sem.missing.paths.R
Identifies missing paths from a piecewise SEM, fits models, extracts path pvalues and returns in a data.frame
.
1 2 3 
modelList 
a 
data 
a 
conditional 
whether conditional variables should be shown in the independence claim (unless the formula is fewer than 30 characters). Default is 
corr.errors 
a vector of variables with correlated errors (separated by "~~"). 
add.vars 
a vector of additional variables whose independence claims should be evaluated, but which do not appear in the model list. 
grouping.vars 
an optional variable that represents the levels of data aggregation for a multilevel dataset. 
grouping.fun 
a function defining how variables are aggregated in 
adjust.p 
whether pvalues degrees of freedom should be adjusted (see below). Default is 
basis.set 
provide an optional basis set. 
model.control 
a 
.progressBar 
enable optional text progress bar. Default is 
This function takes a model list (and optional basis set) and evaluates all conditional independence claims by constructing regressions, returning the claims, the variables upon which they are conditional, and associated pvalues in a data.frame
.
Returns a data.frame
where the first column is the independence claim (with the first variable being the variable of interest, followed by the conditional variables, unless truncated), and the second through sixth columns the model estimates corresponding to the response variable in the independence claim.
Independence claims are constructed based on how the variables are treated as in the model list. For example, if the indepedence claim includes a binary variable that is fit to a binomial distribution using an identity link, the function will evaluate the any claims using the same parameters.
Similarly, for linear mixed effects models construted in lme4
or nlme
, varying slopes and intercepts are treated as in the model list. For example, if a variable is modeled with both a random slope and intercept in any model in the model list, that variable will be modeled with a random slope and intercept when evaluating all independence claims in which it appears. If slopes and intercepts vary for multiple variables, they will appear as such, even if they are conditional.
For models of class lmerMod
, denominator degrees of freedom and resulting Pvalues are calculated using the KenwardRogers approximation from the pbkrtest
package.
For linear mixed effects models, pvalues can be adjusted to accommodate the full model degrees of freedom using the argument p.adjust = TRUE
. For more information, see Shipley 2013.
Jon Lefcheck
Shipley, Bill. "Confirmatory path analysis in a generalized multilevel context." Ecology 90.2 (2009): 363368.
Shipley, Bill. "The AIC model selection method applied to path analytic models compared using a dseparation test." Ecology 94.3 (2013): 560564.
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54  # Load example data
data(shipley2009)
# Reduce dataset for example
shipley2009.reduced = shipley2009[1:200, ]
# Load model packages
library(lme4)
library(nlme)
# Create list of models
shipley2009.reduced.modlist = list(
lme(DD ~ lat, random = ~1site/tree, na.action = na.omit,
data = shipley2009.reduced),
lme(Date ~ DD, random = ~1site/tree, na.action = na.omit,
data = shipley2009.reduced),
lme(Growth ~ Date, random = ~1site/tree, na.action = na.omit,
data = shipley2009.reduced),
glmer(Live ~ Growth+(1site)+(1tree),
family=binomial(link = "logit"), data = shipley2009.reduced)
)
# Evaluate independence claims
sem.missing.paths(shipley2009.reduced.modlist, shipley2009.reduced)
## Not run:
# Repeat with full dataset as in Shipley (2009)
# Create list of models
shipley2009.modlist = list(
lme(DD ~ lat, random = ~1site/tree, na.action = na.omit,
data = shipley2009),
lme(Date ~ DD, random = ~1site/tree, na.action = na.omit,
data = shipley2009),
lme(Growth ~ Date, random = ~1site/tree, na.action = na.omit,
data = shipley2009),
glmer(Live ~ Growth+(1site)+(1tree),
family=binomial(link = "logit"), data = shipley2009)
)
# Evaluate independence claims
sem.missing.paths(shipley2009.modlist, shipley2009)
## End(Not run)

Loading required package: Matrix
Attaching package: 'nlme'
The following object is masked from 'package:lme4':
lmList

  0%

============  17%

=======================  33%

===================================  50%

===============================================  67%

==========================================================  83%

====================================================================== 100%
Conditional variables have been omitted from output table for clarity (or use argument conditional = T)
missing.path estimate std.error df crit.value p.value
1 Date ~ lat + ... 0.501236996 0.55495446 1 0.90320383 0.5323503
2 Growth ~ lat + ... 0.016214895 0.78599926 1 0.02062966 0.9868686
3 Live ~ lat + ... 0.026430185 0.08593623 NA 0.30755577 0.7584204
4 Growth ~ DD + ... 0.157283639 0.13579177 115 1.15827081 0.2491533
5 Live ~ DD + ... 0.003526027 0.09143347 NA 0.03856386 0.9692381
6 Live ~ Date + ... 0.019816691 0.10003341 NA 0.19810073 0.8429663

  0%

============  17%

=======================  33%

===================================  50%

===============================================  67%

==========================================================  83%

====================================================================== 100%
Conditional variables have been omitted from output table for clarity (or use argument conditional = T)
missing.path estimate std.error df crit.value p.value
1 Date ~ lat + ... 0.009051378 0.11347661 18 0.07976426 0.9373049
2 Growth ~ lat + ... 0.098862826 0.11072020 18 0.89290690 0.3836896
3 Live ~ lat + ... 0.030496790 0.02966080 NA 1.02818503 0.3038628
4 Growth ~ DD + ... 0.010613707 0.03576722 1329 0.29674399 0.7667083
5 Live ~ DD + ... 0.027190501 0.02711298 NA 1.00285903 0.3159289
6 Live ~ Date + ... 0.046565402 0.02984092 NA 1.56045449 0.1186525
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.