本文将讲述如何通过R语言计算item的区分度。
setwd("C:\\...")###设定分析文档所在目录###
resp = read.csv("data.csv",row.names = 1)###data.csv为测试者作答得分数据表;是1个数据矩阵###
library(TAM)###载入IRT分析包###
mod1 = tam(resp)###进行IRT分析###
Abil = tam.wle(mod1)###求测试者的能力值###
PersonAbility = Abil$theta
PersonAbility###PersonAbility为根据作答数据求出的测试者能力值,为1列数据###
#######################################
##############区分度(相关法)#############
#######################################
##区分度(相关法)- 即求能力值与实际作答的相关##
discrim = cor(resp,PersonAbility,use="complete.ob")##discrim即求出的区分度,为1列数据##
discrim###discrim为求出的能力值相关区分度,为1列数据###
##区分度(相关法)- 即求实际所有题的总得分与某道题作答得分的相关##
row.sums = apply(resp,1,sum,na.rm = TRUE)###求每人在所有题的总得分,为1列数据###
disob = cor(resp,row.sums,use="complete.ob")##disob即为求出的区分度##
disob###disob为求出的总分相关区分度,为1列数据###
#######################################
##########区分度(鉴别法)#############
#######################################
###区分度(鉴别法)即通过计算高分组测试者与低分组测试者的表现差异来定义区分度####
low = quantile(row.sums, probs = 0.27, na.rm = TRUE,names = TRUE)######将得分在后27%的人设为低分组,该数值可根据实际情况自行设定##
high = quantile(row.sums, probs = 0.73, na.rm = TRUE,names = TRUE)######将得分在前27%的人设为高分分组,该数值可根据实际情况自行设定##
toresp = cbind(resp,row.sums)
lowl = ifelse(toresp$row.sums<low,1,0)
highl = ifelse(toresp$row.sums>high,1,0)
hilo=cbind(toresp,lowl,highl)
diss = NULL
dis = list()
for (i in 1:ncol(resp)){
meanm = tapply(resp[,i], list(lowl, highl), mean, na.rm=TRUE)
lmean = meanm[2,1]
hmean = meanm[1,2]
max = max(resp[,i], na.rm=TRUE)
l = lmean/max
h = hmean/max
dis[[i]] = h-l
diss = rbind(diss,dis[[i]])
}
diss##diss即为求出的鉴别法区分度,为1列数据##
result = cbind(diss,discrim,disob)##将求出的三种区分度放在一个表格中###
colnames(result) = c("diss","discrim","disob")##给各列命名###
write.csv(result,"result.csv")###导出结果####
博主您好,我是一名R的初学者。请问可以跟您要一下您在做区分度时候的数据吗?想实际操作一下。万分感谢