Package 'rmeta'

Title: Meta-Analysis
Description: Functions for simple fixed and random effects meta-analysis for two-sample comparisons and cumulative meta-analyses. Draws standard summary plots, funnel plots, and computes summaries and tests for association and heterogeneity.
Authors: Thomas Lumley
Maintainer: Thomas Lumley <[email protected]>
License: GPL-2
Version: 3.0
Built: 2024-11-17 03:08:32 UTC
Source: https://github.com/cran/rmeta

Help Index


Meta-analysis of antibacterial catheter coating

Description

Data on the effectiveness of silver sulfadiazine coating on venous catheters for preventing bacterial colonisation of the catheter and bloodstream infection

Usage

data(catheter)

Format

A data.frame with 8 variables giving information about 16 controlled trials of antibacterial-coated venous catheters

Name : Name of principal author
n.trt : number of coated catheters
n.ctrl : number of standard catheters
col.trt : number of coated catheters colonised
by bacteria
col.ctrl : number of standard catheters colonised
by bacteria
inf.trt : number of coated catheters resulting in
bloodstream infection
inf.ctrl : number of standard catheters resulting in
bloodstream infection
or : Odds ratio

Source

Veenstra D et al (1998) "Efficacy of Antiseptic Impregnated Central Venous Catheters in Preventing Nosocomial Infections: A Meta-analysis" JAMA 281:261-267

Examples

library(rmeta)
data(catheter)
a <- meta.MH(n.trt, n.ctrl, col.trt, col.ctrl, data=catheter,
             names=Name, subset=c(13,6,5,3,7,12,4,11,1,8,10,2))
b <- meta.DSL(n.trt, n.ctrl, col.trt, col.ctrl, data=catheter,
              names=Name,subset=c(13,6,5,3,7,12,4,11,1,8,10,2))
a
b
summary(a)
summary(b)
plot(a)
plot(b)

Data for Cochrane Collaboration logo

Description

Data from randomised trials before 1980 of corticosteroid therapy in premature labour and its effect on neonatal death.

Usage

data(cochrane)

Format

This data frame contains the following columns:

name

Identifier for the study

ev.trt

Number of deaths in the treated group

n.trt

Number in the treated group

ev.ctrl

Number of deaths in the control group

n.ctrl

Number in the control group

Details

This meta-analysis, if done, would likely have resulted in the treatment being widely used a decade earlier than it was, saving many lives. The graph is part of the logo of the Cochrane Collaboration, a group aiming to perform systematic reviews of the entire clinical trial literature.

Source

http://www.cochrane.org

Examples

data(cochrane)
steroid <- meta.MH(n.trt, n.ctrl, ev.trt, ev.ctrl,
                   names=name, data=cochrane)
plot(steroid, col=meta.colors("RoyalBlue"))

Cumulative meta-analysis of binary data

Description

A cumulative meta-analysis plot shows how evidence has accumulated over time. The ith line in the cumulative meta-analysis plot is the summary produced by a meta-analysis of the first i trials.

Usage

cummeta(ntrt, nctrl, ptrt, pctrl, conf.level = 0.95,
   names = NULL, data= NULL, subset = NULL, 
   na.action = na.fail,
    method = c("meta.MH", "meta.DSL"),
   statistic = "OR")
cummeta.summaries(effects,stderrs, conf.level = 0.95,
   names = NULL,weights=NULL, data= NULL,
   subset = NULL, na.action = get(getOption("na.action")),
   method = c("fixed", "random"), logscale=TRUE)
## S3 method for class 'meta.cum'
plot(x, conf.level = NULL,
    colors = meta.colors(), xlab = NULL, 
    summary.line = TRUE, summary.conf = FALSE,
     main="Cumulative meta-analysis", lwd=1, ...)
## S3 method for class 'meta.cum'
summary(object ,conf.level=NULL,...)

Arguments

ntrt

Number of subjects in treated/exposed group

nctrl

Number of subjects in control group

ptrt

Number of events in treated/exposed group

pctrl

Number of events in control group

effects

Difference between control and treatment group

stderrs

Standard errors of effects

weights

Study weights (see meta.summaries)

names

names or labels for studies

data

data frame to interpret variables

subset

subset of studies to include

na.action

How to handle missing values

method

Which meta-analysis method to use

statistic

"OR" for odds ratio or "RR" for relative risk.

logscale

