NA p value when running anova for moderator

Posted on
No user picture. jaret_hodges Joined: 06/10/2021
Forums

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.

Replied on Wed, 06/30/2021 - 02:28
Picture of user. Mike Cheung Joined: 10/08/2009

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

Replied on Thu, 07/01/2021 - 23:39
Picture of user. Mike Cheung Joined: 10/08/2009

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 in `mydata.R`.


dump(c("my.Cor"), file="mydata.R")

Mike

Replied on Fri, 07/02/2021 - 11:50
No user picture. jaret_hodges Joined: 06/10/2021

In reply to by Mike Cheung

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.

Replied on Sat, 07/03/2021 - 01:29
Picture of user. Mike Cheung Joined: 10/08/2009

If I understand correctly, you are fitting the same model on two independent samples. `anova(fit1, fit2)` only works for nested models.

Replied on Tue, 07/06/2021 - 12:14
No user picture. jaret_hodges Joined: 06/10/2021

In reply to by Mike Cheung

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).