factor scores calculation

137 views
Skip to first unread message

Francesca Graziano

unread,
Sep 18, 2020, 9:55:44 AM9/18/20
to lavaan
Hello,
I have a dataset with missing values and both binary and continous variable. I suppose there is one latent varaible underlying these. How can I calculate manually score using residual covariance matrix, factor  loading matrix... I'm interested on estimate the contribution of each variable in the model not only the score of the latent one.  

fit1<-sem(Mfa1, data=SEMdata, se="robust",ordered=ordered,missing="pairwise",estimator = "WLSMV" )  
lavPredict(fit1) #estimated values for the latent variaible

Thanks a lot 
Francesca 

Yves Rosseel

unread,
Sep 23, 2020, 2:51:06 AM9/23/20
to lav...@googlegroups.com
On 9/18/20 3:55 PM, Francesca Graziano wrote:
> I have a dataset with missing values and both binary and continous
> variable. I suppose there is one latent varaible underlying these. How
> can I calculate manually score using residual covariance matrix, factor
> loading matrix...

If your fitted object is called 'fit', then lavInspect(fit, "est") will
show all the (estimated) model matrices.

But it will not be trivial to compute the factor scores 'manually',
given that you have binary data. lavaan uses 'EBM' (Empirical Bayes
Modal) by default in this setting, and for each observation, the 'mode'
is found using numerical optimization. (ML is also available.)

The relevant code can be seen in the file 'lav_predict.R:

https://github.com/yrosseel/lavaan/blob/master/R/lav_predict.R

in the function 'lav_predict_eta_ebm_ml()' (starting from line 1018). A
local function is defined (f.eta.i, producing the loglikelihood of the
items, for given values of the factors), and nlminb() is used to find
the 'scores' (=values for the factors) that maximize this loglikelihood
(ML), or the posterior (EBM).

Yves.

Francesca Graziano

unread,
Sep 25, 2020, 9:20:44 AM9/25/20
to lavaan
Thanks for you answer! 
Maybe (in some situation...) could be usefull to have this information :)

Francesca 
Reply all
Reply to author
Forward
0 new messages