Calculating IMV values

Here is a slightly more complex example that takes advantage of irw to easily fetch a dataset and to then compute the InterModel Vigorish contrasting predictings for the 2PL to predictions from the 1PL for an example dataset (using cross-validation; see also the documentation in the related imv package). Note the irw_long2resp function which is helpful for reformatting IRW data from long to wide. We have also tried to further illustrate how the IMV can be used to understand predictions here.

Code
library(imv)
library(irw)
library(mirt)
df   <- irw::irw_fetch("gilbert_meta_2")

# Convert from long format (one row per person-item) to wide response matrix
resp <- irw::irw_long2resp(df)
resp$id <- NULL
# Rasch / 1PL model
m0 <- mirt::mirt(resp, 1, 'Rasch', verbose = FALSE)

# 2PL model with log-normal prior on discriminations
ni    <- ncol(resp)
s     <- paste0("F = 1-", ni, "\n",
                "PRIOR = (1-", ni, ", a1, lnorm, 0.0, 1.0)")
model <- mirt::mirt.model(s)
m1    <- mirt::mirt(resp, model,
                    itemtype  = rep("2PL", ni),
                    method    = "EM",
                    technical = list(NCYCLES = 10000),
                    verbose   = FALSE)

set.seed(8675309)
result <- imv(m0, m1)
result
$folds
[1] 0.017189426 0.014739478 0.014186878 0.014899954 0.009752082

$mean
[1] 0.01415356

$sd
[1] 0.002715281

$ci
     lower      upper 
0.01177351 0.01653361