#############################################################################
# EXAMPLE 1: Dataset with mixed dichotomous and polytomous responses
#############################################################################
data(data.mixed1)
dat <- data.mixed1
#****
# Model 1: Partial credit model
# estimate model with TAM package
library(TAM)
mod1 <- TAM::tam.mml( dat )
# estimate person parameter estimates
wmod1 <- TAM::tam.wle( mod1 )
wmod1 <- wmod1[ order(wmod1$theta) , ]
# extract item parameters
A <- mod1$B[,-1,1]
B <- mod1$AXsi[,-1]
# person parameters and standard errors
theta <- wmod1$theta
error <- wmod1$error
# estimate true score transformation
dfr <- truescore.irt( A=A , B=B , theta=theta , error=error )
# plot different person parameter estimates and standard errors
par(mfrow=c(2,2))
plot( theta , dfr$truescore , pch=16 , cex=.6 , xlab=expression(theta) , type="l",
ylab=expression(paste( tau , "(",theta , ")" )) , main="True Score Transformation" )
plot( theta , dfr$percscore , pch=16 , cex=.6 , xlab=expression(theta) , type="l",
ylab=expression(paste( pi , "(",theta , ")" )) , main="Percent Score Transformation" )
points( theta , dfr$lower + (dfr$upper-dfr$lower)*plogis(dfr$a*theta+dfr$b) , col=2 , lty=2)
plot( theta , error , pch=16 , cex=.6 , xlab=expression(theta) , type="l",
ylab=expression(paste("SE(",theta , ")" )) , main="Standard Error Theta" )
plot( dfr$truescore , dfr$truescore.error , pch=16 , cex=.6 , xlab=expression(tau) ,
ylab=expression(paste("SE(",tau , ")" ) ) , main="Standard Error True Score Tau" ,
type="l")
par(mfrow=c(1,1))
#****
# Model 2: Generalized partial credit model
mod2 <- TAM::tam.mml.2pl( dat , irtmodel="GPCM")
# estimate person parameter estimates
wmod2 <- TAM::tam.wle( mod2 )
# extract item parameters
A <- mod2$B[,-1,1]
B <- mod2$AXsi[,-1]
# person parameters and standard errors
theta <- wmod2$theta
error <- wmod2$error
# estimate true score transformation
dfr <- truescore.irt( A=A , B=B , theta=theta , error=error )
#############################################################################
# EXAMPLE 2: Dataset Reading data.read
#############################################################################
data(data.read)
#****
# Model 1: estimate difficulty + guessing model
mod1 <- rasch.mml2( data.read , fixed.c = rep(.25,12) )
mod1$person <- mod1$person[ order( mod1$person$EAP) , ]
# person parameters and standard errors
theta <- mod1$person$EAP
error <- mod1$person$SE.EAP
A <- rep(1,12)
B <- - mod1$item$b
c <- rep(.25,12)
# estimate true score transformation
dfr <- truescore.irt( A=A , B=B , theta=theta , error=error ,c=c)
plot( theta , dfr$percscore , pch=16 , cex=.6 , xlab=expression(theta) , type="l",
ylab=expression(paste( pi , "(",theta , ")" )) , main="Percent Score Transformation" )
points( theta , dfr$lower + (dfr$upper-dfr$lower)*plogis(dfr$a*theta+dfr$b) , col=2 , lty=2)
#****
# Model 2: Rasch model
mod2 <- rasch.mml2( data.read )
# person parameters and standard errors
theta <- mod2$person$EAP
error <- mod2$person$SE.EAP
A <- rep(1,12)
B <- - mod2$item$b
# estimate true score transformation
dfr <- truescore.irt( A=A , B=B , theta=theta , error=error )
Run the code above in your browser using DataLab