constructMap.ls <- list(
c(1,1,2,2),
c(1,1,3,3),
c(2,2,3,3),
c(1,1,2,2),
c(1,1,3,3),
c(2,2,3,3),
c(1,2),
c(2,3),
c(1,3)
)
qTypes <- rep("R", length(constructMap.ls))
mod <- kcirt.model(constructMap.ls=constructMap.ls, qTypes=qTypes, mxLambda=NULL)
N <- 200
set.seed(99999)
mod <- kcirt.sim(model=mod, N=N)
ikcirt.df1(mod, "self")
####### create initial guess for hyperparameters (aka loadings)
mod$mxHatLambda <- mod$mxLambda - matrix( rnorm( sum(mod$ns)^2, 0, 0.3 ), sum(mod$ns), sum(mod$ns) )
####### need to assign hat states and utilities
mod$mxHatEta <- matrix(0, N, sum(mod$nuc))
mod$hatMu <- rep(0, sum(mod$ns))
###### run MSS fit -- performance is R^2 btwn true and pred states (aka scales)
mod <- kcirt.fitMSS(model=mod, lambdaConstraint="self", kcpus=2, penalty="L2",
usetruesigma=TRUE, mss.sd=1)
mod$performance
###### run again ...
mod <- kcirt.fitMSS(model=mod, lambdaConstraint="self", kcpus=2, penalty="L2",
usetruesigma=TRUE, mss.sd=1)
mod$performance
###### run a few more times ... ...Run the code above in your browser using DataLab