philchalmers / mirt

Multidimensional item response theory
199 stars 75 forks source link

Error in itemfit(): Error in seq_len(nrow(On) - 1L) : #234

Closed DominiqueMakowski closed 1 year ago

DominiqueMakowski commented 1 year ago

I am encountering an error with itemfit() when used on a 2 item 1 dimension graded model.

Here's a reproducible code:

data <- read.csv("https://raw.githubusercontent.com/RealityBending/IllusionGameReliability/main/data/preprocessed_questionnaires.csv") |> 
  dplyr::select(starts_with("Item_PHQ4")) |> 
  dplyr::select(dplyr::contains("Depression"))

model <- mirt::mirt(data, model = 1, itemtype = 'graded', SE = TRUE)
#> 
#> Calculating information matrix...
mirt::itemfit(model)
#> Warning in seq_len(nrow(On) - 1L): first element used of 'length.out' argument
#> Error in seq_len(nrow(On) - 1L): argument must be coercible to non-negative integer

Created on 2023-01-04 by the reprex package (v2.0.1)

I believe this error has been also reported here: https://groups.google.com/g/mirt-package/c/ldaF3LvHMjY

philchalmers commented 1 year ago

Thanks. However,

1) Unconstrained IRT models with two items are not identified (you would need to add additional constraints, such as setting the slope parameters to be equal).

2) The model you provided does not converge (related to 1), and gives very unstable parameter estimates, like slopes that are tending to infinity, which result in numerically unstable probability functions, particularly when computing things like normalization constants (as is required in itemfit()).

I don't see this as a bug or problem as bizarre behaviour is expected when inspecting non-converged models. It's akin to computing model fit statistics when estimated variance components are negative.