philchalmers / mirt

Multidimensional item response theory
https://philchalmers.github.io/mirt/
201 stars 75 forks source link

Feature request: covariance between individual multidimensional factor scores #222

Closed StaffanBetner closed 2 years ago

StaffanBetner commented 2 years ago

It would be very useful to be able to get the covariance between, e.g. the factor scores in two dimensions for a two-dimensional model, on an individual level.

philchalmers commented 2 years ago

You can obtain the individual asymptotic correlation components by passing the flag return.acov=TRUE, like the following:

> library(mirt)
> mod <- mirt(Science, 2)
Iteration: 313, Log-Lik: -1601.969, Max-Change: 0.00010
> covs <- fscores(mod, return.acov=TRUE)
  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s  
> covs[[1]]
          [,1]      [,2]
[1,] 0.6768357 0.2448883
[2,] 0.2448883 0.6818730
> cov2cor(covs[[1]])
          [,1]      [,2]
[1,] 1.0000000 0.3604746
[2,] 0.3604746 1.0000000
StaffanBetner commented 2 years ago

And I thought I really really did look through the help page for fscores 🤦‍♂️. Thanks!