我正在尝试为kcirt软件包创建一个R脚本
到目前为止,我仍然找不到
这是我创建的伪脚本:
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) ???