The effects values are the logarithms of actual effects (for plotting)

x, object

a meta.cum object

...

other graphical arguments for metaplot

conf.level

Coverage for confidence intervals

colors

see meta.colors

xlab

X-axis label

summary.line

Plot a vertical line at the final summary value?

summary.conf

Plot vertical lines at the final confidence interval limits?

main, lwd

graphical parameters

Value

Object of class meta.cum.

See Also

meta.MH,meta.DSL

Examples

data(cochrane)
steroid<-cummeta(n.trt,n.ctrl,ev.trt,ev.ctrl,names=name,data=cochrane,
  statistic="RR",method="meta.MH")
plot(steroid)
summary(steroid)
data(catheter)
b <- meta.DSL(n.trt, n.ctrl, col.trt, col.ctrl, data=catheter,
              names=Name, subset=c(13,6,5,3,12,4,11,1,8,10,2))
d <- cummeta.summaries(b$logs, b$selogs, names=b$names,
                    method="random", logscale=TRUE)
plot(d,summary.conf=TRUE)
summary(d)

Forest plots

Description

Draw a forest plot together with a table of text.

Usage

forestplot(labeltext, mean, lower, upper, align = NULL,
 is.summary = FALSE, clip = c(-Inf, Inf), xlab = "", 
 zero = 0, graphwidth = unit(2, "inches"), col = meta.colors(),
  xlog = FALSE, xticks=NULL, boxsize=NULL,...)

Arguments

labeltext

Matrix of strings or NAs for blank spaces

mean

Vector of centers of confidence intervals (or NAs for blank space)

lower

Vector of lower ends of confidence intervals

upper

Vector of upper ends of confidence intervals

align

Vector giving alignment (l,r,c) for columns of table

is.summary

Vector of logicals. Summary lines have bold text and diamond confidence intervals.

clip

Lower and upper limits for clipping confidence intervals to arrows

xlab

x-axis label

zero

x-axis coordinate for zero line

graphwidth

Width of confidence interval graph

col

See meta.colors

xlog

If TRUE, x-axis tick marks are exponentiated

xticks

Optional user-specified x-axis tick marks. Specify NULL to use the defaults, numeric(0) to omit the x-axis.

boxsize

Override the default box size based on precision

...

Not used.

Details

This function is more flexible than metaplot and the plot methods for meta-analysis objects, but requires more work by the user.

In particular, it allows for a table of text, and clips confidence intervals to arrows when they exceed specified limits.

Value

None

See Also

metaplot

Examples

data(cochrane)
steroid <- meta.MH(n.trt, n.ctrl, ev.trt, ev.ctrl,
                        names=name, data=cochrane)

tabletext<-cbind(c("","Study",steroid$names,NA,"Summary"),
          c("Deaths","(steroid)",cochrane$ev.trt,NA,NA),
          c("Deaths","(placebo)", cochrane$ev.ctrl, NA,NA),
          c("","OR",format(exp(steroid$logOR),digits=2),NA,format(exp(steroid$logMH),digits=2))
          )

m<- c(NA,NA,steroid$logOR,NA,steroid$logMH)
l<- m-c(NA,NA,steroid$selogOR,NA,steroid$selogMH)*2
u<- m+c(NA,NA,steroid$selogOR,NA,steroid$selogMH)*2
forestplot(tabletext,m,l,u,zero=0,
   is.summary=c(TRUE,TRUE,rep(FALSE,8),TRUE),
   clip=c(log(0.1),log(2.5)), xlog=TRUE,
   col=meta.colors(box="royalblue",
       line="darkblue", summary="royalblue"))

forestplot(tabletext,m,l,u,zero=0,
    is.summary=c(TRUE,TRUE,rep(FALSE,8),TRUE),
   clip=c(log(0.1),log(2.5)), xlog=TRUE, boxsize=0.75,
   col=meta.colors(box="royalblue",line="darkblue",
    summary="royalblue"))

Funnel plot for publication bias

Description

Plots the treatment difference for trials against the size of the trial (or other specified variable). Asymmetry in the plot often indicates publication bias. Generic, with methods for meta-analysis objects.

Usage

funnelplot(x,...)
## Default S3 method:
funnelplot(x, se, size=1/se, summ=NULL,
        xlab="Effect", ylab="Size", colors=meta.colors(),
        conf.level=0.95, plot.conf=FALSE,
        zero=NULL, mirror=FALSE, ...)

Arguments

x

Treatment difference

se

Standard error of x

size

Variable for the vertical axis

summ

summary treatment difference

xlab

x-axis label

ylab

y-axis label

colors

list of colors for components of the plot

conf.level

For confidence interval plotting

plot.conf

Plot confidence intervals instead of just points?

zero

location of a null hypothesis line

mirror

Add points reflected around summ?

...

further arguments to be passed from or to methods.

Details

With the default value of size the plot should appear as a upwards-pointing funnel shape. Publication bias often causes one side of the funnel to be trimmed near the base. The mirror plot creates a symmetric funnel by reflecting the plot around the summ value. In the presence of publication bias the added points will separate from the real studies.

Value

Used for its side-effect.

Author(s)

Thomas Lumley

See Also

meta.DSL, meta.MH, meta.summaries, metaplot

Examples

data(catheter)
a <- meta.MH(n.trt, n.ctrl, col.trt, col.ctrl, data=catheter,
             names=Name, subset=c(13,6,5,3,7,12,4,11,1,8,10,2))
funnelplot(a$logOR, a$selogOR)
funnelplot(a$logOR, a$selogOR,
           plot.conf=TRUE, summ=a$logMH, mirror=TRUE)
funnelplot(a, plot.conf=TRUE)

Control colours in meta-analysis plot

Description

Wrapper function for specifying colours to meta-analysis plots

Usage

meta.colors(all.elements, box="black", lines="gray", summary="black",
            zero="lightgray", mirror="lightblue", text="black",
             axes="black",background=NA)

Arguments

all.elements

if present, overrides other arguments

box

Colour of sample size box

lines

Colour of confidence intervals

summary

Colour of summary estimate

zero

Colour of null hypothesis line

mirror

Colour of reflected points (in funnelplot)

text

Colour of labels

axes

Colour of x-axis and axis labels

background

Background colour.

Value

a list of colors

See Also

plot.meta.MH,plot.meta.DSL,plot.meta.summaries,funnelplot,metaplot

Examples

data(cochrane)
steroid <- meta.MH(n.trt, n.ctrl, ev.trt, ev.ctrl,
                   names=name, data=cochrane)

## All black, for better photocopying
plot(steroid, col=meta.colors("black"))

## distinguish the summary 
plot(steroid,colors=meta.colors(summary="forestgreen"))

data(catheter)
e <- meta.DSL(n.trt, n.ctrl, inf.trt, inf.ctrl, data=catheter,
              names=Name, subset=c(13,6,3,12,4,11,1,14,8,10,2))

## Truly awful colour scheme to illustrate flexibility
plot(e, colors=meta.colors(summary="green",lines=c("purple","skyblue"),
       box="red",zero="yellow",text=palette(),background="tomato",
       axes="lightgreen"))

## Dark blue background popular for presentations.
plot(e, colors=meta.colors(summary="white",lines="#FFFFF0",
        box="#FFFF50",zero="grey90",text="white",background="darkblue",
        axes="grey90"))

Random effects (DerSimonian-Laird) meta-analysis

Description

Computes the individual odds ratios or relative risks, the summary, the random effects variance, and Woolf's test for heterogeneity. The print method gives the summary and test for heterogeneity; the summary method also gives all the individual odds ratios and confidence intervals. Studies with zero or infinite odds ratio are omitted, as their variance cannot be calculated sensibly.

The plot method draws a standard meta-analysis plot. The confidence interval for each study is given by a horizontal line, and the point estimate is given by a square whose height is inversely proportional to the standard error of the estimate. The summary odds ratio, if requested, is drawn as a diamond with horizontal limits at the confidence limits and width inversely proportional to its standard error.

Usage

meta.DSL(ntrt, nctrl, ptrt, pctrl, conf.level=0.95,
         names=NULL, data=NULL, subset=NULL, na.action=na.fail,statistic="OR")
## S3 method for class 'meta.DSL'
summary(object, conf.level=NULL, ...)
## S3 method for class 'meta.DSL'
plot(x, summary=TRUE, summlabel="Summary",
             conf.level=NULL, colors=meta.colors(), xlab=NULL,...)

Arguments

ntrt

Number of subjects in treated/exposed group

nctrl

Number of subjects in control group

ptrt

Number of events in treated/exposed group

pctrl

Number of events in control group

conf.level

Coverage for confidence intervals

names

names or labels for studies

data

data frame to interpret variables

subset

subset of studies to include

na.action

a function which indicates what should happen when the data contain NAs. Defaults to na.fail.

statistic

"OR" for odds ratio, "RR" for relative risk

x, object

a meta.DSL object

summary

Plot the summary odds ratio?

summlabel

Label for the summary odds ratio

colors

see meta.colors

xlab

x-axis label, default is based on statistic

...

further arguments to be passed from or to methods.

Value

An object of class meta.DSL with print, plot, funnelplot and summary methods.

Author(s)

Thomas Lumley

See Also

plot,par,meta.MH,funnelplot

Examples

data(catheter)
b <- meta.DSL(n.trt, n.ctrl, col.trt, col.ctrl, data=catheter,
              names=Name, subset=c(13,6,5,3,7,12,4,11,1,8,10,2))
b
summary(b)
plot(b)
e <- meta.DSL(n.trt, n.ctrl, inf.trt, inf.ctrl, data=catheter,
              names=Name, subset=c(13,6,3,12,4,11,1,14,8,10,2))
e
summary(e)
##tasteless
plot(e, colors=meta.colors(summary="green",lines="purple",box="orange"))

Fixed effects (Mantel-Haenszel) meta-analysis

Description

Computes the individual odds ratio or relative risk, the Mantel-Haenszel summary, and Woolf's test for heterogeneity. The print method gives the summary and test for heterogeneity; the summary method also gives all the individual odds ratios and confidence intervals.

The plot method draws a standard meta-analysis plot. The confidence interval for each study is given by a horizontal line, and the point estimate is given by a square whose height is inversely proportional to the standard error of the estimate. The summary odds ratio, if requested, is drawn as a diamond with horizontal limits at the confidence limits and width inversely proportional to its standard error.

Usage

meta.MH(ntrt, nctrl, ptrt, pctrl, conf.level=0.95,
        names=NULL, data=NULL, subset=NULL, na.action = na.fail,statistic="OR")
## S3 method for class 'meta.MH'
summary(object, conf.level=NULL, ...)
## S3 method for class 'meta.MH'
plot(x, summary=TRUE, summlabel="Summary",
             conf.level=NULL, colors=meta.colors(),xlab=NULL, ...)

Arguments

ntrt

Number of subjects in treated/exposed group

nctrl

Number of subjects in control group

ptrt

Number of events in treated/exposed group

pctrl

Number of events in control group

names

names or labels for studies

data

data frame to interpret variables

subset

subset of studies to include

na.action

a function which indicates what should happen when the data contain NAs. Defaults to na.fail.

statistic

"OR" for odds ratio, "RR" for relative risk

x, object

a meta.MH object

summary

Plot the summary odds ratio?

summlabel

Label for the summary odds ratio

conf.level

Coverage for confidence intervals

colors

see meta.colors

xlab

x-axis label, default is based on statistic

...

further arguments to be passed to or from methods.

Value

An object of class meta.MH with print, plot, funnelplot and summary methods.

Note

There are at least two other ways to do a fixed effects meta-analysis of binary data. Peto's method is a computationally simpler approximation to the Mantel-Haenszel approach. It is also possible to weight the individual odds ratios according to their estimated variances. The Mantel-Haenszel method is superior if there are trials with small numbers of events (less than 5 or so in either group)

Author(s)

Thomas Lumley

See Also

plot,par,meta.DSL,funnelplot

Examples

data(catheter)
a <- meta.MH(n.trt, n.ctrl, col.trt, col.ctrl, data=catheter,
             names=Name, subset=c(13,6,5,3,7,12,4,11,1,8,10,2))
a
summary(a)
plot(a)
d <- meta.MH(n.trt, n.ctrl, inf.trt, inf.ctrl, data=catheter,
             names=Name, subset=c(13,6,3,12,4,11,1,14,8,10,2))
d
summary(d)
## plot with par("fg")
plot(d, colors=meta.colors(NULL))

Meta-analysis based on effect estimates

Description

Computes a summary estimate and confidence interval from a collection of treatment effect estimates and standard errors. Allows fixed or random effects, optional quality weights.

Usage

meta.summaries(d, se, method=c("fixed", "random"), weights=NULL,
               logscale=FALSE, names=NULL, data=NULL,
               conf.level=0.95, subset=NULL,na.action=na.fail)
## S3 method for class 'meta.summaries'
summary(object,conf.level=NULL,...)
## S3 method for class 'meta.summaries'
plot(x,summary=TRUE,summlabel="Summary",
                    conf.level=NULL,colors=meta.colors(),
                    xlab=NULL,logscale=NULL,...)

Arguments

d

Effect estimates

se

standard errors for d

method

Standard errors and default weights from fixed or random-effects?

weights

Optional weights (eg quality weights)

logscale

Effect is on a log scale? (for plotting)

names

labels for the separate studies

data

optional data frame to find variables in

conf.level

level for confidence intervals

subset

Which studies to use

na.action

a function which indicates what should happen when the data contain NAs. Defaults to na.fail.

x, object

a meta.summaries object

summary

Plot the summary odds ratio?

summlabel

Label for the summary odds ratio

colors

see meta.colors

xlab

label for the effect estimate axis.

...

further arguments to be passed to or from methods.

Details

The summary estimate is a weighted average. If weights are specified they are used, otherwise the reciprocal of the estimated variance is used.

The estimated variance is the square of se for a fixed analysis. For a random analysis a heterogeneity variance is estimated and added.

The variance of a weighted average is a weighted average of the estimated variances using the squares of the weights. This is the square of the summary standard error.

With the default weights these are the standard fixed and random effects calculations.

Value

An object of class meta.summaries, which has print,plot,summary and funnelplot methods.

Author(s)

Thomas Lumley

See Also

meta.DSL, meta.MH, funnelplot, metaplot

Examples

data(catheter)
b <- meta.DSL(n.trt, n.ctrl, col.trt, col.ctrl, data=catheter,
              names=Name, subset=c(13,6,5,3,12,4,11,1,8,10,2))
d <- meta.summaries(b$logs, b$selogs, names=b$names,
                    method="random", logscale=TRUE)

Meta-analysis plot (forest plot)

Description

Plot confidence intervals with boxes indicating the sample size/precision and optionally a diamond indicating a summary confidence interval. This function is usually called by plot methods for meta-analysis objects.

Usage

metaplot(mn, se, nn=NULL, labels=NULL, conf.level=0.95,
         xlab="Odds ratio", ylab="Study Reference",xlim=NULL,
         summn=NULL, sumse=NULL, sumnn=NULL, summlabel="Summary",
         logeffect=FALSE, lwd=2, boxsize=1,
         zero=as.numeric(logeffect), colors=meta.colors(),
         xaxt="s", logticks=TRUE,  ...)

Arguments

mn

point estimates from studies

se

standard errors of mn

nn

precision: box ares is proportional to this. 1/se^2 is the default

labels

labels for each interval

conf.level

Confidence level for confidence intervals

xlab

label for the point estimate axis

ylab

label for the axis indexing the different studies

xlim

the range for the x axis.

summn

summary estimate

sumse

standard error of summary estimate

sumnn

precision of summary estimate

summlabel

label for summary estimate

logeffect

TRUE to display on a log scale

lwd

line width

boxsize

Scale factor for box size

zero

"Null" effect value

xaxt

use "n" for no x-axis (to add a customised one)

logticks

if TRUE and logscale, have tick values approximately equally spaced on a log scale

.

colors

see meta.colors

...

Other graphical parameters

Value

This function is used for its side-effect.

See Also

forestplot for more flexible plots

plot.meta.DSL, plot.meta.MH, plot.meta.summaries

Examples

data(catheter)
a <- meta.MH(n.trt, n.ctrl, col.trt, col.ctrl, data=catheter,
             names=Name, subset=c(13,6,5,3,7,12,4,11,1,8,10,2))
metaplot(a$logOR, a$selogOR, nn=a$selogOR^-2, a$names,
         summn=a$logMH, sumse=a$selogMH, sumnn=a$selogMH^-2,
         logeffect=TRUE)
metaplot(a$logOR, a$selogOR, nn=a$selogOR^-2, a$names,
         summn=a$logMH, sumse=a$selogMH, sumnn=a$selogMH^-2,
         logeffect=TRUE,logticks=FALSE)
## angry fruit salad
metaplot(a$logOR, a$selogOR, nn=a$selogOR^-2, a$names,
         summn=a$logMH, sumse=a$selogMH, sumnn=a$selogMH^-2,
         logeffect=TRUE, colors=meta.colors(box="magenta",
             lines="blue", zero="red", summary="orange",
             text="forestgreen"))