plotPreparedPs: Plot the propensity score distribution

Description Usage Arguments Value Examples

View source: R/CohortMethod.R

Description

Plot the propensity score distribution

Usage

1
2
3
4
5
6
7
plotPreparedPs(
  preparedPsPlots,
  labels,
  treatmentLabel = "Target",
  comparatorLabel = "Comparator",
  fileName = NULL
)

Arguments

preparedPsPlots

A list of prepared propensity score data as created by the preparePsPlot function.

labels

A vector containing the labels for the various sources.

treatmentLabel

A label to us for the treated cohort.

comparatorLabel

A label to us for the comparator cohort.

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.

Value

A ggplot object. Use the ggsave function to save to file in a different format.

Examples

1
2
3
4
5
6
7
8
9
treatment <- rep(0:1, each = 100)
propensityScore <- c(rnorm(100, mean = 0.4, sd = 0.25), rnorm(100, mean = 0.6, sd = 0.25))
data <- data.frame(treatment = treatment, propensityScore = propensityScore)
data <- data[data$propensityScore > 0 & data$propensityScore < 1, ]
preparedPlot <- preparePsPlot(data)
# Just reusing the same data three times for demonstration purposes:
preparedPsPlots <- list(preparedPlot, preparedPlot, preparedPlot)
labels <- c("Data site A", "Data site B", "Data site C")
                         

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