class-specific factor scores

8 views
Skip to first unread message

Irina Uglanova

unread,
Oct 24, 2025, 11:32:38 AMOct 24
to mirt-package
Dear Phil,

Thank you very much for the package and your support. My question is: as the factor scores are weighted by the probability of latent class membership, does mirt provide factor scores for each individual only for the class with the highest estimated class‐membership probability (under  Class_1 label)?  

I used a piece of the script from the example:
library(mirt)
set.seed(12345)
nitems <- 20
a1 <- matrix(.75, ncol=1, nrow=nitems)
a2 <- matrix(1.25, ncol=1, nrow=nitems)
d1 <- matrix(rnorm(nitems,0,1),ncol=1)
d2 <- matrix(rnorm(nitems,0,1),ncol=1)
itemtype <- rep('2PL', nrow(a1))
N1 <- 500
N2 <- N1*2 # second class twice as large

dataset1 <- simdata(a1, d1, N1, itemtype)
dataset2 <- simdata(a2, d2, N2, itemtype)
dat <- rbind(dataset1, dataset2)
# group <- c(rep('D1', N1), rep('D2', N2))

# Mixture Rasch model (Rost, 1990)
models <- 'F1 = 1-20
           CONSTRAIN = (1-20, a1)'
mod_mix <- multipleGroup(dat, models, dentype = 'mixture-2', GenRandomPars = TRUE)
head(fscores(mod_mix)) # theta estimates
Class_1 [1,] -0.3609178 [2,] -1.6950807 [3,] -0.8217168 [4,] 0.8090483 [5,] 0.7936363 [6,] 0.2286020

Thank you in advance for your clarification.

Best regards,
Irina

Phil Chalmers

unread,
Oct 24, 2025, 2:31:56 PMOct 24
to Irina Uglanova, mirt-package
Hi Irina,

The factor scores estimates are not based on the highest latent class probability, but rather the weighted average across the posterior probabilities computed within the Bayesian estimation engine. Only if the posterior classification probability were equal to 1 would the EAP scores correspond to the discrete classification metric. Of course, you could do this yourself, if you were so inclined. Continuing the example above:

> # posterior probability for classification:
> pp <- fscores(mod_mix, method = 'classify')
  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s  
> head(pp)
        CLASS_1   CLASS_2
[1,] 0.04826707 0.9517329
[2,] 0.74223456 0.2577654
[3,] 0.02496631 0.9750337
[4,] 0.02929597 0.9707040
[5,] 0.07220958 0.9277904
[6,] 0.42428417 0.5757158
> classify <- apply(pp > .5, 1, \(x) which(x))
> head(classify)
[1] 2 1 2 2 2 2
>
> # extract single-group mixtures
> mix1 <- extract.group(mod_mix, group='MIXTURE_1')
> mix2 <- extract.group(mod_mix, group='MIXTURE_2')
>
> EAP1 <- fscores(mix1)
> EAP2 <- fscores(mix2)
>
> EAPs <- EAP1
> EAPs[ classify == 2, ] <- EAP2[classify == 2, ]
>
> head(cbind(EAP1, EAP2, classify))
                      F1               F1 classify
[1,] -0.46829891 -0.3554720        2
[2,] -1.65671411 -1.8055570        1
[3,] -0.83309483 -0.8214255        2
[4,]  0.46043047  0.8195696        2
[5,]  0.46043047  0.8195696        2
[6,]  0.07558437  0.3413711        2
> head(EAPs)
             F1
[1,] -0.3554720
[2,] -1.6567141
[3,] -0.8214255
[4,]  0.8195696
[5,]  0.8195696
[6,]  0.3413711

HTH.

Phil


--
You received this message because you are subscribed to the Google Groups "mirt-package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mirt-package...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mirt-package/509eac6d-9a32-45a7-bc0c-41f74847f1aen%40googlegroups.com.

Irina Uglanova

unread,
Oct 25, 2025, 9:11:03 AMOct 25
to mirt-package
Dear Phil,

Thank you very much for the clarification!

Best regards,
Irina

пятница, 24 октября 2025 г. в 20:31:56 UTC+2, Phil Chalmers:
Reply all
Reply to author
Forward
0 new messages