Im trying to bootstrap reliability estimates using non parametric bootstrap
I have written the code below where a model is created and then bootstrapped 1000 times in order to get two reliability statistics Alpha and Omega
I am able to get the Alpha and the Omega for the first construct with confidence intervals: visual =~ x1 + x2 + x3
but see no way of accessing it for the other constructs textual
and speed
When i run the boot function, i see results for all of them
# bootstrapping with 1000 replications
results <- boot(data=data, statistic=reliability, R=500, formula=HS.model,parallel = 'snow')
> results$t0
visual textual speed total
alpha 0.6261171 0.8827069 0.6884550 0.7604886
omega 0.6253180 0.8851754 0.6877600 0.8453351
omega2 0.6253180 0.8851754 0.6877600 0.8453351
omega3 0.6120052 0.8850608 0.6858417 0.8596204
avevar 0.3705589 0.7210163 0.4244883 0.5145874
Below is my admittedly shoddy attempt. Can anyone help
library(lavaan)
library(semTools)
library(boot)
data <- HolzingerSwineford1939
HS.model <- 'visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
# function to reliability stats
reliability <- function(formula, data, indices) {
data = data
d <- data[indices,] # allows boot to select sample
fit <- cfa(HS.model, data=d)
semTools::reliability(fit)
}
# bootstrapping with 500 replications
results <- boot(data=data, statistic=reliability, R=500, formula=HS.model,parallel = 'snow')
# Get the confidence intervals
conf_interval_alpha <- boot.ci(results, type="bca", index = 1)
# Retrieve the Alpha and confidence intervals
alpha <- conf_interval_alpha$t0
alpha.ci <- conf_interval_alpha$bca[,c(4,5)]
# Retrieve the Omega and confidence intervals
conf_interval_omega <- boot.ci(results, type="bca", index = 2)
omega <- conf_interval_omega$t0
omega.ci <- conf_interval_omega$bca[,c(4,5)]
Thank you for your help