Learn R Programming

stremo (version 0.2)

boot.lavaan: Nonparametrical bootstrapping of a SEM model fit by lavaan.

Description

This function does very crude nonparametrical bootstrapping of a fitted sem model using lavaan.

Usage

boot.lavaan(fitted.model, n)

Arguments

fitted.model
A model fitted by sem or cfa.
n
Number of replications.

Value

X2
Bootstrapped maximum likelihood chi-squared
p.X2
P value of the bootstrapped maximum likelihood chi-squared
est
Estimated coefficients
se
Bootstrapped standard errors
z
Bootstrapped z values
p.est
P values of the bootstrapped coefficients
coefs
Matrix with the values of all coefficients in all runs

Details

Steps:

1. Fit a model normally using the arguments 'sample.cov' and 'sample.nobs' instead of 'data';

2. Get the sigma hat from the fitted model and build an empirical dataset with 'sample.nobs' observations;

3. Get 'sample.nobs' observations from this new dataset with replacement;

4. Fit a new model using the sample taken from the simulated dataset;

5. Repeat 3 and 4 'n' times.

Examples

Run this code
## Not run: 
# data(albert)
# fit <- sem(albert.model, sample.cov = albert.litho.cov, sample.nobs
#            = 107)
# booted.fit <- boot.lavaan(fit, 1000)
# ## End(Not run)

Run the code above in your browser using DataLab