#############################################################################
# EXAMPLE 1: Partial Credit Model and Generalized partial credit model
# 5 items and 1 rater
#############################################################################
data(data.ratings1)
dat <- data.ratings1
# select rater db01
dat <- dat[ paste(dat$rater) == "db01" , ]
# Model 1: Partial Credit Model
mod1 <- rm.facets( dat[ , paste0( "k",1:5) ] , pid=dat$idstud , maxiter=15)
# Model 2: Generalized Partial Credit Model
mod2 <- rm.facets( dat[ , paste0( "k",1:5) ] , pid=dat$idstud ,
est.a.item=TRUE , maxiter=15)
summary(mod1)
summary(mod2)
## Not run:
# #############################################################################
# # EXAMPLE 2: Facets Model: 5 items, 7 raters
# #############################################################################
#
# data(data.ratings1)
# dat <- data.ratings1
# maxit <- 15 # maximum number of iterations, increase it in applications!
#
# # Model 1: Partial Credit Model: no rater effects
# mod1 <- rm.facets( dat[ , paste0( "k",1:5) ] , rater=dat$rater ,
# pid=dat$idstud , est.b.rater=FALSE , maxiter=maxit)
#
# # Model 2: Partial Credit Model: intercept rater effects
# mod2 <- rm.facets( dat[ , paste0( "k",1:5) ] , rater=dat$rater ,
# pid=dat$idstud , maxiter=maxit)
#
# # extract individual likelihood
# lmod1 <- IRT.likelihood(mod1)
# str(lmod1)
# # likelihood value
# logLik(mod1)
# # extract item response functions
# pmod1 <- IRT.irfprob(mod1)
# str(pmod1)
# # model comparison
# anova(mod1,mod2)
# # absolute and relative model fit
# smod1 <- IRT.modelfit(mod1)
# summary(smod1)
# smod2 <- IRT.modelfit(mod2)
# summary(smod2)
# IRT.compareModels( smod1 , smod2 )
# # extract factor scores (EAP is the default)
# IRT.factor.scores(mod2)
# # extract WLEs
# IRT.factor.scores(mod2 , type="WLE")
#
# # Model 2a: compare results with TAM package
# # Results should be similar to Model 2
# library(TAM)
# mod2a <- TAM::tam.mml.mfr( resp= dat[ , paste0( "k",1:5) ] ,
# facets= dat[ , "rater" , drop=FALSE] ,
# pid= dat$pid , formulaA = ~ item*step + rater )
#
# # Model 2b: Partial Credit Model: some fixed parameters
# # fix rater parameters for raters 1, 4 and 5
# b.rater.fixed <- rep(NA,7)
# b.rater.fixed[ c(1,4,5) ] <- c(1,-.8,0) # fixed parameters
# # fix item parameters of first and second item
# tau.item.fixed <- round( mod2$tau.item , 1 ) # use parameters from mod2
# tau.item.fixed[ 3:5 , ] <- NA # free item parameters of items 3, 4 and 5
# mod2b <- rm.facets( dat[ , paste0( "k",1:5) ] , rater=dat$rater ,
# b.rater.fixed=b.rater.fixed , tau.item.fixed=tau.item.fixed ,
# est.mean = TRUE , pid=dat$idstud , maxiter=maxit)
# summary(mod2b)
#
# # Model 3: estimated rater slopes
# mod3 <- rm.facets( dat[ , paste0( "k",1:5) ] , rater=dat$rater ,
# est.a.rater=TRUE , maxiter=maxit)
#
# # Model 4: estimated item slopes
# mod4 <- rm.facets( dat[ , paste0( "k",1:5) ] , rater=dat$rater ,
# pid=dat$idstud , est.a.item=TRUE , maxiter=maxit)
#
# # Model 5: estimated rater and item slopes
# mod5 <- rm.facets( dat[ , paste0( "k",1:5) ] , rater=dat$rater ,
# pid=dat$idstud , est.a.rater=TRUE , est.a.item=TRUE , maxiter=maxit)
# summary(mod1)
# summary(mod2)
# summary(mod2a)
# summary(mod3)
# summary(mod4)
# summary(mod5)
#
# # Model 5a: Some fixed parameters in Model 5
# # fix rater b parameters for raters 1, 4 and 5
# b.rater.fixed <- rep(NA,7)
# b.rater.fixed[ c(1,4,5) ] <- c(1,-.8,0)
# # fix rater a parameters for first four raters
# a.rater.fixed <- rep(NA,7)
# a.rater.fixed[ c(1,2,3,4) ] <- c(1.1,0.9,.85,1)
# # fix item b parameters of first item
# tau.item.fixed <- matrix( NA , nrow=5 , ncol=3 )
# tau.item.fixed[ 1 , ] <- c(-2,-1.5 , 1 )
# # fix item a parameters
# a.item.fixed <- rep(NA,5)
# a.item.fixed[ 1:4 ] <- 1
# # estimate model
# mod5a <- rm.facets( dat[ , paste0( "k",1:5) ] , rater=dat$rater ,
# pid=dat$idstud , est.a.rater=TRUE , est.a.item=TRUE ,
# tau.item.fixed=tau.item.fixed , b.rater.fixed=b.rater.fixed ,
# a.rater.fixed=a.rater.fixed , a.item.fixed=a.item.fixed ,
# est.mean=TRUE , maxiter=maxit)
# summary(mod5a)
# ## End(Not run)
Run the code above in your browser using DataLab