plotCovariateBalances: Plot covariate balances

Description Usage Arguments Details Value Examples

View source: R/CohortMethod.R

Description

plotCovariateBalances plots the covariate balance before and after matching for multiple data sources.

Usage

1
2
3
4
5
6
7
8
plotCovariateBalances(
  balances,
  labels,
  threshold = 0,
  beforeLabel = "Before matching",
  afterLabel = "After matching",
  fileName = NULL
)

Arguments

balances

A list of covariate balance objects as created using the computeCovariateBalance function in the CohortMethod package. Each balance object is expected to be a data.frame with at least these two columns: beforeMatchingStdDiff and afterMatchingStdDiff.

labels

A vector containing the labels for the various sources.

threshold

Show a threshold value for the standardized difference.

beforeLabel

Label for before matching / stratification / trimming.

afterLabel

Label for after matching / stratification / trimming.

fileName

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

Details

Creates a plot showing the covariate balance before and after matching. Balance distributions are displayed as box plots combined with scatterplots.

Value

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

Examples

1
2
3
4
5
6
7
8
9
# Some example data:
balance1 <- data.frame(beforeMatchingStdDiff = rnorm(1000, 0.1, 0.1),
                       afterMatchingStdDiff = rnorm(1000, 0.0, 0.01))
balance2 <- data.frame(beforeMatchingStdDiff = rnorm(1000, 0.2, 0.1),
                       afterMatchingStdDiff = rnorm(1000, 0.0, 0.05))
balance3 <- data.frame(beforeMatchingStdDiff = rnorm(1000, 0.0, 0.1),
                       afterMatchingStdDiff = rnorm(1000, 0.0, 0.03))
plotCovariateBalances(balances = list(balance1, balance2, balance3),
                      labels = c("Site A", "Site B", "Site C"))                     

OHDSI/EvidenceSynthesis documentation built on July 24, 2020, 10:45 a.m.