-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve documentation around variable reordering or fix bug for user-specified weight matrix #260
Comments
Thanks for noticing this @mhunter1 @yrosseel FYI @mhunter1, another potential issue might arise if users fit a model to a reduced set of variables, in which case From a design standpoint, I think @yrosseel can only set consistent expectations for summary statistics ( In order to program an automatic reordering of weights, lavaan would still need to expect the dimensions/order of summary stats and their uncertainty to be synchronized, so that the appropriate reordering of |
When the WLS.V/NACOV arguments were added, the implicit assumption was that they were extracted from a fitted lavaan object, and that they would be used again for the same model using the same syntax(!), just avoiding recomputing NACOV again. But now that these arguments are exploited for other means, clearly something needs to happen. There are two possibilities: either we enforce the data-driven order for the variable names (but this would exclude using a subset of the variables, and it is very un-lavaan), or we select+rearrange the elements in the NACOV/WLS.V matrices. The latter is a nightmare, as the NACOV/WLS.V matrices usually have no column or rownames. I will give this some thought. |
I have made two changes in the github version:
It turned out that the only way to do this (in a reliable way) was to add additional rows to the parameter table (using a 'da' operator; this can be seen in the @partable slot) reflecting the order. As many internal functions in lavaan are based on the model only (eg lavNames), this was the only way. Other than reordering the observed variables, this ov.order= argument is not supposed to have any other side-effects. (But more testing is needed to verify this).
|
Sounds like a reasonable solution to me! |
thanks @yrosseel, that should work great |
When you write a
lavaan
model with a user-specified covariance matrix and a user-specific weight matrix,lavaan
rearranges the order of the variables in its covariance matrix based on the order of the variables in the syntax, but does not rearrange the order of the variables in the weight matrix.So, a user could write the same model on the same data, but get different and incorrect results because the models differed in the order of the variables in the syntax. Below is an example based on the
GenomicSEM
package.I propose that
lavaan
either (1) document this behavior is big, bold writing somewhere related to user-specified weight matrices, or (2) re-arrange the user-specified weight matrix in the same order as the rearranged covariance matrix.Here's the RData file wrapped in a Zip: all_DSM_v4.zip
The text was updated successfully, but these errors were encountered: