gpt4 book ai didi

r - 警告 : some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate

转载 作者:行者123 更新时间:2023-12-05 03:49:15 27 4
gpt4 key购买 nike

我正在尝试从数据集中评估 sem 模型,一些数据采用李克特量表,即 1-5。有些数据是 COUNTS 从计算机日志中为某些事件生成的。

而在执行拟合时,laveen 给我的错误是:

lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate

为了缓解此警告,我想缩放 一些变量。但是无法理解这样做的方式。

Log_And_SurveyResult <- read_excel("C:/Users/Aakash/Desktop/analysis/Log-And-SurveyResult.xlsx")

model <- '
Reward =~ REW1 + REW2 + REW3 + REW4
ECA =~ ECA1 + ECA2 + ECA3
Feedback =~ FED1 + FED2 + FED3 + FED4
Motivation =~ Reward + ECA + Feedback
Satisfaction =~ a*MaxTimeSpentInAWeek + a*TotalTimeSpent + a*TotalLearningActivityView

Motivation ~ Satisfaction'

fit <- sem(model,data = Log_And_SurveyResult)

summary(fit, standardized=T, std.lv = T)

fitMeasures(fit, c("cfi", "rmsea", "srmr"))

我想缩放一些变量,例如 MaxTimeSpentInAWeekTotalTimeSpent

你能帮我弄清楚如何缩放变量吗?非常感谢。

最佳答案

作为Elias pointed out ,变量之间的量级差异很大,建议对变量进行缩放。警告会给出提示,检查 varTable(fit) 会返回有关已拟合 lavaan 对象中变量的摘要信息。

与其在每一列上单独运行 scale(),不如在子集或整个 data.frame 上使用 apply() >:

## Scale the variables in the 4th and 7h column
Log_And_SurveyResult[, c(4, 7)] <- apply(Log_And_SurveyResult[, c(4, 7)], 2, scale)

## Scale the whole data.frame
Log_And_SurveyResult <- apply(Log_And_SurveyResult, 2, scale)

关于r - 警告 : some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64023066/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com