Description Usage Arguments Details Value Note Author(s) References See Also Examples
Calculation of an overall mean from studies reporting a single mean using the inverse variance method for pooling; inverse variance weighting is used for pooling.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53  metamean(
n,
mean,
sd,
studlab,
data = NULL,
subset = NULL,
exclude = NULL,
median,
q1,
q3,
min,
max,
method.mean = "Luo",
method.sd = "Shi",
approx.mean,
approx.sd,
sm = gs("smmean"),
method.ci = gs("method.ci.cont"),
level = gs("level"),
level.comb = gs("level.comb"),
comb.fixed = gs("comb.fixed"),
comb.random = gs("comb.random"),
overall = comb.fixed  comb.random,
overall.hetstat = comb.fixed  comb.random,
hakn = gs("hakn"),
adhoc.hakn = gs("adhoc.hakn"),
method.tau = gs("method.tau"),
method.tau.ci = gs("method.tau.ci"),
tau.preset = NULL,
TE.tau = NULL,
tau.common = gs("tau.common"),
prediction = gs("prediction"),
level.predict = gs("level.predict"),
null.effect = NA,
method.bias = gs("method.bias"),
backtransf = gs("backtransf"),
text.fixed = gs("text.fixed"),
text.random = gs("text.random"),
text.predict = gs("text.predict"),
text.w.fixed = gs("text.w.fixed"),
text.w.random = gs("text.w.random"),
title = gs("title"),
complab = gs("complab"),
outclab = "",
byvar,
bylab,
print.byvar = gs("print.byvar"),
byseparator = gs("byseparator"),
keepdata = gs("keepdata"),
warn = gs("warn"),
control = NULL
)

