Attachment | Size |
---|---|
MetaCFA_6_10_21.R | 31.54 KB |
My colleagues and I are running into an issue where we are comparing a model between two groups of correlations. The two groups are categorically different (e.g. gender). So, for example, we have a set of correlations for boys and another set for girls. When we compare our two models, using anova (e.g. anova (fit1, fit2)) then we get an NA for our p value.
base comparison ep minus2LL df AIC diffLL diffdf p Boys Girls 5 22.42174 -5 32.42174 -17.81253 0 NA
Is this due to how we have specified the A and S matrix?
I have also went ahead and attached our code that includes the data.
Hi, Jaret.
Could you provide a copy of the R code that works? The current code includes several unknown R functions.
The current R code is more than 1.2k lines. Could you provide the final data without including the data preparation? It will make the code much more readable.
Mike
Hi Mike,
Thanks for the reply. Is there a way to extract the pooled correlation matrix in metaSEM?
Jaret
Hi Jaret,
You may use
coef()
to extract the parameter estimates including the average correlation matrix.If you want to attach the data files in an R code, you may use the following code. Suppose your list of correlation matrices is
my.Cor
, then you may save it inmydata.R
.Mike
Thank you, I believe this should all work. I am going to load the combined file with the data embedded along with the data files and the trimmed analysis file.
MetaCFA_6_10_21_TRIMMED is the full file with the data included
mydata is the data set with both sets of correlations matrices
mydata_corA is the dataset with the correlation matrices for group 1
mydata_corB is the dataset with the correlation matrices for group 2
metaCFA_reduced is the file with only the analysis.
Thank you again for your help with this.
If I understand correctly, you are fitting the same model on two independent samples.
anova(fit1, fit2)
only works for nested models.Yes you are right,
That would be the problem we are facing then.
How would we effectively compare those models. We tried following your vignette.
Also, is this the purpose of freeing up those parameters in the SEM for the second model? So that the ANOVA function can be used to compare them in metaSEM?
So, defining a comparison S matrix and A matrix is done so that ANOVA will treat them as different models (complex and less complex).