On 05/26/2014 03:21 AM, Conal Monaghan wrote:
> Thanks Terry!
>
> I ran the code and the parameterEstimates() function
> worked (see below). This call has produced the parameter estimates with
> bootstrapped conventional standard errors. Now that this function is
> returning without errors, I was hoping to produce the CI's for the
> standardized parameter estimates (and later down the track several fit
> indices). As a result, bootstrapping the "coef" function should produce
> a distribution on these estimates from which the 95% CI could be
> determined through the parameterEstimates() function. I was wondering
> how I these estimates could be produced?
To bootstrap the standardized estimates, you need to use the
bootstrapLavaan() function again. As follows:
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
fit <- cfa(HS.model, data=HolzingerSwineford1939)
out <- bootstrapLavaan(fit, R = 100, FUN = function(x) {
standardizedSolution(x)$est }, verbose = TRUE)
This will return a 100x24 matrix (in practice, you may want to use a
much larger number for R). The rows are the bootstraps, the columns are
the model parameters (here including fixed parameters).
To get a 95% CI, you can compute percentiles on the columns of out:
# just one column:
quantile(out[,1], probs=c(0.025, 0.975))
# all columns
lapply(as.data.frame(out), quantile, probs=c(0.025, 0.975))
To bootstrap one of more fit measures, you can use something like:
out <- bootstrapLavaan(fit, R = 100, FUN = function(x) { fitMeasures(x,
c("cfi", "rmsea")) }, verbose = TRUE)
Yves.