kim0sun / glca

An R Package for Multiple-Group Latent Class Analysis
https://kim0sun.github.io/glca/
GNU General Public License v3.0
10 stars 2 forks source link

How to get the variance covariance from a glca model? #17

Open Crismoc opened 2 months ago

Crismoc commented 2 months ago

Hi, I would like to get the variance-covariance matrix of a model fitted with glca, similar to what can be done with poLCA in the example below:

library(poLCA)
library(glca)

data(election)

## Fit LCA model with covariates using 3 classes
f.3cov <- cbind(MORALG,CARESG,KNOWG,LEADG,DISHONG,INTELG,
                MORALB,CARESB,KNOWB,LEADB,DISHONB,INTELB)~PARTY*AGE
nes.3cov <- poLCA(f.3cov, election, nclass=3)       

nes.3cov$coeff.V
#>              [,1]          [,2]          [,3]          [,4]         [,5]
#> [1,]  0.883065220 -0.2087377581 -1.653615e-02  3.884561e-03  0.647769635
#> [2,] -0.208737758  0.0620348622  3.850071e-03 -1.149500e-03 -0.129332087
#> [3,] -0.016536151  0.0038500706  3.536768e-04 -8.102530e-05 -0.012351966
#> [4,]  0.003884561 -0.0011494999 -8.102530e-05  2.383865e-05  0.002440923
#> [5,]  0.647769635 -0.1293320866 -1.235197e-02  2.440923e-03  0.729714225
#> [6,] -0.123041204  0.0265498798  2.329002e-03 -4.978581e-04 -0.141696331
#> [7,] -0.012304507  0.0024143741  2.710321e-04 -5.223952e-05 -0.014089306
#> [8,]  0.002326716 -0.0004950197 -5.065983e-05  1.056235e-05  0.002725117
#>               [,6]          [,7]          [,8]
#> [1,] -0.1230412038 -1.230451e-02  2.326716e-03
#> [2,]  0.0265498798  2.414374e-03 -4.950197e-04
#> [3,]  0.0023290023  2.710321e-04 -5.065983e-05
#> [4,] -0.0004978581 -5.223952e-05  1.056235e-05
#> [5,] -0.1416963310 -1.408931e-02  2.725117e-03
#> [6,]  0.0310254823  2.723271e-03 -5.968972e-04
#> [7,]  0.0027232712  3.139628e-04 -6.028458e-05
#> [8,] -0.0005968972 -6.028458e-05  1.316070e-05

## Fit LCA using glca
f.3cov.b <- item(MORALG,CARESG,KNOWG,LEADG,DISHONG,INTELG,
                MORALB,CARESB,KNOWB,LEADB,DISHONB,INTELB)~PARTY*AGE
nes.3cov.b <- glca(f.3cov.b, data = election, nclass = 3)

Is there a way to get the equivalent of nes.3cov$coeff.V from the object nes.3cov.b? Thank you very much!