bootstrapLavaan  R Documentation 
Bootstrap the LRT, or any other statistic (or vector of statistics) you can extract from a fitted lavaan object.
bootstrapLavaan(object, R = 1000L, type = "ordinary", verbose = FALSE, FUN = "coef", keep.idx = FALSE, parallel = c("no", "multicore", "snow"), ncpus = 1L, cl = NULL, iseed = NULL, h0.rmsea = NULL, ...) bootstrapLRT(h0 = NULL, h1 = NULL, R = 1000L, type="bollen.stine", verbose = FALSE, return.LRT = FALSE, double.bootstrap = "no", double.bootstrap.R = 500L, double.bootstrap.alpha = 0.05, parallel = c("no", "multicore", "snow"), ncpus = 1L, cl = NULL, iseed = NULL)
object 
An object of class 
h0 
An object of class 
h1 
An object of class 
R 
Integer. The number of bootstrap draws. 
type 
If 
FUN 
A function which when applied to the 
... 
Other named arguments for 
verbose 
If 
keep.idx 
If 
return.LRT 
If 
parallel 
The type of parallel operation to be used (if any). If
missing, the default is 
ncpus 
Integer: number of processes to be used in parallel operation.
By default
this is the number of cores (as detected by 
cl 
An optional parallel or snow cluster for use if

iseed 
An integer to set the seed. Or NULL if no reproducible results are
needed. This works for both serial (nonparallel) and parallel settings.
Internally, 
h0.rmsea 
Only used if 
double.bootstrap 
If 
double.bootstrap.R 
Integer. The number of bootstrap draws to be use for the double bootstrap. 
double.bootstrap.alpha 
The significance level to compute the adjusted alpha based on the plugin pvalues. 
The FUN function can return either a scalar or a numeric vector.
This function can be an existing function (for example coef
) or
can be a custom defined function. For example:
myFUN < function(x) { # require(lavaan) modelImpliedCov < fitted(x)$cov vech(modelImpliedCov) }
If parallel="snow"
, it is imperative that the require(lavaan)
is included in the custom function.
For bootstrapLavaan()
, the bootstrap distribution of the value(s)
returned by FUN
, when the object can be simplified to a vector.
For bootstrapLRT()
, a bootstrap p value, calculated as the
proportion of bootstrap samples with a LRT statistic at least as large as
the LRT statistic for the original data.
Yves Rosseel and Leonard Vanbrabant. Ed Merkle contributed Yuan's bootstrap. Improvements to Yuan's bootstrap were contributed by Hao Wu and Chuchu Cheng. The handling of iseed was contributed by Shu Fai Cheung.
Bollen, K. and Stine, R. (1992) Bootstrapping Goodness of Fit Measures in Structural Equation Models. Sociological Methods and Research, 21, 205–229.
Yuan, K.H., Hayashi, K., & Yanagihara, H. (2007). A class of population covariance matrices in the bootstrap approach to covariance structure analysis. Multivariate Behavioral Research, 42, 261–281.
# fit the Holzinger and Swineford (1939) example HS.model < ' visual =~ x1 + x2 + x3 textual =~ x4 + x5 + x6 speed =~ x7 + x8 + x9 ' fit < cfa(HS.model, data=HolzingerSwineford1939, se="none") # get the test statistic for the original sample T.orig < fitMeasures(fit, "chisq") # bootstrap to get bootstrap test statistics # we only generate 10 bootstrap sample in this example; in practice # you may wish to use a much higher number T.boot < bootstrapLavaan(fit, R=10, type="bollen.stine", FUN=fitMeasures, fit.measures="chisq") # compute a bootstrap based pvalue pvalue.boot < length(which(T.boot > T.orig))/length(T.boot)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.