【发布时间】:2017-07-15 18:10:23
【问题描述】:
我正在尝试使用非参数引导程序引导可靠性估计
我已经编写了下面的代码,其中创建了一个模型,然后引导 1000 次以获得两个可靠性统计 Alpha 和 Omega
我能够获得具有置信区间的第一个构造的 Alpha 和 Omega:visual =~ x1 + x2 + x3 但看不到其他构造 textual 和 speed 的访问方法
当我运行引导功能时,我会看到所有结果
# 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
以下是我公认的粗制滥造的尝试。谁能帮忙
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)]
感谢您的帮助
【问题讨论】:
-
基本调试...在新会话中执行此操作...并阅读错误消息。我遇到的第一个错误是: ERsum(beta[i, ], tau.found.sym.optim, m + 1, m + n) 中的错误:dims [product 666] do not match the length of object [999] In另外:警告消息:在 y - X %*% beta 中:较长的对象长度不是较短对象长度的倍数
-
对不起,是的,我现在看到了。我会马上更新代码