[R-meta] forest plot function overall effect size rounded
Viechtbauer, Wolfgang (NP)
wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Wed Oct 18 23:09:42 CEST 2023
I have to say that this is a strange thing to do, but here is an example showing how this can be done:
library(metafor)
dat <- escalc(measure="OR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg,
slab=paste0(author, ", ", year))
res <- rma(yi, vi, data=dat)
res
forest(res)
res$beta <- as.numeric(sprintf("%1.2f", ((trunc(100 * coef(res)) / 100))))
forest(res)
Again, not something I would ever recommend doing.
Best,
Wolfgang
> -----Original Message-----
> From: R-sig-meta-analysis <r-sig-meta-analysis-bounces using r-project.org> On Behalf
> Of Gabriel Cotlier via R-sig-meta-analysis
> Sent: Wednesday, October 11, 2023 18:04
> To: Michael Dewey <lists using dewey.myzen.co.uk>
> Cc: Gabriel Cotlier <gabiklm01 using gmail.com>; R Special Interest Group for Meta-
> Analysis <r-sig-meta-analysis using r-project.org>
> Subject: Re: [R-meta] forest plot function overall effect size rounded
>
> Yes, indeed, sprintf("%1.2f", ((trunc(100 * 0.7080) / 100))) is a good
> solution.
> Do you know how to plug the value into the forest plot location where the
> overall effect size is (lower right-hand side corner)?
> Thanks a lot.
> Gabriel
>
> On Wed, Oct 11, 2023 at 6:46 PM Michael Dewey <lists using dewey.myzen.co.uk>
> wrote:
>
> > Do you mean something like
> >
> > sprintf("%1.2f", ((trunc(100 * 0.7080) / 100)))
> >
> > perhaps?
> >
> > Michael
> >
> > On 11/10/2023 16:31, Gabriel Cotlier wrote:
> > > Dear Michael,
> > >
> > > Thank you very much for clarifying it. You are indeed right; one thing
> > > is rounding and the other is simply retrieving a given number of digits
> > > or number precision, at least as far as I understand it.
> > > I just would like to appear in the forest plot exactly the same value
> > > that gives the model results or output for the overall effect size, but
> > > if the model's output is, for instance, 0.7080 and such a number is too
> > > large, well then only the first 2 digits after the point would be 0.70.
> > >
> > > Thanks a lot for your help.
> > > Kind regards,
> > > Gabriel
> > >
> > > On Wed, Oct 11, 2023 at 5:46 PM Michael Dewey <lists using dewey.myzen.co.uk
> > > <mailto:lists using dewey.myzen.co.uk>> wrote:
> > >
> > > Dear Gabriel
> > >
> > > Comments in-line
> > >
> > > On 11/10/2023 15:10, Gabriel Cotlier via R-sig-meta-analysis wrote:
> > > > Hello all,
> > > > I would like to ask how to modify in the forest plot the value of
> > the
> > > > overall effect size to be round (overall_effect_size, 1) since it
> > > > aurtomatically does round(overall_effect_size, 2) for instance in
> > > my case
> > > > the model's output overall effect size is :
> > > >
> > > > p0 <- predict(res)
> > > > p0
> > > > # pred se ci.lb <http://ci.lb> ci.ub pi.lb <http://pi.lb>
> > pi.ub
> > > > # 0.7080 0.2950 0.1297 1.2863 -2.9950 4.4110
> > > >
> > > > That is 0.7080 but in the forest lot is round(0.7080, 2) that is
> > > 0.71 as it
> > > > appears in the forest plot (lower right corner):
> > > >
> > > > 100% 0.71 [0.13, 1.29]
> > > >
> > > > Therefore I would like to access the variable in the forest plot
> > > and set it
> > > > to be round(0.7080, 1) so as to have the overall effect size as
> > > is in the
> > > > model output, that is 0.70 or alternatively 0.7080.
> > >
> > > But round(0.7080, 1) is 0.7, not 0.70. Rounded to 2 decimals it is
> > 0.71
> > > which you state you do not want. Perhaps it would help if you
> > explained
> > > what you mean by rounding as what you ask does not seem to
> > > correspond to
> > > what is usually meant by the term.
> > >
> > > Michael
> > >
> > > >
> > > > Thanks a lot.
> > > > Kid regards,
> > > > Gabriel
More information about the R-sig-meta-analysis
mailing list