Learn R Programming

piecewiseSEM (version 1.2.1)

sem.missing.paths: Evaluate independence claims for piecewise SEM

Description

Identifies missing paths from a piecewise SEM, fits models, extracts path p-values and returns in a data.frame.

Usage

sem.missing.paths(modelList, data, conditional = FALSE, corr.errors = NULL, 
add.vars = NULL, grouping.vars = NULL, grouping.fun = mean, adjust.p = FALSE, 
basis.set, model.control = NULL, .progressBar = TRUE)

Arguments

modelList

a list of regressions representing the structural equation model.

data

a data.frame used to construct the structured equations.

conditional

whether conditional variables should be shown in the independence claim (unless the formula is fewer than 30 characters). Default is FALSE.

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 multi-level dataset.

grouping.fun

a function defining how variables are aggregated in grouping.vars. Default is mean.

adjust.p

whether p-values degrees of freedom should be adjusted (see below). Default is FALSE.

basis.set

provide an optional basis set.

model.control

a list of model control arguments to be passed to d-sep models.

.progressBar

enable optional text progress bar. Default is TRUE.

Value

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.

Details

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 p-values in a data.frame.

References

Shipley, Bill. "Confirmatory path analysis in a generalized multilevel context." Ecology 90.2 (2009): 363-368.

Shipley, Bill. "The AIC model selection method applied to path analytic models compared using a d-separation test." Ecology 94.3 (2013): 560-564.

See Also

DAG, get_ddf_Lb

Examples

Run this code
# NOT RUN {
# 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 = ~1|site/tree, na.action = na.omit, 
        data = shipley2009.reduced),
    
    lme(Date ~ DD, random = ~1|site/tree, na.action = na.omit, 
        data = shipley2009.reduced),
    
    lme(Growth ~ Date, random = ~1|site/tree, na.action = na.omit, 
        data = shipley2009.reduced),
    
    glmer(Live ~ Growth+(1|site)+(1|tree), 
          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 = ~1|site/tree, na.action = na.omit, 
        data = shipley2009),
    
    lme(Date ~ DD, random = ~1|site/tree, na.action = na.omit, 
        data = shipley2009),
    
    lme(Growth ~ Date, random = ~1|site/tree, na.action = na.omit, 
        data = shipley2009),
    
    glmer(Live ~ Growth+(1|site)+(1|tree), 
          family=binomial(link = "logit"), data = shipley2009) 
    
  )

  # Evaluate independence claims
  sem.missing.paths(shipley2009.modlist, shipley2009)
  
# }

Run the code above in your browser using DataLab