sem.aic: Extracts AIC scores for piecewise SEM

Description Usage Arguments Details Value Author(s) References Examples

View source: R/sem.aic.R

Description

Extracts the AIC and AICc (corrected for small sample size) values from a piecewise structural equation model (SEM).

Usage

1
2
3
sem.aic(modelList, data, corr.errors, add.vars, grouping.vars, 
  grouping.fun, adjust.p, basis.set, pvalues.df, model.control, 
  .progressBar) 

Arguments

modelList

a list of regressions representing the structural equation model.

data

a data.frame used to construct the structured equations.

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.

pvalues.df

an optional data.frame corresponding to p-values for independence claims.

model.control

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

.progressBar

enable optional text progress bar. Default is TRUE.

Details

This function calculates AIC and AICc (corrected for small sample sizes) values for a piecewise structural equation model (SEM).

For linear mixed effects models, p-values can be adjusted to accommodate the full model degrees of freedom using the argument p.adjust = TRUE. For more information, see Shipley 2013.

Value

Returns a data.frame where the first entry is the AIC score, and the second is the AICc score, and the third is the likelihood degrees of freedom (K).

Author(s)

Jon Lefcheck

References

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

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
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 = ~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) 
    
  )

  # Get AIC and AICc values for the SEM
  sem.aic(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) 
    
  )

  # Get AIC and AICc values for the SEM
  sem.aic(shipley2009.modlist, shipley2009)
  
## End(Not run)

piecewiseSEM documentation built on May 29, 2017, 6:05 p.m.