Closed netique closed 2 years ago
Can you provide a reproducible example of this? I don't see the change you're referring to. Thanks.
library(mirt)
#> Warning: package 'mirt' was built under R version 4.0.5
#> Loading required package: stats4
#> Loading required package: lattice
#> Warning: package 'lattice' was built under R version 4.0.5
mod <- mirt(Science, 2, TOL=.01)
fs <- fscores(mod)
head(fs)
#> F1 F2
#> [1,] -0.35204296 0.6606722
#> [2,] -0.01449952 0.1201497
#> [3,] 0.57747572 -1.0050485
#> [4,] 0.57747572 -1.0050485
#> [5,] -0.08768448 1.0232843
#> [6,] -0.75955060 0.8650403
model <- 'this = 1-3
that = 2-4'
mod2 <- mirt(Science, model, TOL=.01)
fs2 <- fscores(mod2)
head(fs2)
#> this that
#> [1,] 0.87822600 -0.38884876
#> [2,] -0.04466289 0.10589125
#> [3,] -0.88730995 -0.60420773
#> [4,] -0.88730995 -0.60420773
#> [5,] 1.13280708 0.37017709
#> [6,] 0.67229000 0.05898098
Created on 2022-01-03 by the reprex package (v2.0.1)
Sorry for the absent reprex. In meanwhile, I discovered that this issue is only present when there are completely empty rows in the data:
library(mirt)
#> Loading required package: stats4
#> Loading required package: lattice
# introduce empty row
Science[sample(nrow(Science), 1), ] <- NA
mod <- mirt(Science, 1, TOL = .01)
#> Warning: data contains response patterns with only NAs
#> Iteration: 1, Log-Lik: -1625.876, Max-Change: 0.48834Iteration: 2, Log-Lik: -1613.767, Max-Change: 0.24061Iteration: 3, Log-Lik: -1609.221, Max-Change: 0.17940Iteration: 4, Log-Lik: -1606.734, Max-Change: 0.10320Iteration: 5, Log-Lik: -1606.210, Max-Change: 0.09513Iteration: 6, Log-Lik: -1605.898, Max-Change: 0.07813Iteration: 7, Log-Lik: -1605.311, Max-Change: 0.03422Iteration: 8, Log-Lik: -1605.271, Max-Change: 0.03069Iteration: 9, Log-Lik: -1605.244, Max-Change: 0.02644Iteration: 10, Log-Lik: -1605.176, Max-Change: 0.01442Iteration: 11, Log-Lik: -1605.172, Max-Change: 0.00908
fs <- fscores(mod)
head(fs)
#> [,1]
#> [1,] 0.40245938
#> [2,] 0.05130783
#> [3,] -0.89092054
#> [4,] -0.89092054
#> [5,] 0.76282310
#> [6,] 0.67152043
mod2 <- "this = 1-3
that = 2-4"
mod2 <- mirt(Science, mod2, TOL = .01)
#> Warning: data contains response patterns with only NAs
#> Iteration: 1, Log-Lik: -1636.290, Max-Change: 0.35303Iteration: 2, Log-Lik: -1626.232, Max-Change: 0.15746Iteration: 3, Log-Lik: -1623.878, Max-Change: 0.17703Iteration: 4, Log-Lik: -1621.088, Max-Change: 0.08666Iteration: 5, Log-Lik: -1620.768, Max-Change: 0.06429Iteration: 6, Log-Lik: -1620.622, Max-Change: 0.06059Iteration: 7, Log-Lik: -1620.402, Max-Change: 0.05045Iteration: 8, Log-Lik: -1620.366, Max-Change: 0.04481Iteration: 9, Log-Lik: -1620.338, Max-Change: 0.04012Iteration: 10, Log-Lik: -1620.232, Max-Change: 0.02663Iteration: 11, Log-Lik: -1620.222, Max-Change: 0.02430Iteration: 12, Log-Lik: -1620.214, Max-Change: 0.02673Iteration: 13, Log-Lik: -1620.182, Max-Change: 0.01006Iteration: 14, Log-Lik: -1620.176, Max-Change: 0.01410Iteration: 15, Log-Lik: -1620.172, Max-Change: 0.01480Iteration: 16, Log-Lik: -1620.158, Max-Change: 0.01524Iteration: 17, Log-Lik: -1620.156, Max-Change: 0.00436
fs2 <- fscores(mod2)
head(fs2)
#> [,1] [,2]
#> [1,] 0.88919756 -0.38737883
#> [2,] -0.04477272 0.10392385
#> [3,] -0.88273333 -0.61129919
#> [4,] -0.88273333 -0.61129919
#> [5,] 1.12612844 0.37932512
#> [6,] 0.68469179 0.05696166
Created on 2022-01-03 by the reprex package (v2.0.1)
Confirmed; the column names were not being preserved when adding the NA placeholders for completely missing vectors. Should be patched now; thanks for the report!
Hi,
in the latest release 1.35.1,
fscores
no longer retain names specified in the mirt model. For one-dimensional models, it prints out F1, F1_SE as it used previously, but for multidimensional one, the function returns an unnamed matrix. Is it deliberate or is it a bug introduced by an update? Version 1.34 outputs as expected.Many thanks and keep up the good work! Jan