1
$\begingroup$
library(mirt)
library(eRm)

# Simulation of dichotomous data
set.seed(3)
n_items <- 40
n_cand  <- 1000
diff <- rnorm(n_items, 0, 1) |> sort() 
abilities <- rnorm(n_cand, 0, 1)
sim_data <- sapply(1:n_items, \(i) as.numeric(1 / (1 + exp ((diff[i] - abilities))) > 
                                                       runif(n_cand, 0, 1)))
colnames(sim_data) <- paste0("Item ", seq_len(n_items))

## MIRT
model.mirt <- mirt(sim_data, 1, itemtype = "Rasch", verbose = FALSE)
res.mirt <- mirt::itemfit(model.mirt, 'infit')

# eRM
model.erm <- RM(sim_data)
res.erm <- person.parameter(model.erm) |> eRm::itemfit()

# All the following correlations are not equal to 1 (and far from it)
cor(res.mirt[, "infit"], res.erm$i.infitMSQ, method = "spearman")
cor(res.mirt[, "z.infit"], res.erm$i.infitZ, method = "spearman")
cor(res.mirt[, "outfit"], res.erm$i.outfitMSQ, method = "spearman")
cor(res.mirt[, "z.outfit"], res.erm$i.outfitZ, method = "spearman")

The items' difficulties are the same

item_mirt <- coef(model.mirt, IRTpars = TRUE, simplify = TRUE)$items[, "b"]
item_erm <- - coef(model.erm)
cor(item_mirt, item_erm, method = "spearman")
# [1] 1
$\endgroup$

1 Answer 1

5
$\begingroup$

The default estimation methods for the person parameters may differ between the two packages.

Your example yields:

> # All the following correlations are not equal to 1 (and far from it)
> cor(res.mirt[, "infit"], res.erm$i.infitMSQ, method = "spearman")
[1] 0.9613508
> cor(res.mirt[, "z.infit"], res.erm$i.infitZ, method = "spearman")
[1] 0.8726079
> cor(res.mirt[, "outfit"], res.erm$i.outfitMSQ, method = "spearman")
[1] 0.9658537
> cor(res.mirt[, "z.outfit"], res.erm$i.outfitZ, method = "spearman")
[1] 0.884803

After specifying ML estimation for the itemfit of MIRT, we get:

> res.mirt <- mirt::itemfit(model.mirt, 'infit', method="ML") 
> # All the following correlations are equal to 1
> cor(res.mirt[, "infit"], res.erm$i.infitMSQ, method = "spearman")
[1] 0.9998124
> cor(res.mirt[, "z.infit"], res.erm$i.infitZ, method = "spearman")
[1] 0.9998124
> cor(res.mirt[, "outfit"], res.erm$i.outfitMSQ, method = "spearman")
[1] 1
> cor(res.mirt[, "z.outfit"], res.erm$i.outfitZ, method = "spearman")
[1] 0.9998124
$\endgroup$
1
  • 2
    $\begingroup$ This is correct. The packages use different default estimators for the latent traits (ML vs EAP). ML is the cannonical way to use this fit statistics $\endgroup$ Commented Aug 9 at 15:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.