#############################################################################
# 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 <- sirt::rm.facets( dat[, paste0( "k",1:5) ], pid=dat$idstud )
#**** Model 2: Generalized Partial Credit Model
mod2 <- sirt::rm.facets( dat[, paste0( "k",1:5) ], pid=dat$idstud, est.a.item=TRUE)
summary(mod1)
summary(mod2)
if (FALSE) {
#############################################################################
# EXAMPLE 2: Facets Model: 5 items, 7 raters
#############################################################################
data(data.ratings1)
dat <- data.ratings1
#**** Model 1: Partial Credit Model: no rater effects
mod1 <- sirt::rm.facets( dat[, paste0( "k",1:5) ], rater=dat$rater,
pid=dat$idstud, est.b.rater=FALSE )
#**** Model 2: Partial Credit Model: intercept rater effects
mod2 <- sirt::rm.facets( dat[, paste0( "k",1:5) ], rater=dat$rater, pid=dat$idstud)
# 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 <- sirt::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)
summary(mod2b)
#**** Model 3: estimated rater slopes
mod3 <- sirt::rm.facets( dat[, paste0( "k",1:5) ], rater=dat$rater,
est.a.rater=TRUE)
#**** Model 4: estimated item slopes
mod4 <- sirt::rm.facets( dat[, paste0( "k",1:5) ], rater=dat$rater,
pid=dat$idstud, est.a.item=TRUE)
#**** Model 5: estimated rater and item slopes
mod5 <- sirt::rm.facets( dat[, paste0( "k",1:5) ], rater=dat$rater,
pid=dat$idstud, est.a.rater=TRUE, est.a.item=TRUE)
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 <- sirt::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)
summary(mod5a)
#**** Model 6: Estimate rater model with reference rater 'db03'
mod6 <- sirt::rm.facets( dat[, paste0( "k",1:5) ], rater=dat$rater, est.a.item=TRUE,
est.a.rater=TRUE, pid=dat$idstud, reference_rater="db03" )
summary(mod6)
#**** Model 7: Modelling rater-item-interactions
mod7 <- sirt::rm.facets( dat[, paste0( "k",1:5) ], rater=dat$rater, est.a.item=FALSE,
est.a.rater=TRUE, pid=dat$idstud, reference_rater="db03",
rater_item_int=TRUE)
summary(mod7)
}
Run the code above in your browser using DataLab