philchalmers / mirt

Multidimensional item response theory
199 stars 75 forks source link

`fscores` fails when custom response pattern has empty rows #220

Closed netique closed 2 years ago

netique commented 2 years ago

Hi,

another issue concerning empty rows:

library(mirt)
#> Loading required package: stats4
#> Loading required package: lattice

mod <- mirt(Science, 1, TOL = .01)
#> Iteration: 1, Log-Lik: -1629.361, Max-Change: 0.50660Iteration: 2, Log-Lik: -1617.374, Max-Change: 0.25442Iteration: 3, Log-Lik: -1612.894, Max-Change: 0.16991Iteration: 4, Log-Lik: -1610.306, Max-Change: 0.10461Iteration: 5, Log-Lik: -1609.814, Max-Change: 0.09162Iteration: 6, Log-Lik: -1609.534, Max-Change: 0.07363Iteration: 7, Log-Lik: -1609.030, Max-Change: 0.03677Iteration: 8, Log-Lik: -1608.988, Max-Change: 0.03200Iteration: 9, Log-Lik: -1608.958, Max-Change: 0.02754Iteration: 10, Log-Lik: -1608.878, Max-Change: 0.01443Iteration: 11, Log-Lik: -1608.875, Max-Change: 0.00847

# new data with empty rows
new_science <- Science
new_science[sample(nrow(new_science), 1), ] <- NA

mod |> fscores(response.pattern = new_science)
#> Error in is.nan(scores): default method not implemented for type 'list'

Created on 2022-03-13 by the reprex package (v2.0.1)

scores object, in this case, contains a list-column, don't know where it originates. Thanks for looking in!

Jan

philchalmers commented 2 years ago

Thanks! Should be patched now.