Learn R Programming

TAM (version 1.995-0)

msq.itemfit: Mean Squared Residual Based Item Fit Statistics (Infit, Outfit)

Description

The function msq.itemfit computes computed the outfit and infit statistic for items or item groups. Contrary to tam.fit, the function msq.itemfit is not based on simulation from individual posterior distributions but rather on evaluating the individual posterior.

The function msq.itemfit also computes the outfit and infit statistics but these are based on weighted likelihood estimates obtained from tam.wle.

Usage

msq.itemfit( object , fitindices=NULL, version=2 )
"summary"(object, ... )
msq.itemfitWLE( tamobj , fitindices=NULL , ... )
"summary"(object, ... )

Arguments

object
Object for which the classes IRT.data, IRT.posterior and predict are defined.
fitindices
Vector with parameter labels defining the item groups for which the fit should be evaluated.
version
The Rcpp function used for calculation. version=1 provides results compatible with TAM version $\le$1.99-6. A pure R routine can be requested by version=3.
tamobj
Object of class tam.mml, tam.mml.2pl or tam.mml.mfr.
...
Further arguments to be passed

Value

List with following entries
itemfit
Data frame with outfit and infit statistics.
summary_itemfit
Summary statistics of outfit and infit

See Also

See also tam.fit for simulation based assessment of item fit.

See also eRm::itemfit or mirt::itemfit.

Examples

Run this code
#############################################################################
# SIMULATED EXAMPLE 1: Simulated data Rasch model
############################################################################# 	

#*** simulate data
library(sirt)
set.seed(9875)
N <- 2000
I <- 20
b <- sample( seq( -2 , 2 , length=I ) )
a <- rep( 1, I )
# create some misfitting items
a[c(1,3)] <- c(.5 , 1.5 )
# simulate data
dat <- sirt::sim.raschtype( rnorm(N) , b=b , fixed.a=a )
#*** estimate Rasch model
mod1 <- tam.mml(resp=dat) 
# compute WLEs
wmod1 <- tam.wle(mod1)$theta

#--- item fit from "msq.itemfit" function
fit1 <- msq.itemfit(mod1)
summary( fit1 )

## Not run: 
# #--- item fit using simulation in "tam.fit"
# fit0 <- tam.fit( mod1 )
# summary(fit0)
# 
# #--- item fit based on WLEs
# fit2a <- msq.itemfitWLE( mod1 )
# summary(fit2a)
# 
# #++ fit assessment in mirt package
# library(mirt)
# mod1b <- mirt::mirt( dat , model=1 , itemtype="Rasch" , verbose=TRUE )
# print(mod1b)
# sirt::mirt.wrapper.coef(mod1b)
# fmod1b <- mirt::itemfit(mod1b , Theta= as.matrix(wmod1,ncol=1) ,
#                  Zh = TRUE, X2 = FALSE, S_X2 = FALSE )
# cbind( fit2a$fit_data , fmod1b )
# 
# #++ fit assessment in eRm package
# library(eRm)
# mod1c <- eRm::RM( dat )
# summary(mod1c)
# eRm::plotPImap(mod1c)    # person-item map
# pmod1c <- eRm::person.parameter(mod1c)
# fmod1c <- eRm::itemfit(pmod1c)
# print(fmod1c)
# plot(fmod1c)
# 
# #--- define some item groups for fit assessment
# 
# # bases on evaluating the posterior
# fitindices <- rep( paste0("IG",c(1,2)) , each=10)
# fit2 <- msq.itemfit( mod1 , fitindices )
# summary(fit2)
# 
# # using WLEs
# fit2b <- msq.itemfitWLE( mod1 , fitindices )
# summary(fit2b)
# ## End(Not run)	

#############################################################################
# EXAMPLE 2: data.read | fit statistics assessed for testlets
############################################################################# 

library(sirt)
data(data.read,package="sirt")
dat <- data.read

# fit Rasch model
mod <- tam.mml( dat )

#***** item fit for each item
# based on posterior
res1 <- msq.itemfit( mod  )
summary(res1)
# based on WLEs
res2 <- msq.itemfitWLE( mod  )
summary(res2)

#***** item fit for item groups
# define item groups
fitindices <- substring( colnames(dat) , 1 , 1 )
# based on posterior
res1 <- msq.itemfit( mod , fitindices )
summary(res1)
# based on WLEs
res2 <- msq.itemfitWLE( mod , fitindices )
summary(res2)

## Not run: 
# #############################################################################
# # EXAMPLE 3: Fit statistics for rater models
# ############################################################################# 
# 
# library(sirt)
# data(data.ratings2, package="sirt")
# dat <- data.ratings2
# 
# # fit rater model "~ item*step + rater"
# mod <- tam.mml.mfr( resp= dat[ , paste0( "k",1:5) ] , 
#             facets= dat[ , "rater" , drop=FALSE] ,
#             pid= dat$pid , formulaA = ~ item*step + rater )
# 
# # fit for parameter with "tam.fit" function
# fmod1a <- tam.fit( mod )
# fmod1b <- msq.itemfit( mod )
# summary(fmod1a)
# summary(fmod1b)
# 
# # define item groups using pseudo items from object "mod"
# pseudo_items <- colnames(mod$resp)
# pss <- strsplit( pseudo_items , split="-" )
# item_parm <- unlist( lapply( pss , FUN = function(ll){ ll[1] } ) )
# rater_parm <- unlist( lapply( pss , FUN = function(ll){ ll[2] } ) )
# 
# # fit for items with "msq.itemfit" functions
# res2a <- msq.itemfit( mod , item_parm )
# res2b <- msq.itemfitWLE( mod , item_parm )
# summary(res2a)
# summary(res2b)
# 
# # fit for raters
# res3a <- msq.itemfit( mod , rater_parm )
# res3b <- msq.itemfitWLE( mod , rater_parm )
# summary(res3a)
# summary(res3b)
# ## End(Not run)	

Run the code above in your browser using DataLab