【发布时间】:2017-03-22 04:33:16
【问题描述】:
我使用 R 包“ltm”来估计模型(分级响应模型),我想导出为每个响应模式 factor.scores() 计算的概率并将其附加到个人(这样每个人都会接受与他的反应模式相匹配的概率)。
a <- c(1,3,3,1,2,2,2,2,2,2)
b <- c(1,3,3,1,NA,1,1,2,2,3)
c <- c(1,3,3,3,3,3,1,2,2,3)
ABC <- data.frame(a, b, c)
grm.model <- grm(ABC, constrained = FALSE)
summary.grm(grm.model)
str(grm.model)
factor.scores(grm.model, return.MIvalues=TRUE, prior = TRUE)
使用factor.scores(),我得到一个列表 Exp,它是每个响应模式的预测概率(如果我理解正确的话)。我想为参与者创建一个包含此信息的变量(因此将它们与他们的响应模式相匹配并给出各自的预测概率)。
关于我是否可以做到这一点的任何想法?
这是factor.scores(grm.model, return.MIvalues=TRUE, prior = TRUE)输出的第一行
> factor.scores(grm.model, return.MIvalues=TRUE, prior = TRUE)
Call:
grm(data = ABC, constrained = FALSE)
Scoring Method: Empirical Bayes
Factor-Scores for observed response patterns:
a b c Obs Exp z1 se.z1
1 1 1 1 1 0.193 -1.791 0.152
2 1 1 3 1 0.479 -1.294 0.796
3 2 1 1 1 0.076 -1.774 0.100
4 2 1 3 1 0.749 -0.833 0.706
问题是在我的数据集中我有大约 400 个响应模式,并且不可能手动创建变量。 提前谢谢!
编辑 ---------------------------------- --------------
三年后,我仍然对如何做到这一点感到困惑。 这是这次生成 Rasch 模型的代码。
install.packages("ltm")
ID <- c('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q')
a <- c(1,0,0,0,0,0,0,1,1,0,0,0,0,1,0,1,0)
b <- c(1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,0,0)
c <- c(0,1,0,1,0,1,0,1,0,1,0,0,0,1,1,1,0)
dataset <- data.frame(ID, a, b, c)
dataset
data_for_rasch <- dataset[c(a, b, c)]
library(ltm)
my_model <- rasch(data_for_rasch, constraint = NULL, IRT.param = TRUE, start.val = NULL, na.action = NULL, Hessian = TRUE)
summary(my_model)
plot.rasch(my_model)
str(my_model)
# following jlhoward's answer
factor.scores(my_model, return.MIvalues=TRUE, prior = TRUE)
scores <- factor.scores(my_model, return.MIvalues=TRUE, prior = TRUE)$score.dat
str(scores)
result <- merge(data_for_rasch, scores, by=c("a","b","c"))
result <- merge(data_for_rasch, scores[,c(1,2,3,5)], by=c("a","b","c"))
str(result)
# how do I join this to the initial dataset that includes the participant ID?
【问题讨论】: