Type: | Package |
Title: | Robust Meta-Analysis and Meta-Regression |
Version: | 1.0-6 |
Date: | 2025-01-18 |
Maintainer: | Ken Beath <ken@kjbeath.id.au> |
Contact: | Ken Beath <ken@kjbeath.id.au> |
Author: | Ken Beath [aut, cre], Ben Bolker [aut], R Development Core Team [aut] |
Description: | Performs meta-analysis and meta-regression using standard and robust methods with confidence intervals based on the profile likelihood. Robust methods are based on alternative distributions for the random effect, either the t-distribution (Lee and Thompson, 2008 <doi:10.1002/sim.2897> or Baker and Jackson, 2008 <doi:10.1007/s10729-007-9041-8>) or mixtures of normals (Beath, 2014 <doi:10.1002/jrsm.1114>). |
Depends: | R(≥ 3.2.0) |
Suggests: | R.rsp |
VignetteBuilder: | R.rsp |
Imports: | bbmle, metafor, boot, methods, numDeriv, MASS, graphics, stats, fastGHQuad, lme4, Rfast, parallel, doParallel, foreach |
LazyData: | yes |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
NeedsCompilation: | no |
Packaged: | 2025-01-23 05:45:13 UTC; kenbeath |
Repository: | CRAN |
Date/Publication: | 2025-01-23 06:10:02 UTC |
Fits random effects meta-analysis models including robust models
Description
Allows fitting of random effects meta-analysis producing confidence intervals based on the profile likelihood (Hardy and Thompson, 1996). Two methods of robust meta-analysis are included, based on either the t
-distribution (Baker and Jackson (2008) and Lee and Thompson (2008)) or normal-mixture distribution (Beath, 2014). Tests can be performed for the need for a robust model, using a parametric bootstrap, and for the normal-mixture the identity of the outliers using the posterior probability. Plots are produced allowing a comparison between the results of each method. Where possible use has been made of the metafor package.
The metaplus function
This is the main function that allows fitting the models. The metaplus objects may be plotted, using plot, and tested for outliers using testOutliers. The results of tests.outliers may also be plotted.
Author(s)
Ken Beath <ken@kjbeath.id.au>
References
Baker, R., & Jackson, D. (2008). A new approach to outliers in meta-analysis. Health Care Management Science, 11(2), 121-131. doi:10.1007/s10729-007-9041-8
Beath, K. J. (2014). A finite mixture method for outlier detection and robustness in meta-analysis. Research Synthesis Methods, (in press). doi:10.1002/jrsm.1114
Hardy, R. J., & Thompson, S. G. (1996). A likelihood approach to meta-analysis with random effects. Statistics in Medicine, 15, 619-629.
Lee, K. J., & Thompson, S. G. (2008). Flexible parametric models for random effects distributions. Statistics in Medicine, 27, 418-434. doi:10.1002/sim
AIC for metaplus object
Description
Returns AIC for a metaplus object.
Usage
## S3 method for class 'metaplus'
AIC(object, ...)
Arguments
object |
metaplus object |
... |
additional argument; currently none are used. |
Value
AIC of fitted model
Author(s)
Ken Beath
Examples
data(mag)
mag1 <- metaplus(yi, sei, plotci = TRUE, slab = study, cores = 1, data = mag)
print(AIC(mag1))
BIC for metaplus object
Description
Returns BIC for a metaplus object.
Usage
## S3 method for class 'metaplus'
BIC(object, ...)
Arguments
object |
metaplus object |
... |
additional argument; currently none are used. |
Value
BIC of fitted model
Author(s)
Ken Beath
Examples
data(mag)
mag1 <- metaplus(yi, sei, plotci = TRUE, slab = study, cores = 1, data = mag)
print(BIC(mag1))
CDP meta-analysis data
Description
Data for the meta-analysis by Fioravanti and Yanagi (2005) of cytidinediphosphocholine (CDP-choline) for cognitive and behavioural disturbances associated with chronic cerebral disorders in the elderly.
Usage
cdp
Format
A data frame with 10 observations on the following 3 variables.
study
study authors and date
yi
study effect estimate
sei
study standard error
Source
Fioravanti and Yanagi (2005)
References
Fioravanti, M., & Yanagi, M. (2005). Cytidinediphosphocholine (CDP choline) for cognitive and behavioural disturbances associated with chronic cerebral disorders in the elderly (Review). The Cochrane Database of Systematic Reviews. Retrieved from http://onlinelibrary.wiley.com/doi/10.1002/14651858.CD000269.pub2/pdf
Examples
data(cdp)
cdp1 <- metaplus(yi, sei, plotci = TRUE, slab = study, cores = 1, data = cdp)
Exercise meta-analysis data
Description
Lawlor & Hopker (2001) performed a meta-analysis of trials of exercise in the management of depression, which was subsequently analysed using meta- regression (Higgins & Thompson 2004) with duration of treatment as a covariate. There is a possible outlier, the study by Reuter. While there are additional predictors, it seems excessive to use them given the small number of studies.
Usage
exercise
Format
A data frame with 10 observations on the following 9 variables.
study
study author
smd
study effect estimate
varsmd
study effect variance
sesmd
study effect standard error
abstract
study available as abstract only?
duration
length of study in weeks
itt
intention to treat analysis?
alloc
outcome assessor blinded
phd
phd thesis?
Source
Higgins and Thompson (2004)
References
Higgins, J. P. T., & Thompson, S. G. (2004). Controlling the risk of spurious findings from meta-regression. Statistics in Medicine, 23(11), 166382. doi:10.1002/sim.1752
Lawlor, D. A., & Hopker, S. W. (2001). The effectiveness of exercise as an intervention in the management of depression: systematic review and meta-regression analysis of randomised controlled trials. BMJ, 322(31 March), 18.
Examples
exercise1 <- metaplus(smd, sqrt(varsmd), mods = duration, slab = study,
cores = 1, data = exercise)
exercise2 <- metaplus(smd, sqrt(varsmd), mods = cbind(duration, itt), slab = study,
cores = 1, data = exercise)
log Likelikelihood for metaplus object
Description
Returns the log Likelihood for a metaplus object.
Usage
## S3 method for class 'metaplus'
logLik(object, ...)
Arguments
object |
metaplus object |
... |
additional argument; currently none are used. |
Value
The loglikelihood of the fitted model.
Author(s)
Ken Beath
Examples
data(mag)
mag1 <- metaplus(yi, sei, plotci = TRUE, slab = study, cores = 1, data = mag)
print(logLik(mag1))
Magnesium meta-analysis data
Description
Data for a meta-analysis of intravenous magnesium in acute myocardial infarction. An interesting question is whether the ISIS4 study is an outlier.
Usage
mag
Format
A data frame with 16 observations on the following 3 variables.
study
study author
yi
study effect estimate
sei
study standard error
Source
Sterne et al (2001)
References
Sterne, J. A. C., Bradburn, M. J., & Egger, M. (2001). Meta-analysis in Stata. In M. Egger, G. D. Smith, & D. G. Altman (Eds.), Systematic Reviews in Health Care: Meta-Analysis in Context (pp. 347-369). BMJ Publishing Group.
Examples
data(mag)
mag1 <- metaplus(yi, sei, plotci = TRUE, slab = study, cores = 1, data = mag)
plot(mag1)
Marinho meta-analysis data
Description
Data for the meta-analysis by Marinho et al (2009) to determine the effectiveness of fluoride toothpastes on caries in children.
Usage
marinho
Format
A data frame with 70 observations on the following 11 variables.
study
study authors and date
nfluor
number in fluoride group
meanfluor
mean effect in fluoride group
sdfluor
standard deviation of effect in fluoride group
nplacebo
number in placebo group
meanplacebo
mean effect in placebo group
sdplacebo
standard deviation of effect in placebo group
meaneffect
mean effect difference
seeffect
standard error of effect difference
Source
Marinho et al (2009)
References
Marinho, V. C. C., Higgins, J. P. T., Logan, S., & Sheiham, A. (2009). Fluoride toothpastes for preventing dental caries in children and adolescents (Review). The Cochrane Database of Systematic Reviews. Retrieved from http://onlinelibrary.wiley.com/doi/10.1002/14651858.CD002278/pdf
Examples
data(marinho)
marinho1 <- metaplus(meaneffect, seeffect, plotci = TRUE, slab = study, cores = 1, data = marinho)
Fits random effects meta-analysis models, using either a standard normal distribution, a t
-distribution or a mixture of normals for the random effect.
Description
Allows fitting of random effects meta-analysis producing confidence intervals based on profile likelihood. Two methods of robust meta-analysis are included, based on either the t
-distribution or normal-mixture distribution.
Usage
metaplus(yi, sei, mods = NULL, random = "normal",
label = switch(random, "normal" = "Random Normal", "t-dist" = "Random t-distribution",
"mixture" = "Random mixture"),
plotci = FALSE, justfit = FALSE, slab = 1:length(yi),
useAGQ = FALSE, quadpoints = 21, notrials = 20,
cores = max(detectCores()%/%2, 1), data)
Arguments
yi |
vector of observed effect size |
sei |
vector of observed standard errors (note: not standard errors squared) |
mods |
data frame of covariates corresponding to each study |
random |
The type of random effects distribution. One of "normal", "t-dist", "mixture", for standard normal, |
label |
The label to be used for this model when plotting |
plotci |
Should profile be plotted for each confidence interval? |
justfit |
Should model only be fitted? If justfit = TRUE then profiling and likelihood ratio statistics are not calculated. Useful for when bootstrapping. |
slab |
Vector of character strings corresponding to each study. |
useAGQ |
Deprecated. No longer used. |
quadpoints |
Deprecated. No longer used. |
notrials |
Number of random starting values to use for mixture models. |
cores |
Number of rcores to use for parallel processing of . |
data |
Optional data frame containing some or all other data. |
Details
As well as standard normal random effects meta-analysis, fitting of robust models incorporating either a t
-distribution random effect (Lee and Thompson, 2008 or Baker and Jackson, 2008) or a mixture of normals (Beath, 2014) may be fitted. For all models the profile log-likelihood (Hardy and Thompson, 1996) is used to determine the confidence intervals for the parameters, with corresponding p values calculated using the likelihood ratio test, to give consistency between the confidence intervals and p values. The profile log-likelihood produces confidence intervals with better properties than REML or Der Simonian-Laird method (Brockwell and Gordon 2001, Jackson et al 2010)
For the mixture normal model, multiple starting values are used. This is achieved by starting with the no outlier model, then all possible single outlier models and choosing the model with the maximum likelihood. The process is repeated by adding all possible outliers to obtain the two outlier models and the maximum likelihood chosen. The process is repeated until the likelihood is not further maximised by adding outliers. This method gives a faster fitting time and is more reliable than using random assignments, as we have usually only a small number of outliers.
Value
results |
Matrix containing columns for estimate, lower 95%, upper 95% and p value, or if justfit = TRUE then only the parameter estimates |
yi |
Effect sizes |
sei |
Standard error of effect sizes |
mods |
Modifiers for meta-regression |
slab |
Study labels |
justfit |
Value of justfit passed to the method. |
fittedmodel |
final model returned by mle2 |
profile |
profile likelihood returned as described in bbmle |
random |
Type of random effect |
outlier.prob |
Outlier probabilities for robust mixture model only |
Note
I have used cores = 1 in the examples, as this is required by some of the checking procedures but it can, and should be, be removed for your own use for faster execution.
Author(s)
Ken Beath <ken@kjbeath.id.au>
References
Baker, R., & Jackson, D. (2008). A new approach to outliers in meta-analysis. Health Care Management Science, 11(2), 121131.
Beath, K. J. (2014). A finite mixture method for outlier detection and robustness in meta-analysis. Research Synthesis Methods, 5, 285-293. doi:10.1002/jrsm.1114
Brockwell, S. E., & Gordon, I. R. (2001). A comparison of statistical methods for meta-analysis. Statistics in Medicine, 20, 825-840.
Hardy, R. J., & Thompson, S. G. (1996). A likelihood approach to meta-analysis with random effects. Statistics in Medicine, 15, 619-629.
Jackson, D., Bowden, J., & Baker, R. (2010). How does the DerSimonian and Laird procedure for random effects meta-analysis compare with its more efficient but harder to compute counterparts? Journal of Statistical Planning and Inference, 140, 961-970. doi:10.1016/j.jspi.2009.09.017
Lee, K. J., & Thompson, S. G. (2008). Flexible parametric models for random effects distributions. Statistics in Medicine, 27, 418-434. doi:10.1002/sim
Examples
library(metaplus)
# perform meta-analysis for mag studies, which have no outliers
# fit standard normal random-effect model and print summary
mag.meta <- metaplus(yi, sei, slab = study, data = mag)
summary(mag.meta)
# repeat, but this time plot the profile likelihood diagnostic plot using plotci
mag.meta <- metaplus(yi, sei, slab = study, plotci = TRUE, cores = 1, data = mag)
# plot a forest plot with exponential transform, so that the odds ratios are plotted
plot(mag.meta, atransf = exp, at = log(c(.01, .1, 1, 10, 100)), xlab = "Odds Ratio",
cex = 0.75)
# repeat for t-distribution random effects
mag.tdist <- metaplus(yi, sei, slab = study,
random = "t-dist", cores = 1, data = mag)
summary(mag.tdist)
# use parametric bootstrap to test for presence of outliers
summary(testOutliers(mag.tdist, cores = 1))
# repeat for robust mixture random effects
mag.mix <- metaplus(yi, sei, slab = study,
random = "mixture", cores = 1, data = mag)
summary(mag.mix)
# use parametric bootstrap to test for presence of outliers
summary(testOutliers(mag.mix, cores = 1))
# perform meta-analysis for CDP studies
# where there is one outlier
cdp.meta <- metaplus(yi, sei, slab = study, cores = 1, data = cdp)
summary(cdp.meta)
cdp.tdist <- metaplus(yi, sei, slab = study,
random = "t-dist", cores = 1, data = cdp)
summary(cdp.tdist)
summary(testOutliers(cdp.tdist, cores = 1))
cdp.mix <- metaplus(yi, sei, slab = study,
random = "mixture", cores = 1, data = cdp)
summary(cdp.mix)
summary(testOutliers(cdp.mix, cores = 1))
# extract and plot outlier probabilities
cdp.mix.outlierProbs <- outlierProbs(cdp.mix)
plot(cdp.mix.outlierProbs)
# produce forest plot with summary for all 3 models, showing narrower confidence
# intervals for robust models
plot(cdp.meta, extrameta = list(cdp.tdist, cdp.mix), xlab = "Standardised Mean Difference")
# effect of exercise on depression with covariate of length of study
# fit the 3 models
exercise.meta <- metaplus(smd, sqrt(varsmd),
mods = duration, slab = study, cores = 1, data = exercise)
summary(exercise.meta)
exercise.mix <- metaplus(smd, sqrt(varsmd),
mods = duration, slab = study, random = "mixture",
cores = 1, data = exercise)
summary(exercise.mix)
exercise.testOutliers <- testOutliers(exercise.mix, cores = 1)
summary(exercise.testOutliers)
# identify possible outliers
exercise.outlierProbs <- outlierProbs(exercise.mix)
plot(exercise.outlierProbs)
# centre duration at different values to obtain predictions at 4, 8 and 12 weeks
exercise$duration4 <- exercise$duration-4
exercise$duration8 <- exercise$duration-8
exercise$duration12 <- exercise$duration-12
# fit the different models, giving each an appropriate label
exercise.nodurn <- metaplus(smd, sqrt(varsmd),
label = "Random Mixture (No Duration)", slab = study,
random = "mixture", cores = 1, data = exercise)
exercise.wk4 <- metaplus(smd, sqrt(varsmd),
mods = duration4, label = "Random Mixture (Week 4)",
slab = study, random = "mixture", cores = 1, data = exercise)
exercise.wk8 <- metaplus(smd, sqrt(varsmd),
mods = duration8, label = "Random Mixture (Week 8)",
slab = study, random = "mixture", cores = 1, data = exercise)
exercise.wk12 <- metaplus(smd, sqrt(varsmd),
mods = duration12, label = "Random Mixture (Week 12)",
slab = study, random = "mixture", cores = 1, data = exercise)
# produce forest plot with summary for each model with robust mixture model at different weeks
plot(exercise.nodurn, extrameta = list(exercise.wk4, exercise.wk8,
exercise.wk12), xlab = "Standardised mean difference")
Calculate outlier probabilities for each study.
Description
For the normal mixture random effect calculates the probability that each study is an outlier based on the posterior probability of it being an outlier.
Usage
## S3 method for class 'metaplus'
outlierProbs(object)
Arguments
object |
A metaplus object with a mixture (robust) random effects distribution. |
Details
The outlier probabilities are obtained as the posterior probabilities of each study being an outlier based on the fitted mixture model.
Value
outlier.prob |
Posterior probability that each study is an outlier |
slab |
Labels corresponding to each study |
Author(s)
Ken Beath <ken@kjbeath.id.au>
Examples
data(mag)
mag3 <- metaplus(yi, sei, plotci = TRUE, slab = study, random = "mixture", cores = 1, data = mag)
mag3.outlierProbs <- outlierProbs(mag3)
plot(mag3.outlierProbs)
Produces forest plot for the studies together with the meta-analysis results.
Description
Produces a forest plot for the studies in the meta-analysis and the result of the meta-analysis. Allows the inclusion of extra results of alternative meta-analyses, to allow, for example comparison between standard and robust methods of meta-analysis. Makes extensive use of the metafor package to produce the forest plot.
Usage
## S3 method for class 'metaplus'
plot(x, ..., extrameta = NULL)
Arguments
x |
metaplus object to be plotted |
... |
additional parameters to plot |
extrameta |
Additional metaplus objects to be plotted. Only the summary statistic is plotted at the end of the plot. This is useful for comparing standard and robust methods, or meta-regressions for various values of the predictor. |
Value
Plot
Note
On some systems the alignment of characters in the CI may be poor when saving the plots to pdf. A solution is to use the extrafont package and a fixed width font, for eample Courier New. Then if creating the plot using pdf() the parameter family = "Courier New" will use this font and fonts = "Courier New" will add it to the pdf.
An alternative is to use pdf.options() with the same parameters before the plot, and pdf.options(reset = TRUE) will produce the same effect.
Author(s)
Ken Beath <ken@kjbeath.com.au>
Examples
data(cdp)
# produce all 3 models for the CDP data and plot them all
cdp1 <- metaplus(yi, sei, plotci = TRUE, slab = study, cores = 1, data = cdp)
cdp2 <- metaplus(yi, sei, plotci = TRUE, slab = study, random = "t-dist", cores = 1, data = cdp)
cdp3 <- metaplus(yi, sei, plotci = TRUE, slab = study, random = "mixture", cores = 1, data = cdp)
plot(cdp1, extrameta = list(cdp2, cdp3))
# plot effect of exercise on depression at 4, 8 and 12 weeks
data(exercise)
exercise$duration4 <- exercise$duration-4
exercise$duration8 <- exercise$duration-8
exercise$duration12 <- exercise$duration-12
exercise.wk4 <- metaplus(smd, sqrt(varsmd), mods = duration4,
label = "Random Mixture (Week 4)", slab = study, random = "mixture", cores = 1, data = exercise)
exercise.wk8 <- metaplus(smd, sqrt(varsmd), mods = duration8,
label = "Random Mixture (Week 8)", slab = study, random = "mixture", cores = 1, data = exercise)
exercise.wk12 <- metaplus(smd, sqrt(varsmd), mods = duration12,
label = "Random Mixture (Week 12)", slab = study, random = "mixture", cores = 1, data = exercise)
exercise.nodurn <- metaplus(smd, sqrt(varsmd), plotci = TRUE,
label = "Random Mixture (No Duration)", slab = study, random = "mixture",
cores = 1, data = exercise)
plot(exercise.nodurn, extrameta = list(exercise.wk4, exercise.wk8, exercise.wk12))
Plot outlier probabilities.
Description
Plots the outlier probability for each study, from an outlierProbs object.
Usage
## S3 method for class 'outlierProbs'
plot(x, ...)
Arguments
x |
outlierProbs object to be plotted |
... |
additional parameters to plot |
Value
Plot
Author(s)
Ken Beath <ken@kjbeath.id.au>
Examples
data(mag)
mag.mix <- metaplus(yi, sei, plotci = TRUE, slab = study, random = "mixture", cores = 1, data = mag)
mag.mix.outlierProbs <- outlierProbs(mag.mix)
plot(mag.mix.outlierProbs)
Summary of a metaplus object.
Description
Summarises the meta-analysis, giving the parameter estimates and goodness of fit statistics. For the robust methods this includes the values of the parameters relating to robustness. In the summary the 95% confidence intervals are calculated using the profile likelihood method. To produce corresponding p-values these are obtained from the likelihood ratio test statistic.
Usage
## S3 method for class 'metaplus'
summary(object, ...)
Arguments
object |
metaplus object to summarise. |
... |
Additional parameters to summary. |
Value
results |
Matrix containing parameter estimates, confidence intervals and p values |
fitstats |
List containing logLikelihood, AIC and BIC |
Author(s)
Ken Beath <ken@kjbeath.id.au>
Examples
data(mag)
mag1 <- metaplus(yi, sei, plotci = TRUE, slab = study, cores = 1, data = mag)
summary(mag1)
Tests for the presence of outliers.
Description
For the t
-distribution models this is a test that the degrees of freedom is infinitite, or equivalently that it's inverse is zero. For the mixture-normal model it is a test that the proportion of outliers is zero. As both tests involve a parameter on the boundary of the parameter space, asymptotic theory does not apply, so a parametric bootstrap is performed to determine the empirical distribution of the test statistic under the null hypothesis. The observed likelihood ratio statistic is then compared to this distribution to determine the p value.
Usage
## S3 method for class 'metaplus'
testOutliers(object, R = 999, cores = max(detectCores()%/%2, 1))
Arguments
object |
The meta-analysis for which the presence of outliers is to be tested. |
R |
Number of simulations (parametric bootstraps) used in testing the hypothesis. Initially, it may be useful to set this to a smaller value, to allow faster execution time. |
cores |
Number of cores used to simultaneously perform simulations. |
Value
pvalue |
p value obtained from parametric bootstrap |
observed |
Observed value of the likelihood ratio test statistic |
sims |
Simulated values of the test statistic under the null hypothesis |
Note
Running the default number of bootstrap samples may take considerable time, of the order of hours. Use of the parallel options will improve these times. For a preliminary guide to whether there are outliers, this is indicated by a reduction in AIC or BIC with the robust model, and a change in the estimated mean effect.
Author(s)
Ken Beath <ken@kjbeath.id.au>
Examples
data(cdp)
cdp3 <- metaplus(yi, sei , plotci = TRUE, slab = study, random = "mixture", cores = 1, data = cdp)
summary(testOutliers(cdp3, cores = 1))