if (FALSE) {
#############################################################################
# EXAMPLE 1: Plot item response functions from a unidimensional model
#############################################################################
data(data.Students, package="CDM")
dat <- data.Students
resp <- dat[, paste0("sc",1:4) ]
resp[ paste(resp[,1])==3,1] <- 2
psych::describe(resp)
#--- Model 1: PCM in CDM::gdm
theta.k <- seq( -5, 5, len=21 )
mod1 <- CDM::gdm( dat=resp, irtmodel="1PL", theta.k=theta.k, skillspace="normal",
centered.latent=TRUE)
summary(mod1)
# plot
IRT.irfprobPlot( mod1 )
# plot in graphics package (which comes with R base version)
IRT.irfprobPlot( mod1, package="graphics")
# plot first and third item and do not smooth discretized item response
# functions in IRT.irfprob
IRT.irfprobPlot( mod1, items=c(1,3), smooth=FALSE )
# cumulated IRF
IRT.irfprobPlot( mod1, cumul=TRUE )
#############################################################################
# EXAMPLE 2: Fitted mutidimensional model with gdm
#############################################################################
dat <- CDM::data.fraction2$data
Qmatrix <- CDM::data.fraction2$q.matrix3
# Model 1: 3-dimensional Rasch Model (normal distribution)
theta.k <- seq( -4, 4, len=11 ) # discretized ability
mod1 <- CDM::gdm( dat, irtmodel="1PL", theta.k=theta.k, Qmatrix=Qmatrix,
centered.latent=TRUE, maxiter=10 )
summary(mod1)
# unsmoothed curves
IRT.irfprobPlot(mod1, smooth=FALSE)
# smoothed curves
IRT.irfprobPlot(mod1)
}
Run the code above in your browser using DataLab