boot.sem: Bootstrap a Structural Equation Model

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

View source: R/boot.sem.R

Description

Bootstraps a structural equation model in an sem object (as returned by the sem function).

Usage

1
2
3
4
5
6
7
8
boot.sem(data, model, R=100, cov=cov, ...)

## S3 method for class 'bootsem'
print(x, digits=getOption("digits"), ...)

## S3 method for class 'bootsem'
summary(object,
    type=c("perc", "bca", "norm", "basic", "none"), level=0.95, ...)

Arguments

data

a data frame containing the data to which the model was fit; note that the original observations are required, not just the covariance matrix of the observed variables in the model.

model

an sem object, produced by the sem function.

R

the number of bootstrap replications; the default is 100, which should be enough for computing standard errors, but not confidence intervals (except for the normal-theory intervals).

cov

a function to compute the input covariance matrix; the default is cov. Use cor if the model is fit to the correlation matrix. The function hetcor in the polycor package will compute product-moment, polychoric, and polyserial correlations among mixed continuous and ordinal variables (see the example below for an illustration).

x, object

an object of class bootsem.

digits

controls the number of digits to print.

type

type of bootstrapped confidence intervals to compute; the default is "perc" (percentile); see boot.ci for details.

level

level for confidence intervals; default is 0.95.

...

in boot.sem, arguments to be passed to sem; otherwise ignored.

Details

boot.sem implements the nonparametric bootstrap, assuming an independent random sample. Convergence failures in the bootstrap resamples are discarded (and a warning printed); 10 consecutive convergence failures result in an error. You can use the boot function in the boot package for more complex sampling schemes and additional options.

Bootstrapping is implemented by resampling the observations in data, recalculating the input covariance matrix with cov and refitting the model with sem, using the parameter estimates from the original sample as start-values.

Warning: the bootstrapping process can be very time-consuming.

Value

boot.sem returns an object of class bootsem, which inherits from class boot, supported by the boot package. The returned object contains the following components:

t0

the estimated parameters in the model fit to the original data set.

t

a matrix containing the bootstrapped estimates, one bootstrap replication per row.

data

the data frame containing the data to which the model was fit.

seed

the value of .Random.seed when boot.sem was called.

statistic

the function used to produce the bootstrap replications; this is always the local function refit from boot.sem.

sim

always set to "ordinary"; see the documentation for the boot function.

stype

always set to "i"; see the documentation for the boot function.

call

the call of the boot.sem function.

strata

always a vector of ones.

Author(s)

John Fox jfox@mcmaster.ca

References

Davison, A. C., and Hinkley, D. V. (1997) Bootstrap Methods and their Application. Cambridge.

Efron, B., and Tibshirani, R. J. (1993) An Introduction to the Bootstrap. Chapman and Hall.

See Also

boot, sem

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
    ## Not run: 

# A simple confirmatory factor-analysis model using polychoric correlations.
#  The polycor package is required for the hetcor function.

library(polycor)

# The following function returns correlations computed by hetcor,
#   and is used for the bootstrapping.

hcor <- function(data) hetcor(data, std.err=FALSE)$correlations

model.cnes <- specify.model()
F -> MBSA2, lam1, NA
F -> MBSA7, lam2, NA
F -> MBSA8, lam3, NA
F -> MBSA9, lam4, NA
F <-> F, NA, 1
MBSA2 <-> MBSA2, the1, NA
MBSA7 <-> MBSA7, the2, NA
MBSA8 <-> MBSA8, the3, NA
MBSA9 <-> MBSA9, the4, NA

data(CNES)
R.cnes <- hcor(CNES)

sem.cnes <- sem(model.cnes, R.cnes, N=1529)
summary(sem.cnes)

#  Note: this can take a couple of minutes:

system.time(boot.cnes <- boot.sem(CNES, sem.cnes, R=100, cov=hcor), gcFirst=TRUE)
summary(boot.cnes, type="norm")  
# cf., standard errors to those computed by summary(sem.cnes)

    
## End(Not run)

sem1 documentation built on May 2, 2019, 6:38 p.m.

Related to boot.sem in sem1...