metagen  R Documentation 
Common effect and random effects metaanalysis based on estimates (e.g. log hazard ratios) and their standard errors. The inverse variance method is used for pooling.
Threelevel random effects metaanalysis (Van den Noortgate et al.,
2013) is available by internally calling
rma.mv
function from R package
metafor (Viechtbauer, 2010).
metagen( TE, seTE, studlab, data = NULL, subset = NULL, exclude = NULL, cluster = NULL, sm = "", method.ci = if (missing(df)) "z" else "t", level = gs("level"), common = gs("common"), random = gs("random")  !is.null(tau.preset), overall = common  random, overall.hetstat = common  random, prediction = gs("prediction")  !missing(method.predict), method.tau = gs("method.tau"), method.tau.ci = gs("method.tau.ci"), tau.preset = NULL, TE.tau = NULL, tau.common = gs("tau.common"), detail.tau = "", level.ma = gs("level.ma"), method.random.ci = gs("method.random.ci"), adhoc.hakn.ci = gs("adhoc.hakn.ci"), level.predict = gs("level.predict"), method.predict = gs("method.predict"), adhoc.hakn.pi = gs("adhoc.hakn.pi"), null.effect = 0, method.bias = gs("method.bias"), n.e = NULL, n.c = NULL, pval, df, lower, upper, level.ci = 0.95, median, q1, q3, min, max, method.mean = "Luo", method.sd = "Shi", approx.TE, approx.seTE, backtransf = gs("backtransf"), pscale = 1, irscale = 1, irunit = "personyears", text.common = gs("text.common"), text.random = gs("text.random"), text.predict = gs("text.predict"), text.w.common = gs("text.w.common"), text.w.random = gs("text.w.random"), title = gs("title"), complab = gs("complab"), outclab = "", label.e = gs("label.e"), label.c = gs("label.c"), label.left = gs("label.left"), label.right = gs("label.right"), subgroup, subgroup.name = NULL, print.subgroup.name = gs("print.subgroup.name"), sep.subgroup = gs("sep.subgroup"), test.subgroup = gs("test.subgroup"), prediction.subgroup = gs("prediction.subgroup"), byvar, id, adhoc.hakn, keepdata = gs("keepdata"), warn = gs("warn"), warn.deprecated = gs("warn.deprecated"), control = NULL, ... )
TE 
Estimate of treatment effect, e.g., log hazard ratio or risk difference. 
seTE 
Standard error of treatment estimate. 
studlab 
An optional vector with study labels. 
data 
An optional data frame containing the study information. 
subset 
An optional vector specifying a subset of studies to be used (see Details). 
exclude 
An optional vector specifying studies to exclude from metaanalysis, however, to include in printouts and forest plots (see Details). 
cluster 
An optional vector specifying which estimates come from the same cluster resulting in the use of a threelevel metaanalysis model. 
sm 
A character string indicating underlying summary measure,
e.g., 
method.ci 
A character string indicating which method is used to calculate confidence intervals for individual studies, see Details. 
level 
The level used to calculate confidence intervals for individual studies. 
common 
A logical indicating whether a common effect metaanalysis should be conducted. 
random 
A logical indicating whether a random effects metaanalysis should be conducted. 
overall 
A logical indicating whether overall summaries should be reported. This argument is useful in a metaanalysis with subgroups if overall results should not be reported. 
overall.hetstat 
A logical value indicating whether to print heterogeneity measures for overall treatment comparisons. This argument is useful in a metaanalysis with subgroups if heterogeneity statistics should only be printed on subgroup level. 
prediction 
A logical indicating whether a prediction interval should be printed. 
method.tau 
A character string indicating which method is
used to estimate the betweenstudy variance τ^2 and its
square root τ (see 
method.tau.ci 
A character string indicating which method is
used to estimate the confidence interval of τ^2 and
τ (see 
tau.preset 
Prespecified value for the square root of the betweenstudy variance τ^2. 
TE.tau 
Overall treatment effect used to estimate the betweenstudy variance tausquared. 
tau.common 
A logical indicating whether tausquared should be the same across subgroups. 
detail.tau 
Detail on betweenstudy variance estimate. 
level.ma 
The level used to calculate confidence intervals for metaanalysis estimates. 
method.random.ci 
A character string indicating which method
is used to calculate confidence interval and test statistic for
random effects estimate (see 
adhoc.hakn.ci 
A character string indicating whether an
ad hoc variance correction should be applied in the case
of an arbitrarily small HartungKnapp variance estimate (see

level.predict 
The level used to calculate prediction interval for a new study. 
method.predict 
A character string indicating which method is
used to calculate a prediction interval (see

adhoc.hakn.pi 
A character string indicating whether an
ad hoc variance correction should be applied for
prediction interval (see 
null.effect 
A numeric value specifying the effect under the null hypothesis. 
method.bias 
A character string indicating which test is to
be used. Either 
n.e 
Number of observations in experimental group (or total sample size in study). 
n.c 
Number of observations in control group. 
pval 
Pvalue (used to estimate the standard error). 
df 
Degrees of freedom (used in test or to construct confidence interval). 
lower 
Lower limit of confidence interval (used to estimate the standard error). 
upper 
Upper limit of confidence interval (used to estimate the standard error). 
level.ci 
Level of confidence interval. 
median 
Median (used to estimate the treatment effect and standard error). 
q1 
First quartile (used to estimate the treatment effect and standard error). 
q3 
Third quartile (used to estimate the treatment effect and standard error). 
min 
Minimum (used to estimate the treatment effect and standard error). 
max 
Maximum (used to estimate the treatment effect and standard error). 
method.mean 
A character string indicating which method to use to approximate the mean from the median and other statistics (see Details). 
method.sd 
A character string indicating which method to use to approximate the standard deviation from sample size, median, interquartile range and range (see Details). 
approx.TE 
Approximation method to estimate treatment estimate (see Details). 
approx.seTE 
Approximation method to estimate standard error (see Details). 
backtransf 
A logical indicating whether results should be
back transformed in printouts and plots. If 
pscale 
A numeric giving scaling factor for printing of
single event probabilities or risk differences, i.e. if argument

irscale 
A numeric defining a scaling factor for printing of
single incidence rates or incidence rate differences, i.e. if
argument 
irunit 
A character specifying the time unit used to calculate rates, e.g. personyears. 
text.common 
A character string used in printouts and forest plot to label the pooled common effect estimate. 
text.random 
A character string used in printouts and forest plot to label the pooled random effects estimate. 
text.predict 
A character string used in printouts and forest plot to label the prediction interval. 
text.w.common 
A character string used to label weights of common effect model. 
text.w.random 
A character string used to label weights of random effects model. 
title 
Title of metaanalysis / systematic review. 
complab 
Comparison label. 
outclab 
Outcome label. 
label.e 
Label for experimental group. 
label.c 
Label for control group. 
label.left 
Graph label on left side of forest plot. 
label.right 
Graph label on right side of forest plot. 
subgroup 
An optional vector to conduct a metaanalysis with subgroups. 
subgroup.name 
A character string with a name for the subgroup variable. 
print.subgroup.name 
A logical indicating whether the name of the subgroup variable should be printed in front of the group labels. 
sep.subgroup 
A character string defining the separator between name of subgroup variable and subgroup label. 
test.subgroup 
A logical value indicating whether to print results of test for subgroup differences. 
prediction.subgroup 
A logical indicating whether prediction intervals should be printed for subgroups. 
byvar 
Deprecated argument (replaced by 'subgroup'). 
id 
Deprecated argument (replaced by 'cluster'). 
adhoc.hakn 
Deprecated argument (replaced by 'adhoc.hakn.ci'). 
keepdata 
A logical indicating whether original data (set) should be kept in meta object. 
warn 
A logical indicating whether warnings should be printed (e.g., if studies are excluded from metaanalysis due to zero standard errors). 
warn.deprecated 
A logical indicating whether warnings should be printed if deprecated arguments are used. 
control 
An optional list to control the iterative process to
estimate the betweenstudy variance τ^2. This argument
is passed on to 
... 
Additional arguments (to catch deprecated arguments). 
This function provides the generic inverse variance method
for metaanalysis which requires treatment estimates and their
standard errors (Borenstein et al., 2010). The method is useful,
e.g., for pooling of survival data (using log hazard ratio and
standard errors as input). Arguments TE
and seTE
can
be used to provide treatment estimates and standard errors
directly. However, it is possible to derive these quantities from
other information.
A threelevel random effects metaanalysis model (Van den Noortgate
et al., 2013) is utilized if argument cluster
is used and at
least one cluster provides more than one estimate. Internally,
rma.mv
is called to conduct the analysis and
weights.rma.mv
with argument type =
"rowsum"
is used to calculate random effects weights.
Default settings are utilised for several arguments (assignments
using gs
function). These defaults can be changed for
the current R session using the settings.meta
function.
Furthermore, R function update.meta
can be used to
rerun a metaanalysis with different settings.
Missing treatment estimates can be derived from
confidence limits provided by arguments lower
and
upper
;
median, interquartile range and range (arguments
median
, q1
, q3
, min
, and max
);
median and interquartile range (arguments median
,
q1
and q3
);
median and range (arguments median
, min
and
max
).
For confidence limits, the treatment estimate is defined as the center of the confidence interval (on the log scale for relative effect measures like the odds ratio or hazard ratio).
If the treatment effect is a mean it can be approximated from
sample size, median, interquartile range and range. By default,
methods described in Luo et al. (2018) are utilized (argument
method.mean = "Luo"
):
equation (7) if sample size, median and range are available,
equation (11) if sample size, median and interquartile range are available,
equation (15) if sample size, median, range and interquartile range are available.
Instead the methods described in Wan et al. (2014) are used if
argument method.mean = "Wan"
:
equation (2) if sample size, median and range are available,
equation (14) if sample size, median and interquartile range are available,
equation (10) if sample size, median, range and interquartile range are available.
By default, missing treatment estimates are replaced successively
using these method, i.e., confidence limits are utilised before
interquartile ranges. Argument approx.TE
can be used to
overwrite this default for each individual study:
Use treatment estimate directly (entry ""
in argument
approx.TE
);
confidence limits ("ci"
in argument approx.TE
);
median, interquartile range and range ("iqr.range"
);
median and interquartile range ("iqr"
);
median and range ("range"
).
Missing standard errors can be derived from
pvalue provided by arguments pval
and (optional)
df
;
confidence limits (arguments lower
, upper
, and
(optional) df
);
sample size, median, interquartile range and range (arguments
n.e
and / or n.c
, median
, q1
,
q3
, min
, and max
);
sample size, median and interquartile range (arguments
n.e
and / or n.c
, median
, q1
and
q3
);
sample size, median and range (arguments n.e
and / or
n.c
, median
, min
and max
).
For pvalues and confidence limits, calculations are either based
on the standard normal or tdistribution if argument
df
is provided. Furthermore, argument level.ci
can be
used to provide the level of the confidence interval.
Wan et al. (2014) describe methods to estimate the standard
deviation (and thus the standard error by deviding the standard
deviation with the square root of the sample size) from the sample
size, median and additional statistics. Shi et al. (2020) provide
an improved estimate of the standard deviation if the interquartile
range and range are available in addition to the sample size and
median. Accordingly, equation (11) in Shi et al. (2020) is the
default (argument method.sd = "Shi"
), if the median,
interquartile range and range are provided (arguments
median
, q1
, q3
, min
and
max
). The method by Wan et al. (2014) is used if argument
method.sd = "Wan"
and, depending on the sample size, either
equation (12) or (13) is used. If only the interquartile range or
range is available, equations (15) / (16) and (7) / (9) in Wan et
al. (2014) are used, respectively. The sample size of individual
studies must be provided with arguments n.e
and / or
n.c
. The total sample size is calculated as n.e
+
n.c
if both arguments are provided.
By default, missing standard errors are replaced successively using
these method, e.g., pvalue before confidence limits before
interquartile range and range. Argument approx.seTE
can be
used to overwrite this default for each individual study:
Use standard error directly (entry ""
in argument
approx.seTE
);
pvalue ("pval"
in argument approx.seTE
);
confidence limits ("ci"
);
median, interquartile range and range ("iqr.range"
);
median and interquartile range ("iqr"
);
median and range ("range"
).
For the mean difference (argument sm = "MD"
), the confidence
interval for individual studies can be based on the
standard normal distribution (method.ci = "z"
), or
tdistribution (method.ci = "t"
).
By default, the first method is used if argument df
is
missing and the second method otherwise.
Note, this choice does not affect the results of the common effect and random effects metaanalysis.
Argument subgroup
can be used to conduct subgroup analysis for
a categorical covariate. The metareg
function can be
used instead for more than one categorical covariate or continuous
covariates.
Argument null.effect
can be used to specify the (treatment)
effect under the null hypothesis in a test for an overall
effect.
By default (null.effect = 0
), the null hypothesis
corresponds to "no difference" (which is obvious for absolute
effect measures like the mean difference (sm = "MD"
) or
standardised mean difference (sm = "SMD"
)). For relative
effect measures, e.g., risk ratio (sm = "RR"
) or odds ratio
(sm = "OR"
), the null effect is defined on the log scale,
i.e., ln(RR) = 0 or ln(OR) = 0 which is equivalent to
testing RR = 1 or OR = 1.
Use of argument null.effect
is especially useful for summary
measures without a "natural" null effect, i.e., in situations
without a second (treatment) group. For example, an overall
proportion of 50% could be tested in the metaanalysis of single
proportions with argument null.effect = 0.5
.
Note, all tests for an overall effect are twosided with the
alternative hypothesis that the effect is unequal to
null.effect
.
Arguments subset
and exclude
can be used to exclude
studies from the metaanalysis. Studies are removed completely from
the metaanalysis using argument subset
, while excluded
studies are shown in printouts and forest plots using argument
exclude
(see Examples).
Metaanalysis results are the same for both arguments.
Internally, both common effect and random effects models are
calculated regardless of values choosen for arguments common
and random
. Accordingly, the estimate for the random effects
model can be extracted from component TE.random
of an object
of class "meta"
even if argument random =
FALSE
. However, all functions in R package meta will
adequately consider the values for common
and
random
. For example, functions print.meta
and
forest.meta
will not show results for the random
effects model if random = FALSE
.
A prediction interval will only be shown if prediction =
TRUE
.
Argument pscale
can be used to rescale single proportions or
risk differences, e.g. pscale = 1000
means that proportions
are expressed as events per 1000 observations. This is useful in
situations with (very) low event probabilities.
Argument irscale
can be used to rescale single rates or rate
differences, e.g. irscale = 1000
means that rates are
expressed as events per 1000 time units, e.g. personyears. This is
useful in situations with (very) low rates. Argument irunit
can be used to specify the time unit used in individual studies
(default: "personyears"). This information is printed in summaries
and forest plots if argument irscale
is not equal to 1.
Default settings for common
, random
,
pscale
, irscale
, irunit
and several other
arguments can be set for the whole R session using
settings.meta
.
An object of class c("metagen", "meta")
with corresponding
generic functions (see metaobject
).
R function rma.uni
from R package
metafor (Viechtbauer 2010) is called internally to estimate
the betweenstudy variance τ^2.
Guido Schwarzer sc@imbi.unifreiburg.de
Borenstein M, Hedges LV, Higgins JP, Rothstein HR (2010): A basic introduction to fixedeffect and randomeffects models for metaanalysis. Research Synthesis Methods, 1, 97–111
Luo D, Wan X, Liu J, Tong T (2018): Optimally estimating the sample mean from the sample size, median, midrange, and/or midquartile range. Statistical Methods in Medical Research, 27, 1785–805
Shi J, Luo D, Weng H, Zeng XT, Lin L, Chu H, et al. (2020): Optimally estimating the sample standard deviation from the fivenumber summary. Research Synthesis Methods.
Viechtbauer W (2010): Conducting MetaAnalyses in R with the metafor Package. Journal of Statistical Software, 36, 1–48
Van den Noortgate W, LópezLópez JA, MarínMartínez F, SánchezMeca J (2013): Threelevel metaanalysis of dependent effect sizes. Behavior Research Methods, 45, 576–94
Wan X, Wang W, Liu J, Tong T (2014): Estimating the sample mean and standard deviation from the sample size, median, range and/or interquartile range. BMC Medical Research Methodology, 14, 135
metapackage
, update.meta
,
metabin
, metacont
,
print.meta
, settings.meta
data(Fleiss1993bin) m1 < metabin(d.asp, n.asp, d.plac, n.plac, study, data = Fleiss1993bin, sm = "RR", method = "I") m1 # Identical results using the generic inverse variance method with # log risk ratio and its standard error: # Note, argument 'n.e' in metagen() is used to provide the total # sample size which is calculated from the group sample sizes n.e # and n.c in metaanalysis m1. m1.gen < metagen(TE, seTE, studlab, n.e = n.e + n.c, data = m1, sm = "RR") m1.gen forest(m1.gen, leftcols = c("studlab", "n.e", "TE", "seTE")) # Metaanalysis with prespecified betweenstudy variance # metagen(m1$TE, m1$seTE, sm = "RR", tau.preset = sqrt(0.1)) # Metaanalysis of survival data: # logHR < log(c(0.95, 1.5)) selogHR < c(0.25, 0.35) metagen(logHR, selogHR, sm = "HR") # PauleMandel method to estimate betweenstudy variance for data # from Paule & Mandel (1982) # average < c(27.044, 26.022, 26.340, 26.787, 26.796) variance < c(0.003, 0.076, 0.464, 0.003, 0.014) # metagen(average, sqrt(variance), sm = "MD", method.tau = "PM") # Conduct metaanalysis using hazard ratios and 95% confidence intervals # # Data from Steurer et al. (2006), Analysis 1.1 Overall survival # https://www.cochranelibrary.com/cdsr/doi/10.1002/14651858.CD004270.pub2/abstract # study < c("FCG on CLL 1996", "Leporrier 2001", "Rai 2000", "Robak 2000") HR < c(0.55, 0.92, 0.79, 1.18) lower.HR < c(0.28, 0.79, 0.59, 0.64) upper.HR < c(1.09, 1.08, 1.05, 2.17) # # Input must be log hazard ratios, not hazard ratios # metagen(log(HR), lower = log(lower.HR), upper = log(upper.HR), studlab = study, sm = "HR") # Exclude MRC1 and MRC2 studies from metaanalysis, however, # show them in printouts and forest plots # metabin(d.asp, n.asp, d.plac, n.plac, study, data = Fleiss1993bin, sm = "RR", method = "I", exclude = study %in% c("MRC1", "MRC2")) # # Exclude MRC1 and MRC2 studies completely from metaanalysis # metabin(d.asp, n.asp, d.plac, n.plac, study, data = Fleiss1993bin, sm = "RR", method = "I", subset = !(study %in% c("MRC1", "MRC2"))) # Exclude studies with total sample size above 1500 # metabin(d.asp, n.asp, d.plac, n.plac, study, data = Fleiss1993bin, sm = "RR", method = "I", exclude = (n.asp + n.plac) > 1500) # Exclude studies containing "MRC" in study name # metabin(d.asp, n.asp, d.plac, n.plac, study, data = Fleiss1993bin, sm = "RR", method = "I", exclude = grep("MRC", study)) # Use both arguments 'subset' and 'exclude' # metabin(d.asp, n.asp, d.plac, n.plac, study, data = Fleiss1993bin, sm = "RR", method = "I", subset = (n.asp + n.plac) > 1500, exclude = grep("MRC", study)) ## Not run: # Threelevel model: effects of modified school calendars on # student achievement data(dat.konstantopoulos2011, package = "metadat") metagen(yi, sqrt(vi), studlab = study, data = dat.konstantopoulos2011, sm = "SMD", cluster = district, detail.tau = c("district", "district/school")) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.