使用包mirt(Rasch模型)制作DIF。我不明白结果

时间:2019-07-18 15:21:32

标签: r

我得到了某人的项目和代码,我无法真正理解他想要做什么,我认为他在代码中也犯了一个错误。 他想从Large MultipleGroupClass(正常工作,并在列AIC,AICc,SABIC,HQ,BIC X2,df和p中给出了正常的值)中创建一个DIF,称为“差异”,但随后他制作了一个无效的循环。这是他的代码:

name.dif<-names(difference)


for(i in 1:extract.mirt(ra5, "nitems")){
  print(paste0("##",i,"##"))

 s.dif<-sum(difference[[name.dif[i]]][["p"]]<=0.05,na.rm=T)
 ID<-name.dif[i]

 if(i==1){
   dif.name<-data.frame(n=i,ID,s.dif)
 } else {
   dif.name<-rbind(dif.name,data.frame(n=i,ID,s.dif))
 }

}

结果是:

[1] "##1##"
Error in difference[[name.dif[i]]][["p"]] : subscript out of bounds

在我看来,我认为他想采用行中项目的名称(“ TP_A2_CE_9998_05”,“ TP_A2_CO_0177_01”等)而不是“差异”的名称,但在这种情况下,总和等于0 。我不知道这是否是一个错误,特别是因为据他说,这样做非常好。

下面的代码允许您重新创建我使用的数据框(摘录)

difference<-structure(list(AIC = c(0, -2.65798975722282, 1.49929917514964, 
-4.8038987828877, 0.0826287581076031, 0.802433983943047, 0.564218552575767, 
0.523164606922364, 1.65717815634707, -0.42597311946156, 1.91236246030167
), AICc = c(0, -1.30637045781623, 2.85091847455624, -3.45227948348111, 
1.4342480575142, 2.15405328334964, 1.91583785198236, 1.87478390632896, 
3.00879745575367, 0.925646179945034, 3.26398175970826), SABIC = c(0, 
-1.69615903534577, 2.46112989702669, -3.84206806101065, 1.04445947998465, 
1.7642647058201, 1.52604927445282, 1.48499532879941, 2.61900887822412, 
0.53585760241549, 2.87419318217871), HQ = c(0, -1.02978545580117, 
3.12750347657129, -3.17569448146605, 1.71083305952925, 2.43063828536469, 
2.19242285399741, 2.15136890834401, 3.28538245776872, 1.20223118196009, 
3.54056676172331), BIC = c(0, 1.47757513385659, 5.63486406622906, 
-0.668333891808288, 4.21819364918701, 4.93799887502246, 4.69978344365518, 
4.65872949800178, 5.79274304742648, 3.70959177161785, 6.04792735138108
), X2 = c(0, 4.65798975722282, 0.500700824850355, 6.8038987828877, 
1.9173712418924, 1.19756601605695, 1.43578144742423, 1.47683539307764, 
0.342821843652928, 2.42597311946156, 0.0876375396983349), df = c(0, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1), p = c(1, 0.0309093594949843, 0.4791923476023, 
0.00909590351739753, 0.166146742877238, 0.273808696491182, 0.230823215709549, 
0.224270311555174, 0.558204911450531, 0.119339112611171, 0.767202296845983
)), row.names = c("TP_A2_CE_9998_05", "TP_A2_CO_0177_01", "TP_A2_CO_0177_02", 
"TP_A2_CO_0177_03", "TP_A2_CO_0177_04", "TP_A2_CO_0177_05", "TP_A2_CO_0177_06", 
"TP_A2_CO_0178_01", "TP_A2_CO_0178_02", "TP_A2_CO_0178_03", "TP_A2_CO_0178_04"
), class = c("mirt_df", "data.frame"))

我想是一笔小数目。实际输出是错误(“下标超出范围”)。

谢谢!

0 个答案:

没有答案