kcirt软件包工作流程示例

时间:2019-06-04 11:49:21

标签: r statistics

我正在尝试为kcirt软件包创建一个R脚本

  • 从一个定性问卷中获取答案,
  • 创建IRT模型
  • 根据创建的模型为新的响应评分

到目前为止,我仍然找不到

  • 如何根据未使用该程序包模拟的响应来构建模型
  • 如何使用模型对新的响应进行评分

这是我创建的伪脚本:

library(kcirt)
options(stringsAsFactors=FALSE, width=140)
set.seed(99999)

# 4 scales, 4 items in a group, all positive loadings, 24 item groups, 200 cases
gT<-c(1,NA,NA,4) #group template
iN=4 #num items in group
gN=24 #num itemgroup in test - 96 items
cN=200 #num cases

# An example group of items
# I am the sort of person who
#  - sees the big picture
#  - shows enthusiasm
#  - supports others
#  - enjoys independence

#generate random test data as I would have it in the database
mxData <-matrix(
  replicate(gN*cN,
            sample(gT,iN) #an item group
  ) # all cases
, byrow = F, ncol = cN, nrow = iN*gN)

covEta <- diag(1, 4) # four scales
constructMap.ls <- replicate(gN, c(1,2,3,4), simplify=FALSE) #items always load to the same scales within a group
mxLambda <- rep(1,iN*gN) #item directions
qTypes <- rep("M",gN) #response format
mu <- rep(0, length(mxLambda)) #utilities

#how to do this? create model from case data  ***********************************************
mod <- kcirt.model(data=mxData, constructMap.ls=constructMap.ls, qTypes=qTypes, mxLambda=mxLambda,  mu=mu, covEta=covEta)
mod <- kcirt.fitMSS(model=mod, lambdaConstraint="self", kcpus=2, penalty="L2", usetruesigma=TRUE, mss.sd=1)

#how to do this? get the 4 scale scores for a new case ***********************************************
cD=matrix(replicate(gN, sample(gT,iN)), nrow = iN*gN) #new random case data
kcirt.score(mod,cD) ???

0 个答案:

没有答案