Dear Lavaan Google Group
I just tried to extract the observed variance-covariance matrix from my data and my model using the following two commands:
Extract it from the data:
lavCor(data_imputed[,c("t4_belief_qualities_trait","t4_belief_useless_trait", "t4_belief_useful_trait", "t4_belief_positive_trait")], output = "cov")
t4_blf_q_ t4_blf_sl_ t4_blf_sf_ t4_blf_p_ t4_sc_
t4_belief_qualities_trait 1.000
t4_belief_useless_trait 0.359 1.000
t4_belief_useful_trait 0.687 0.513 1.000
t4_belief_positive_trait 0.585 0.562 0.664 1.000
t4_scim_location 1.028 3.468 1.923 1.240 127.007
Extract it from the model (I am using the default setting conditional.x = T):
sem_fit_med_se <- sem(sem_med_se, estimator = "WLSMV", data = data_imputed, mimic = 'Mplus')
inspect(sem_fit_med_se, "sampstat")$res.cov
t4_blf_q_ t4_blf_sl_ t4_blf_sf_ t4_blf_p_ t4_sc_
t4_belief_qualities_trait 1.000
t4_belief_useless_trait 0.346 1.000
t4_belief_useful_trait 0.679 0.505 1.000
t4_belief_positive_trait 0.590 0.569 0.677 1.000
t4_scim_location 0.282 1.915 0.791 1.024 71.956
To my understanding, these two outputs should look the same no matter if I am extracting the observed variance-covariance matrix directly from the data or from the fitted lavaan model. Does anybody know what is the problem here?
Thanks a lot for any help!
Best, Isabel
Dear Terence,
thank you very much for your response. I guess my problem is that I don’t fully understand what is going on in this process of partialing out the exogenous covariates. But according to your answer I understand that the two matrices I showed in my first post do not necessarily need to be the same if categorical exogenous covariates are involved.
In terms of reproducibility of the analysis in such a case: is it enough to report the observed matrix generated by the lavCor() function or should the residual polychoric correlation matrix $res.cov be given, or both?
Thanks again very much! Best, isabel
In terms of reproducibility of the analysis in such a case: is it enough to report the observed matrix generated by the lavCor() function or should the residual polychoric correlation matrix $res.cov be given, or both?
Dear Terence,
thanks again a lot for your response and the link to the Open Science Framework! I would like to ask two follow-up questions on this:
· In case I will not be able to put my data on a repository like you mentioned, how would I extract the weight matrix? And according to your answer: reporting all 3 matrices (observed, residual polychoric, and weight) would make an analysis reproducible?
· Regarding the setting conditional.x = T /partialing out the exogenous covariates: Does this setting mean that I assume the covariances among the exogenous covariates to be zero? (When I compare the model summary output between conditional.x = T and conditional.x = F, I see that the latter also shows me in addition the covariances among the exogenous covariates).
Best wishes, isabel
· In case I will not be able to put my data on a repository like you mentioned, how would I extract the weight matrix? And according to your answer: reporting all 3 matrices (observed, residual polychoric, and weight) would make an analysis reproducible?
· Regarding the setting conditional.x = T /partialing out the exogenous covariates: Does this setting mean that I assume the covariances among the exogenous covariates to be zero? (When I compare the model summary output between conditional.x = T and conditional.x = F, I see that the latter also shows me in addition the covariances among the exogenous covariates).