[R-meta] metafor::escalc question: Confidence intervals for differences in standardized mean change -

Dale Steele d@|e@w@@tee|e @end|ng |rom gm@||@com
Mon May 17 13:34:49 CEST 2021


Hi Wolfgang -

Thanks for your reply.  Unfortunately, when I attempt to create the
escalc object from the 'dat' dataframe, I get the error message below.

"> new_dat <- escalc(data=dat, yi=yi, vi=vi)
Error in escalc(data = dat, yi = yi, vi = vi) :
  Must specify an effect size or outcome measure via the 'measure' argument."

If I add measure = "GEN" the following error results:

"> new_dat <- escalc(measure = "GEN", data=dat, yi=yi, vi=vi)
Error in attributes(dat[[var.names[1]]])$ni[include & yi.replace] <-
ni.u[include &  :
  replacement has length zero"

Appears I'm still missing some nuance.

Best

--Dale

datT <- data.frame(
  m_pre   = c(30.6, 23.5, 0.5, 53.4, 35.6),
  m_post  = c(38.5, 26.8, 0.7, 75.9, 36.0),
  sd_pre  = c(15.0, 3.1, 0.1, 14.5, 4.7),
  sd_post = c(11.6, 4.1, 0.1, 4.4, 4.6),
  ni      = c(20, 50, 9, 10, 14),
  ri      = c(0.47, 0.64, 0.77, 0.89, 0.44))

datC <- data.frame(
  m_pre   = c(23.1, 24.9, 0.6, 55.7, 34.8),
  m_post  = c(19.7, 25.3, 0.6, 60.7, 33.4),
  sd_pre  = c(13.8, 4.1, 0.2, 17.3, 3.1),
  sd_post = c(14.8, 3.3, 0.2, 17.9, 6.9),
  ni      = c(20, 42, 9, 11, 14),
  ri      = c(0.47, 0.64, 0.77, 0.89, 0.44))

datT <- escalc(measure="SMCR", m1i=m_post, m2i=m_pre, sd1i=sd_pre,
               ni=ni, ri=ri, data=datT)
datC <- escalc(measure="SMCR", m1i=m_post, m2i=m_pre, sd1i=sd_pre,
               ni=ni, ri=ri, data=datC)

dat <- data.frame(yi = datT$yi - datC$yi, vi = datT$vi + datC$vi)
dat

new_dat <- escalc(data=dat, yi=yi, vi=vi)
summary(new_dat)

On Mon, May 17, 2021 at 6:19 AM Viechtbauer, Wolfgang (SP)
<wolfgang.viechtbauer using maastrichtuniversity.nl> wrote:
>
> Hi Dale,
>
> You almost got it. To convert a non-escalc object to an escalc one, you give it the data via the 'data' argument and you must specify the names of the variables for the outcomes and the corresponding sampling variances via arguments 'yi' and 'vi'. In this example, these variables have the same names as those arguments, so it would be:
>
> new_dat <- escalc(data=dat, yi=yi, vi=vi)
>
> And now
>
> summary(new_dat)
>
> works (append=TRUE is the default anyway and you can leave off measure="GEN", since this will be used as the default as well).
>
> Best,
> Wolfgang
>
> >-----Original Message-----
> >From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org] On
> >Behalf Of Dale Steele
> >Sent: Saturday, 15 May, 2021 13:21
> >To: r-sig-meta-analysis using r-project.org
> >Subject: Re: [R-meta] metafor::escalc question: Confidence intervals for
> >differences in standardized mean change -
> >
> >Correcting the last 3 lines of the previous message. The CIs
> >calculated as follows:
> >
> >dat[c("ci_lb", "ci_ub")] <- dat$yi + c(-1,1) * (qnorm(1 - 0.025) * sqrt(dat$vi))
> >
> >On Fri, May 14, 2021 at 2:47 PM Dale Steele <dale.w.steele using gmail.com> wrote:
> >>
> >> I'm following the example on the metafor website for Computing the
> >> Difference in the Standardized Mean Change
> >> <https://www.metafor-project.org/doku.php/analyses:morris2008>
> >>
> >> I'd like to calculate a confidence interval for each of the
> >> differences in the 'dat' dataframe, rather than calculating by hand as
> >> I have attempted below.  As illustrated below,  I tried to convert
> >> 'dat' back to an 'escalc' object with:
> >> new_dat <- escalc(measure = "GEN", dat, append = TRUE) with the hope
> >> that summary(new_dat) would generate the desired confidence intervals,
> >> but this failed with a "Error in as.vector(vi) : argument "vi" is
> >> missing, with no default" error.
> >>
> >> Is what I'm doing possible?.
> >>
> >> Thanks!
> >>
> >> Example below:
> >>
> >> datT <- data.frame(
> >>   m_pre   = c(30.6, 23.5, 0.5, 53.4, 35.6),
> >>   m_post  = c(38.5, 26.8, 0.7, 75.9, 36.0),
> >>   sd_pre  = c(15.0, 3.1, 0.1, 14.5, 4.7),
> >>   sd_post = c(11.6, 4.1, 0.1, 4.4, 4.6),
> >>   ni      = c(20, 50, 9, 10, 14),
> >>   ri      = c(0.47, 0.64, 0.77, 0.89, 0.44))
> >>
> >> datC <- data.frame(
> >>   m_pre   = c(23.1, 24.9, 0.6, 55.7, 34.8),
> >>   m_post  = c(19.7, 25.3, 0.6, 60.7, 33.4),
> >>   sd_pre  = c(13.8, 4.1, 0.2, 17.3, 3.1),
> >>   sd_post = c(14.8, 3.3, 0.2, 17.9, 6.9),
> >>   ni      = c(20, 42, 9, 11, 14),
> >>   ri      = c(0.47, 0.64, 0.77, 0.89, 0.44))
> >>
> >> datT <- escalc(measure="SMCR", m1i=m_post, m2i=m_pre, sd1i=sd_pre,
> >> ni=ni, ri=ri, data=datT)
> >> datC <- escalc(measure="SMCR", m1i=m_post, m2i=m_pre, sd1i=sd_pre,
> >> ni=ni, ri=ri, data=datC)
> >>
> >> summary(datT) #generates CI's for within-arm standardized differences
> >> summary(datC)
> >>
> >> dat <- data.frame(yi = datT$yi - datC$yi, vi = datT$vi + datC$vi)
> >> # dat is no longer an 'escalc' object
> >> # Next line fails with error
> >> new_dat <- escalc(measure = "GEN", dat, append = TRUE)
> >> dat$sei <- sqrt(dat$vi)
> >> dat$zi <- dat$yi/dat$sei
> >> dat$ci_lb <- dat$yi - dat$zi *dat$sei
> >> dat$ci_ub <- dat$yi + dat$zi *dat$sei



More information about the R-sig-meta-analysis mailing list