#############################################################################
# EXAMPLE 1: Plot item response functions from a unidimensional model
#############################################################################
data(data.Students)
dat <- data.Students
resp <- dat[ , paste0("sc",1:4) ]
resp[ paste(resp[,1]) == 3 ,1] <- 2
psych::describe(resp)
#--- Model 1: PCM in gdm
theta.k <- seq( -5 , 5 , len=21 )
mod1 <- 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
#############################################################################
data( data.fraction2 )
dat <- data.fraction2$data
Qmatrix <- data.fraction2$q.matrix3
# Model 1: 3-dimensional Rasch Model (normal distribution)
theta.k <- seq( -4 , 4 , len=11 ) # discretized ability
mod1 <- 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