Plots the propensity (or preference) score distribution.
plotPs(
data,
unfilteredData = NULL,
scale = "preference",
type = "density",
binWidth = 0.05,
targetLabel = "Target",
comparatorLabel = "Comparator",
showCountsLabel = FALSE,
showAucLabel = FALSE,
showEquiposeLabel = FALSE,
equipoiseBounds = c(0.3, 0.7),
unitOfAnalysis = "subjects",
title = NULL,
fileName = NULL
)
A data frame with at least the two columns described below
To be used when computing preference scores on data from which subjects
have already been removed, e.g. through trimming and/or matching. This data
frame should have the same structure as data
.
The scale of the graph. Two scales are supported: scale = 'propensity'
or scale = 'preference'
. The preference score scale is
defined by Walker et al (2013).
Type of plot. Four possible values: type = 'density'
type = 'histogram'
, type = 'histogramCount'
,
or type = 'histogramProportion'
. 'histogram'
defaults to 'histogramCount'
.
For histograms, the width of the bins
A label to us for the target cohort.
A label to us for the comparator cohort.
Show subject counts?
Show the AUC?
Show the percentage of the population in equipoise?
The bounds on the preference score to determine whether a subject is in equipoise.
The unit of analysis in the input data. Defaults to 'subjects'.
Optional: the main title for the plot.
Name of the file where the plot should be saved, for example 'plot.png'.
See the function ggplot2::ggsave()
for supported file formats.
A ggplot object. Use the ggplot2::ggsave()
function to save to file in a different
format.
The data frame should have a least the following two columns:
treatment (integer): Column indicating whether the person is in the target (1) or comparator (0) group
propensityScore (numeric): Propensity score
Walker AM, Patrick AR, Lauer MS, Hornbrook MC, Marin MG, Platt R, Roger VL, Stang P, and Schneeweiss S. (2013) A tool for assessing the feasibility of comparative effectiveness research, Comparative Effective Research, 3, 11-20
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, ]
plotPs(data)