gpt4 book ai didi

r - 使用 ltm 包从 factor.scores 中提取 z 分数?

转载 作者:行者123 更新时间:2023-12-03 21:53:01 26 4
gpt4 key购买 nike

我下面的代码用于复制目的。我使用 ltm 包创建了一个双参数模型。我还使用 factor.scores 函数计算每个响应的 z1 值,这是下面“response_pattern”对象中的倒数第二行。

我的问题是,如何从 response_pattern 对象中提取 z1 值,使其成为我可以在其他地方使用的向量?它应该是一个长度为 12 的向量,每个响应一个 z1。

  item1 <- cbind(1,0,1,0,1,1,0,0,0,0,1,0)
item2 <- cbind(0,0,0,1,0,1,0,1,0,0,1,0)
item3 <- cbind(1,0,1,0,1,1,0,1,1,0,0,0)
item4 <- cbind(0,0,1,1,0,1,0,0,0,1,1,1)

Items <- matrix(c(item1, item2, item3, item4), ncol=4)

library(ltm)
fit <- ltm(Items ~ z1) # two parameter IRT model

response_pattern <- factor.scores(fit, resp.patterns = Items, method = "EB", return.MIvalues = TRUE) #Gets a z score for each response
response_pattern

谢谢!

最佳答案

?str 是 R 工具包中最有用的工具之一。

> str(response_pattern)
List of 6
$ score.dat:'data.frame': 12 obs. of 8 variables:
..$ Item 1: num [1:12] 1 0 1 0 1 1 0 0 0 0 ...
..$ Item 2: num [1:12] 0 0 0 1 0 1 0 1 0 0 ...
..$ Item 3: num [1:12] 1 0 1 0 1 1 0 1 1 0 ...
..$ Item 4: num [1:12] 0 0 1 1 0 1 0 0 0 1 ...
..$ Obs : num [1:12] 2 2 1 1 2 1 2 1 1 2 ...
..$ Exp : num [1:12] 1.051 1.948 1.225 0.668 1.051 ...
..$ z1 : num [1:12] 0.46 -0.6 0.519 -0.326 0.46 ...
..$ se.z1 : num [1:12] 0.558 0.797 0.66 0.713 0.558 ...
$ method : chr "EB"
$ B : num 5
$ call : language ltm(formula = Items ~ z1)
$ resp.pats: logi TRUE
$ coef : num [1:4, 1:2] 0.125 2.3196 0.0241 0.0197 14.6276 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:4] "Item 1" "Item 2" "Item 3" "Item 4"
.. ..$ : chr [1:2] "Dffclt" "Dscrmn"
- attr(*, "class")= chr "fscores"


> response_pattern$score.dat$z1

关于r - 使用 ltm 包从 factor.scores 中提取 z 分数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9491286/

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