Learn R Programming

TAM (version 4.2-21)

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)

# S3 method for msq.itemfit summary(object, file=NULL, ... )

msq.itemfitWLE( tamobj, fitindices=NULL, ... )

# S3 method for msq.itemfitWLE summary(object, file=NULL, ... )

Value

List with following entries

itemfit

Data frame with outfit and infit statistics.

summary_itemfit

Summary statistics of outfit and infit

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.

tamobj

Object of class tam.mml, tam.mml.2pl or tam.mml.mfr.

file

Optional name of a file to which the summary should be written

...

Further arguments to be passed

See Also

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

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

Examples

Run this code
if (FALSE) {

#############################################################################
# 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::tam.mml(resp=dat)
# compute WLEs
wmod1 <- TAM::tam.wle(mod1)$theta

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

#--- item fit using simulation in "tam.fit"
fit0 <- TAM::tam.fit( mod1 )
summary(fit0)

#--- item fit based on WLEs
fit2a <- TAM::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 <- TAM::msq.itemfit( mod1, fitindices )
summary(fit2)

# using WLEs
fit2b <- TAM::msq.itemfitWLE( mod1, fitindices )
summary(fit2b)

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

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

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

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

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

#############################################################################
# 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::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::tam.fit( mod )
fmod1b <- TAM::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 <- TAM::msq.itemfit( mod, item_parm )
res2b <- TAM::msq.itemfitWLE( mod, item_parm )
summary(res2a)
summary(res2b)

# fit for raters
res3a <- TAM::msq.itemfit( mod, rater_parm )
res3b <- TAM::msq.itemfitWLE( mod, rater_parm )
summary(res3a)
summary(res3b)
}

Run the code above in your browser using DataLab