plotMetaAnalysisForest: Create a forest plot

Description Usage Arguments Details Value Examples

View source: R/MetaAnalysis.R

Description

Creates a forest plot of effect size estimates, including the summary estimate.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
plotMetaAnalysisForest(
  data,
  labels,
  estimate,
  xLabel = "Relative risk",
  summaryLabel = "Summary",
  limits = c(0.1, 10),
  alpha = 0.05,
  fileName = NULL
)

Arguments

data

A data frame containing either normal, skew-normal, custom parametric, or grid likelihood data. One row per database.

labels

A vector of labels for the data sources.

estimate

The meta-analytic estimate as created using either ['computeFixedEffectMetaAnalysis()] or [computeBayesianMetaAnalysis()'] function.

xLabel

The label on the x-axis: the name of the effect estimate.

summaryLabel

The label for the meta-analytic estimate.

limits

The limits of the effect size axis.

alpha

The alpha (expected type I error).

fileName

Name of the file where the plot should be saved, for example 'plot.png'. See the function ggplot2::ggsave ifor supported file formats.

Details

Creates a forest plot of effect size estimates, including a meta-analysis estimate.

Value

A Ggplot object. Use the ggplot2::ggsave function to save to file.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Simulate some data for this example:
populations <- simulatePopulations()
labels <- paste("Data site", LETTERS[1:length(populations)])

# Fit a Cox regression at each data site, and approximate likelihood function:
fitModelInDatabase <- function(population) {
  cyclopsData <- Cyclops::createCyclopsData(Surv(time, y) ~ x + strata(stratumId),
                                            data = population,
                                            modelType = "cox")
  cyclopsFit <- Cyclops::fitCyclopsModel(cyclopsData)
  approximation <- approximateLikelihood(cyclopsFit, parameter = "x", approximation = "custom")
  return(approximation)
}
approximations <- lapply(populations, fitModelInDatabase)
approximations <- do.call("rbind", approximations)

# At study coordinating center, perform meta-analysis using per-site approximations:
estimate <- computeBayesianMetaAnalysis(approximations)
plotMetaAnalysisForest(approximations, labels, estimate)

# (Estimates in this example will vary due to the random simulation)

OHDSI/EvidenceSynthesis documentation built on Feb. 14, 2021, 9:15 p.m.