#############################################################################
# EXAMPLE 1: 11 Items: 2 itemclusters with 2 resp. 3 dependent items
# and 6 independent items
#############################################################################
set.seed(7654)
I <- 11 # number of items
n <- 1500 # number of persons
b <- seq(-2,2, len=I) # item difficulties
theta <- stats::rnorm( n, sd=1 ) # person abilities
# itemcluster
itemcluster <- rep(0,I)
itemcluster[ c(3,5)] <- 1
itemcluster[c(2,4,9)] <- 2
# residual correlations
rho <- c( .7, .5 )
# simulate data
dat <- sirt::sim.rasch.dep( theta, b, itemcluster, rho )
colnames(dat) <- paste("I", seq(1,ncol(dat)), sep="")
# estimate Rasch copula model
mod1 <- sirt::rasch.copula2( dat, itemcluster=itemcluster )
summary(mod1)
# compare result with Rasch model estimation in rasch.copula
# delta must be set to zero
mod2 <- sirt::rasch.copula2( dat, itemcluster=itemcluster, delta=c(0,0),
est.delta=c(0,0) )
summary(mod2)
# estimate Rasch model with rasch.mml2 function
mod3 <- sirt::rasch.mml2( dat )
summary(mod3)
if (FALSE) {
#############################################################################
# EXAMPLE 2: 12 Items: Cluster 1 -> Items 1,...,4;
# Cluster 2 -> Items 6,...,9; Cluster 3 -> Items 10,11,12
#############################################################################
set.seed(7896)
I <- 12 # number of items
n <- 450 # number of persons
b <- seq(-2,2, len=I) # item difficulties
b <- sample(b) # sample item difficulties
theta <- stats::rnorm( n, sd=1 ) # person abilities
# itemcluster
itemcluster <- rep(0,I)
itemcluster[ 1:4 ] <- 1
itemcluster[ 6:9 ] <- 2
itemcluster[ 10:12 ] <- 3
# residual correlations
rho <- c( .55, .25, .45 )
# simulate data
dat <- sirt::sim.rasch.dep( theta, b, itemcluster, rho )
colnames(dat) <- paste("I", seq(1,ncol(dat)), sep="")
# estimate Rasch copula model
mod1 <- sirt::rasch.copula2( dat, itemcluster=itemcluster, numdiff.parm=.001 )
summary(mod1)
# Rasch model estimation
mod2 <- sirt::rasch.copula2( dat, itemcluster=itemcluster,
delta=rep(0,3), est.delta=rep(0,3) )
summary(mod2)
# estimation with pairwise Rasch model
mod3 <- sirt::rasch.pairwise( dat )
summary(mod3)
}
Run the code above in your browser using DataLab