n 
Number of observations. 
mean 
Estimated mean. 
sd 
Standard deviation. 
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. 
exclude 
An optional vector specifying studies to exclude from metaanalysis, however, to include in printouts and forest plots. 
median 
Median (used to estimate the mean and standard deviation). 
q1 
First quartile (used to estimate the mean and standard deviation). 
q3 
Third quartile (used to estimate the mean and standard deviation). 
min 
Minimum (used to estimate the mean and standard deviation). 
max 
Maximum (used to estimate the mean and standard deviation). 
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.mean 
Approximation method to estimate means (see Details). 
approx.sd 
Approximation method to estimate standard deviations (see Details). 
sm 
A character string indicating which summary measure
( 
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. 
level.comb 
The level used to calculate confidence intervals for pooled estimates. 
comb.fixed 
A logical indicating whether a fixed effect metaanalysis should be conducted. 
comb.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. 
hakn 
A logical indicating whether the method by Hartung and Knapp should be used to adjust test statistics and confidence intervals. 
adhoc.hakn 
A character string indicating whether an ad hoc variance correction should be applied in the case of an arbitrarily small HartungKnapp variance estimate, see Details. 
method.tau 
A character string indicating which method is
used to estimate the betweenstudy variance τ^2 and its
square root τ. Either 
method.tau.ci 
A character string indicating which method is
used to estimate the confidence interval of τ^2 and
τ. Either 
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. 
prediction 
A logical indicating whether a prediction interval should be printed. 
level.predict 
The level used to calculate prediction interval for a new study. 
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 
backtransf 
A logical indicating whether results should be
back transformed in printouts and plots for 
text.fixed 
A character string used in printouts and forest plot to label the pooled fixed 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.fixed 
A character string used to label weights of fixed 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. 
byvar 
An optional vector containing grouping information
(must be of same length as 
bylab 
A character string with a label for the grouping variable. 
print.byvar 
A logical indicating whether the name of the grouping variable should be printed in front of the group labels. 
byseparator 
A character string defining the separator between label and levels of grouping variable. 
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 deviations). 
control 
An optional list to control the iterative process to
estimate the betweenstudy variance τ^2. This argument
is passed on to 
Fixed effect and random effects metaanalysis of single means to calculate an overall mean; inverse variance weighting is used for pooling. The following transformations of means are implemented to calculate an overall mean:
Raw, i.e. untransformed, means (sm = "MRAW"
, default)
Log transformed means (sm = "MLN"
)
Note, you should use R function metacont
to compare
means of pairwise comparisons instead of using metamean
for
each treatment arm separately which will break randomisation in
randomised controlled trials.
Calculations are conducted on the log scale if sm =
"ROM"
. Accordingly, list elements TE
, TE.fixed
, and
TE.random
contain the logarithm of means. In printouts and
plots these values are back transformed if argument
backtransf = TRUE
.
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 means can be derived from
sample size, median, interquartile range and range (arguments
n
, median
, q1
, q3
, min
, and
max
),
sample size, median and interquartile range (arguments
n
, median
, q1
, and q3
), or
sample size, median and range (arguments n
,
median
, min
, and max
).
By default, methods described in Luo et al. (2018) are utilized
(argument method.mean = "Luo"
):
equation (15) if sample size, median, interquartile range and range are available,
equation (11) if sample size, median and interquartile range are available,
equation (7) if sample size, median and range are available.
Instead the methods described in Wan et al. (2014) are used if
argument method.mean = "Wan"
):
equation (10) if sample size, median, interquartile range and range are available,
equation (14) if sample size, median and interquartile range are available,
equation (2) if sample size, median and range are available.
By default, missing means are replaced successively using
interquartile ranges and ranges (if available), interquartile
ranges (if available) and finally ranges. Argument
approx.mean
can be used to overwrite this behaviour for each
individual study and treatment arm:
use means directly (entry ""
in argument
approx.mean
);
median, interquartile range and range ("iqr.range"
);
median and interquartile range ("iqr"
);
median and range ("range"
).
Missing standard deviations can be derived from
sample size, median, interquartile range and range (arguments
n
, median
, q1
, q3
, min
, and
max
),
sample size, median and interquartile range (arguments
n
, median
, q1
and q3
), or
sample size, median and range (arguments n
,
median
, min
and max
).
Wan et al. (2014) describe methods to estimate the standard
deviation 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. 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.
By default, missing standard deviations are replaced successively
using these method, i.e., interquartile ranges and ranges are used
before interquartile ranges before ranges. Argument
approx.sd
can be used to overwrite this default for each
individual study and treatment arms:
sample size, median, interquartile range and range
("iqr.range"
);
sample size, median and interquartile range ("iqr"
);
sample size, median and range ("range"
).
For untransformed means (argument sm = "MRAW"
), the
confidence interval for individual studies can be based on the
standard normal distribution (method.ci = "z"
, default), or
tdistribution (method.ci = "t"
).
The following methods to estimate the betweenstudy variance τ^2 are available:
DerSimonianLaird estimator (method.tau = "DL"
)
PauleMandel estimator (method.tau = "PM"
)
Restricted maximumlikelihood estimator (method.tau =
"REML"
)
Maximumlikelihood estimator (method.tau = "ML"
)
HunterSchmidt estimator (method.tau = "HS"
)
SidikJonkman estimator (method.tau = "SJ"
)
Hedges estimator (method.tau = "HE"
)
Empirical Bayes estimator (method.tau = "EB"
)
See metagen
for more information on these
estimators.
The following methods to calculate a confidence interval for τ^2 and τ are available.
Argument  Method 
method.tau.ci = "J"  Method by Jackson 
method.tau.ci = "BJ"  Method by Biggerstaff and Jackson 
method.tau.ci = "QP"  QProfile method 
See metagen
for more information on these methods. No
confidence intervals for τ^2 and τ are calculated
if method.tau.ci = ""
.
Hartung and Knapp (2001) proposed an alternative method for random effects metaanalysis based on a refined variance estimator for the treatment estimate. Simulation studies (Hartung and Knapp, 2001; IntHout et al., 2014; Langan et al., 2019) show improved coverage probabilities compared to the classic random effects method.
In rare settings with very homogeneous treatment estimates, the HartungKnapp variance estimate can be arbitrarily small resulting in a very narrow confidence interval (Knapp and Hartung, 2003; Wiksten et al., 2016). In such cases, an ad hoc variance correction has been proposed by utilising the variance estimate from the classic random effects model with the HK method (Knapp and Hartung, 2003; IQWiQ, 2020). An alternative approach is to use the wider confidence interval of classic fixed or random effects metaanalysis and the HK method (Wiksten et al., 2016; Jackson et al., 2017).
Argument adhoc.hakn
can be used to choose the ad hoc
method:
Argument  Ad hoc method 
adhoc.hakn = ""  not used 
adhoc.hakn = "se"  use variance correction if HK standard error is smaller 
than standard error from classic random effects  
metaanalysis (Knapp and Hartung, 2003)  
adhoc.hakn = "iqwig6"  use variance correction if HK confidence interval 
is narrower than CI from classic random effects model  
with DerSimonianLaird estimator (IQWiG, 2020)  
adhoc.hakn = "ci"  use wider confidence interval of classic random effects 
and HK metaanalysis  
(Hybrid method 2 in Jackson et al., 2017) 
A prediction interval for the proportion in a new study (Higgins et
al., 2009) is calculated if arguments prediction
and
comb.random
are TRUE
. Note, the definition of
prediction intervals varies in the literature. This function
implements equation (12) of Higgins et al., (2009) which proposed a
t distribution with K2 degrees of freedom where
K corresponds to the number of studies in the metaanalysis.
Argument byvar
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.
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 in metagen
).
Metaanalysis results are the same for both arguments.
Internally, both fixed effect and random effects models are
calculated regardless of values choosen for arguments
comb.fixed
and comb.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 comb.random = FALSE
. However, all functions in R
package meta will adequately consider the values for
comb.fixed
and comb.random
. E.g. functions
print.meta
and forest.meta
will not
print results for the random effects model if comb.random =
FALSE
.
An object of class c("metamean", "meta")
with corresponding
print
, summary
, and forest
functions. The
object is a list containing the following components:
n, mean, sd, 
As defined above. 
studlab, exclude, sm, method.ci, 
As defined above. 
median, q1, q3, min, max, 
As defined above. 
method.mean, method.sd, 
As defined above. 
approx.mean, approx.sd, 
As defined above. 
level, level.comb, 
As defined above. 
comb.fixed, comb.random, 
As defined above. 
overall, overall.hetstat, 
As defined above. 
hakn, adhoc.hakn, method.tau, method.tau.ci, 
As defined above. 
tau.preset, TE.tau, method.bias, 
As defined above. 
tau.common, title, complab, outclab, 
As defined above. 
byvar, bylab, print.byvar, byseparator, warn 
As defined above. 
TE, seTE 
Estimated effect (mean or log mean) and standard error of individual studies. 
lower, upper 
Lower and upper confidence interval limits for individual studies. 
statistic, pval 
Statistic and pvalue for test of treatment effect for individual studies. 
w.fixed, w.random 
Weight of individual studies (in fixed and random effects model). 
TE.fixed, seTE.fixed 
Estimated overall effect (mean or log mean) and standard error (fixed effect model). 
lower.fixed, upper.fixed 
Lower and upper confidence interval limits (fixed effect model). 
statistic.fixed, pval.fixed 
Statistic and pvalue for test of overall treatment effect (fixed effect model). 
TE.random, seTE.random 
Estimated overall effect (mean or log mean) and standard error (random effects model). 
lower.random, upper.random 
Lower and upper confidence interval limits (random effects model). 
statistic.random, pval.random 
Statistic and pvalue for test of overall treatment effect (random effects model). 
prediction, level.predict 
As defined above. 
seTE.predict 
Standard error utilised for prediction interval. 
lower.predict, upper.predict 
Lower and upper limits of prediction interval. 
k 
Number of studies combined in metaanalysis. 
Q 
Heterogeneity statistic. 
tau2 
Betweenstudy variance τ^2. 
se.tau2 
Standard error of τ^2. 
lower.tau2, upper.tau2 
Lower and upper limit of confidence interval for τ^2. 
tau 
Squareroot of betweenstudy variance τ. 
lower.tau, upper.tau 
Lower and upper limit of confidence interval for τ. 
H 
Heterogeneity statistic H. 
lower.H, upper.H 
Lower and upper confidence limit for heterogeneity statistic H. 
I2 
Heterogeneity statistic I^2. 
lower.I2, upper.I2 
Lower and upper confidence limit for heterogeneity statistic I^2. 
Rb 
Heterogeneity statistic R_b. 
lower.Rb, upper.Rb 
Lower and upper confidence limit for heterogeneity statistic R_b. 
method 
Pooling method: 
df.hakn 
Degrees of freedom for test of treatment effect for
HartungKnapp method (only if 
bylevs 
Levels of grouping variable  if 
TE.fixed.w, seTE.fixed.w 
Estimated effect and standard error
in subgroups (fixed effect model)  if 
lower.fixed.w, upper.fixed.w 
Lower and upper confidence
interval limits in subgroups (fixed effect model)  if

statistic.fixed.w, pval.fixed.w 
Statistics and pvalues for
test of treatment effect in subgroups (fixed effect model)  if

TE.random.w, seTE.random.w 
Estimated effect and standard
error in subgroups (random effects model)  if 
lower.random.w, upper.random.w 
Lower and upper confidence
interval limits in subgroups (random effects model)  if

statistic.random.w, pval.random.w 
Statistics and pvalues
for test of treatment effect in subgroups (random effects model)
 if 
w.fixed.w, w.random.w 
Weight of subgroups (in fixed and
random effects model)  if 
df.hakn.w 
Degrees of freedom for test of effect for
HartungKnapp method in subgroups  if 
n.e.w 
Number of observations in experimental group in
subgroups  if 
n.c.w 
Number of observations in control group in subgroups 
if 
k.w 
Number of studies combined within subgroups  if

k.all.w 
Number of all studies in subgroups  if 
Q.w.fixed 
Overall within subgroups heterogeneity statistic Q
(based on fixed effect model)  if 
Q.w.random 
Overall within subgroups heterogeneity statistic
Q (based on random effects model)  if 
df.Q.w 
Degrees of freedom for test of overall within
subgroups heterogeneity  if 
pval.Q.w.fixed 
Pvalue of within subgroups heterogeneity
statistic Q (based on fixed effect model)  if 
pval.Q.w.random 
Pvalue of within subgroups heterogeneity
statistic Q (based on random effects model)  if 
Q.b.fixed 
Overall between subgroups heterogeneity statistic
Q (based on fixed effect model)  if 
Q.b.random 
Overall between subgroups heterogeneity statistic
Q (based on random effects model)  if 
df.Q.b 
Degrees of freedom for test of overall between
subgroups heterogeneity  if 
pval.Q.b.fixed 
Pvalue of between subgroups heterogeneity
statistic Q (based on fixed effect model)  if 
pval.Q.b.random 
Pvalue of between subgroups heterogeneity
statistic Q (based on random effects model)  if 
tau.w 
Squareroot of betweenstudy variance within subgroups
 if 
H.w 
Heterogeneity statistic H within subgroups  if

lower.H.w, upper.H.w 
Lower and upper confidence limit for
heterogeneity statistic H within subgroups  if 
I2.w 
Heterogeneity statistic I^2 within subgroups  if

lower.I2.w, upper.I2.w 
Lower and upper confidence limit for
heterogeneity statistic I^2 within subgroups  if 
keepdata 
As defined above. 
data 
Original data (set) used in function call (if

subset 
Information on subset of original data used in
metaanalysis (if 
call 
Function call. 
version 
Version of R package meta used to create object. 
The function metagen
is called internally to
calculate individual and overall treatment estimates and standard
errors.
Guido Schwarzer sc@imbi.unifreiburg.de
DerSimonian R & Laird N (1986): Metaanalysis in clinical trials. Controlled Clinical Trials, 7, 177–88
Hartung J & Knapp G (2001): On tests of the overall treatment effect in metaanalysis with normally distributed responses. Statistics in Medicine, 20, 1771–82
Higgins JPT, Thompson SG, Spiegelhalter DJ (2009): A reevaluation of randomeffects metaanalysis. Journal of the Royal Statistical Society: Series A, 172, 137–59
IntHout J, Ioannidis JPA, Borm GF (2014): The HartungKnappSidikJonkman method for random effects metaanalysis is straightforward and considerably outperforms the standard DerSimonianLaird method. BMC Medical Research Methodology, 14, 25
IQWiG (2020): General Methods: Version 6.0. https://www.iqwig.de/en/aboutus/methods/methodspaper/
Jackson D, Law M, Rücker G, Schwarzer G (2017): The HartungKnapp modification for randomeffects metaanalysis: A useful refinement but are there any residual concerns? Statistics in Medicine, 36, 3923–34
Langan D, Higgins JPT, Jackson D, Bowden J, Veroniki AA, Kontopantelis E, et al. (2019): A comparison of heterogeneity variance estimators in simulated randomeffects metaanalyses. Research Synthesis Methods, 10, 83–98
Viechtbauer W (2010): Conducting MetaAnalyses in R with the Metafor Package. Journal of Statistical Software, 36, 1–48
Wiksten A, Rücker G, Schwarzer G (2016): HartungKnapp method is not always conservative compared with fixedeffect metaanalysis. Statistics in Medicine, 35, 2503–15
update.meta
, metamean
,
metagen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  m1 < metamean(rep(100, 3), 1:3, rep(1, 3))
m1
m2 < update(m1, sm = "MLN")
m2
# With test for overall mean equal to 2
#
update(m1, null.effect = 2)
update(m2, null.effect = 2)
# Print results without backtransformation
#
update(m1, backtransf = FALSE)
update(m2, backtransf = FALSE)
update(m1, null.effect = 2, backtransf = FALSE)
update(m2, null.effect = 2, backtransf = FALSE)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.