daniel1noble / orchaRd

Extending the Orchard Plot for Meta-analysis
https://daniel1noble.github.io/orchaRd/
11 stars 6 forks source link

error in i2_ml() with random slopes #36

Closed zacrobinson5 closed 1 year ago

zacrobinson5 commented 1 year ago

For some reason I haven't been able to get i2_ml() to work with a rma.mv model fit with random slopes even with the struct="GEN" argument included (I am referencing the code of a paper that included this argument to presumably get around this error). The error I receive is:

"Sorry. At the moment i2_ml cannot take models with heterogeneous variance."

When the model is refit with only random intercepts, it works fine. Any help here is appreciated!

Code: model<-rma.mv(yi, vi, mods = ~ xi, random = list(~ xi | study, ~1 | group, ~1 | es), data = df, method = "REML", test = "t",struct = "GEN")

i2_ml(model)

daniel1noble commented 1 year ago

Currently, I2_ml does not work with these kind of models because it's quite difficult dealing with the varied structure specific to particular models users run under the hood. Sorry. Best to drop the slope and us I2 from that.

itchyshin commented 1 year ago

@daniel1noble - I think this same issue comes up in R2 too (there is a solution for this) - I will look at how rptR deals with this, which gets you R2 with random slope models

daniel1noble commented 1 year ago

It’s definitely doable, but it’s probably just not something that will be a quick fix. I’d be keen to see what rptR does. The model structures are very different, so we’ll need to see if we can easily apply to rma objects, but I’m sure we can work something out down the road.

On 14 Jul 2023, at 9:28 am, Shinichi Nakagawa @.***> wrote:

@daniel1noble https://github.com/daniel1noble - I think this same issue comes up in R2 too (there is a solution for this) - I will look at how rptR deals with this, which gets you R2 with random slope models

— Reply to this email directly, view it on GitHub https://github.com/daniel1noble/orchaRd/issues/36#issuecomment-1635052101, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2X2SU4XX4ROO2XGBPLN4DXQCABHANCNFSM6AAAAAA2FIOFHY. You are receiving this because you were mentioned.

itchyshin commented 1 year ago

@daniel1noble - we can look at it the next time we meet. There is an analytical solution which we may be able to use but let's see

zacrobinson5 commented 1 year ago

@daniel1noble @itchyshin Thanks again for the replies here gentleman! In the meantime, I wanted to see if you have any recommended citations/references to help me do the calculations for I2 and R2 for a multilevel meta-regression with random slopes at one of the levels

I appreciate it!

daniel1noble commented 1 year ago

Not the same situation but similar, we have implemented random slope models where we estimate changes in variance across age in this paper: https://ecoevorxiv.org/repository/view/4686/

You can consult refs therein. It's mainly about calculating variance components across the random slope. Then, you can calculate I2 at those new levels. Shinichi should have a few refs for R2 with random slopes.

zacrobinson5 commented 1 year ago

@daniel1noble thank you!