daniel1noble / orchaRd

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

Issue with orchard_plot #23

Closed AmberChatten closed 1 year ago

AmberChatten commented 1 year ago

I'm not sure why I am having issues with orchard plots. This is my code: REM1=rma.mv(yi=Fishers.Zr, V=Variance.ZR, random=list(~1|Effect.size.code,~1|Experiment.Code,~1|Paper.code,~1|GENUS.SPECIES), method="REML",data=TEMP) summary(REM1)

REM1plot <- orchard_plot(REM1, xlab = "Effect size (Zr)", transfm = "none") REM1plot

I am getting this error

REM1plot <- orchard_plot(REM1, xlab = "Effect size (Zr)", transfm = "none") Error in orchaRd::mod_results(object, mod = "1", group, data, N, by = by, : Please specify the 'group' argument by providing the name of the grouping variable. See ?mod_results Thanks

daniel1noble commented 1 year ago

Hi. You need to specify the group argument. Probably adding in group = "Paper.code" should fix this

itchyshin commented 1 year ago

@daniel1noble - this reminds me that for now, I think even for rma objects we have to specify group, which is a bit counterintuitive. Should we fix this?

daniel1noble commented 1 year ago

Agree. In this case it makes sense, but we should add a catch for this for other model types. We do have the option to have g = FALSE, but I suspect it will not override this message so that needs a catch. Will fix. Working on a few other small things in the vignette on dev branch

AmberChatten commented 1 year ago

Hi there, I appreciate your help, I just tried these and am still receiving these error messages:

REM1plot <- orchard_plot(REM1, xlab = "Effect size (Zr)", transfm = "none", group = Paper.code) Error in orchaRd::mod_results(object, mod = "1", group, data, N, by = by, :

Please specify the 'data' argument by providing the data used to fit the model. See ?mod_results

REM1plot <- orchard_plot(REM1, xlab = "Effect size (Zr)", transfm = "none", group = Paper.code, data = TEMP)

Error in (function(x, i, exact) if (is.matrix(i)) as.matrix(x)[[i]] else .subset2(x, : object 'Paper.code' not found

Thanks again

itchyshin commented 1 year ago

Try "Paper.code"

AmberChatten commented 1 year ago

Thank you, Still getting these messages

REM1plot <- orchard_plot(REM1, xlab = "Effect size (Zr)", transfm = "none", group = "Paper.code") Error in orchaRd::mod_results(object, mod = "1", group, data, N, by = by, : Please specify the 'data' argument by providing the data used to fit the model. See ?mod_results

Please specify the 'data' argument by providing the data used to fit the model. See ?mod_results

REM1plot <- orchard_plot(REM1, xlab = "Effect size (Zr)", transfm = "none", group = "Paper.code", data = TEMP) Error in data.frame(yi, vi, moderator, stdy, type) : arguments imply differing number of rows: 476, 1, 498

daniel1noble commented 1 year ago

Hi, yes, this is because you need to specify by default both the data, and group arguments. As the error says, you can use the ?mod_results to check out the help file about these arguments. The examples will also demonstrate how to apply the function. We've also got a fairly detailed vignette which should help, which you can find here: https://daniel1noble.github.io/orchaRd/

If you're still having troubles after that then let us know

daniel1noble commented 1 year ago

Sorry, I only seen the upper error and just noticed you have two. The second line of code with an error "differing number of rows: 476, 1, 498" indicates there is something wrong with your data. Do you have missing data? It's hard to diagnose, but I'd suggest fitting the model with complete case data and then running orchard_plot. That will likely solve the second error

daniel1noble commented 1 year ago

Just making a note here @AmberChatten that I just pushed the dev branch to the master. This involves changes that will impact you if you're following the vignette. This includes dropping the data argument from all functions, which may solve your problems above. The vignette details these changes, and has updated code.