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.