wviechtb / metafor

A meta-analysis package for R
https://www.metafor-project.org
230 stars 52 forks source link

Option to show second summary estimate on forest plot #80

Closed JanionNevill closed 8 months ago

JanionNevill commented 8 months ago

This was requested by a collaborator on a recent project, and I am keen to keep using the CRAN package, rather than relying on a fork which is not likely to be maintained.

The change is to allow for a second summary estimate to be plotted below the main summary estimate in the function forest.rma(). This allows for fixed and random effects to be shown on the same plot. I hope that this is something which fits with the ethos of this package.

I updated the documentation for the function, but I may not have done a complete job because I have not worked on an R package before this.

I also noticed a small bug where the limits were not being applied to the summary estimate diamonds properly, so I have fixed that by limiting the beta variable rather than the pred variable.

I'm happy to make any changes which would make this change compatible with {metafor}.

wviechtb commented 8 months ago

This is what the addpoly() function is for. See an example here:

https://wviechtb.github.io/metafor/reference/addpoly.rma.html#examples

This is more flexible, as one can add any number of polygons.

Will check into the issue with olim.

JanionNevill commented 8 months ago

That's much cleaner and more flexible, thanks. Am I right in thinking that I need to use ylim to make the plot area fit the additional polygon?

wviechtb commented 8 months ago

Yes, that is correct, so there is an additional 'manual' step. But I would say that is a small inconvenience for the extra flexibility. This actually just made me think that it would be nice if one could also only specify a single value for ylim which is then used for the lower bound, while the upper bound is still set automatically (since that one depends on k, so one has to do a bit of thinking to choose an appropriate value). I just added this. So then one only has to do ylim=-1.5-<number of additional polygons to be added>. And now olim is applied correctly - thanks for catching that.

JanionNevill commented 8 months ago

That's great, thanks. Do you have a schedule for when the changes will make it to CRAN?

wviechtb commented 8 months ago

Don't know. But you can always install the 'devel' version.