【问题标题】:Trying to find a way to combine IRT info plots from 3 different mirt models in R in the same试图找到一种方法将来自 R 中 3 个不同 mirt 模型的 IRT 信息图组合在一起
【发布时间】:2020-04-29 16:37:07
【问题描述】:

我希望将所有三个“测试信息函数”行(每个模型一个)合并到一个相同的图表中。我有一个 1-5 类李克特响应的数据集,有 400 行,每列 8 列(每个项目一个)。我使用 R 中的 mirt 包在这些集合上运行了三个 IRT 模型,并生成了测试信息图。我想将来自三个不同(分级响应)模型、三行的 IRT 测试信息图组合在一个相同的网格中。

plot(PFgrmodel29, type = 'info', xlim = c(-4, 4), ylim=c(0,85)) 
plot(PFgrmodel43, type = 'info', xlim = c(-4, 4), ylim=c(0,85)) 
plot(PFgrmodel57, type = 'info', xlim = c(-4, 4), ylim=c(0,85))

测试信息图示例:

如何使用 mirt、lattice、ggplot2 或类似工具实现此目的?

【问题讨论】:

  • 你能提供至少一个例子吗?如果可以从模型中提取数据,则很容易将它们绘制在一起,例如与ggplot 的构面..
  • 谢谢。我添加了一个情节。谢谢你的提示。那么需要以某种方式捕获输出。

标签: r ggplot2 plot lattice likert


【解决方案1】:

您的 mirt 包中的图是一个 lattice 对象,因此您可以尝试使用 latticeExtra,由于您没有提供数据集,我在下面使用包中的示例数据集提供示例代码:

library(mirt)
library(latticeExtra)

fulldata <- expand.table(LSAT7)
mod1 <- mirt(fulldata,1,SE=TRUE)
mod2 <- mirt(fulldata,1, itemtype = 'Rasch')
mod3 <- mirt(fulldata,1,itemtype='ideal')

key=list(columns=2, 
        text=list(lab=c("mod1","mod2","mod3")), 
        lines=list(lwd=4, col=c("blue","orange","red"))
)

p1 = plot(mod1,type="info",key=key)
p2 = update(plot(mod2,type="info"),col="orange")
p3 = update(plot(mod3,type="info"),col="red")
p1+p2+p3

【讨论】:

  • 这看起来正是我正在寻找的,我将调整代码并尝试。抱歉,我无权分享数据集,但我使用的是在 mirt 包中创建的分级响应 IRT 模型,该模型来自 8 列和 400 行,只有数字 1-5 数据,没有 N/As。
  • 嗯 - 我仍然得到三个并排的图表。我希望将所有三个“测试信息功能”行(每个模型一个)组合成一个相同的图表。
  • 哦,对了.. 抱歉,不清楚。我现在编辑我的答案
  • @SteinR,我已经编辑了答案。它应该适用于 3 个图。抱歉没有更简单的方法,除非您实际访问拟合下的数据。
  • 这简直太美了!就像一个魅力,除了我需要修改 y 轴(更高)以适应数据。我认为首先放置具有最高信息曲线的模型(作为 mod1)会做到这一点,但没有。非常感谢您将我引导至 gridExtra 并提供代码!!我的代码现在看起来像这样: > model
【解决方案2】:

简直太美了!就像一个魅力,除了我需要添加 ylim=c(0,100) 来修改 y 轴(更高)以适应数据。我认为首先放置具有最高信息曲线的模型(作为 mod1)会做到这一点,但没有。非常感谢 Stupidwolf 提供代码!!不需要 latticeExtra 包。 此外,我还必须保留代码的“模型”部分才能正常工作:
model
我的代码现在看起来像这样:

library(mirt)
library(latticeExtra)
model <- 'F = 1-5 PRIOR = (5, g, norm, -1.5, 3)' 

mod1 <- mirt(PFdata57,1,itemtype="graded", SE=TRUE)
mod2 <- mirt(PFdata43,1,itemtype="graded", SE=TRUE)
mod3 <- mirt(PFdata29,1,itemtype="graded", SE=TRUE)

key=list(columns=1, 
text=list(lab=c("P57/PF Short form 8a","P43/PF Short form 6a","P29/PF Short form 4a")), 
lines=list(lwd=4, col=c("blue","orange","red")))

     p1 = plot(mod1,type="info",key=key,xlim=c(-4,4),ylim=c(0,85))
     p2 = update(plot(mod2,type="info"),col="orange")
     p3 = update(plot(mod3,type="info"),col="red")
     p1+p2+p3

【讨论】:

    猜你喜欢
    • 2021-04-16
    • 1970-01-01
    • 2020-04-21
    • 1970-01-01
    • 2017-09-07
    • 1970-01-01
    • 1970-01-01
    • 2016-05-22
    • 1970-01-01
    相关资源
    最近更新 更多