% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/PsFunctions.R
\name{plotPs}
\alias{plotPs}
\title{Plot the propensity score distribution}
\usage{
plotPs(
  data,
  unfilteredData = NULL,
  scale = "preference",
  type = "density",
  binWidth = 0.05,
  targetLabel = "Target",
  comparatorLabel = "Comparator",
  showCountsLabel = FALSE,
  showAucLabel = FALSE,
  showEquipoiseLabel = FALSE,
  equipoiseBounds = c(0.3, 0.7),
  unitOfAnalysis = "subjects",
  title = NULL,
  fileName = NULL
)
}
\arguments{
\item{data}{A data frame with at least the two columns described below}

\item{unfilteredData}{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 \code{data}.}

\item{scale}{The scale of the graph. Two scales are supported: \code{scale = 'propensity'} or \code{scale = 'preference'}. The preference score scale is
defined by Walker et al (2013).}

\item{type}{Type of plot. Four possible values: \code{type = 'density'}  \code{type = 'histogram'}, \code{type = 'histogramCount'},
or \code{type = 'histogramProportion'}. \code{'histogram'} defaults to \code{'histogramCount'}.}

\item{binWidth}{For histograms, the width of the bins}

\item{targetLabel}{A label to us for the target cohort.}

\item{comparatorLabel}{A label to us for the comparator cohort.}

\item{showCountsLabel}{Show subject counts?}

\item{showAucLabel}{Show the AUC?}

\item{showEquipoiseLabel}{Show the percentage of the population in equipoise?}

\item{equipoiseBounds}{The bounds on the preference score to determine whether a subject is in
equipoise.}

\item{unitOfAnalysis}{The unit of analysis in the input data. Defaults to 'subjects'.}

\item{title}{Optional: the main title for the plot.}

\item{fileName}{Name of the file where the plot should be saved, for example 'plot.png'.
See the function \code{\link[ggplot2:ggsave]{ggplot2::ggsave()}} for supported file formats.}
}
\value{
A ggplot object. Use the \code{\link[ggplot2:ggsave]{ggplot2::ggsave()}} function to save to file in a different
format.
}
\description{
Plots the propensity (or preference) score distribution.
}
\details{
The data frame should have a least the following two columns:
\itemize{
\item treatment (integer): Column indicating whether the person is in the target (1) or comparator (0) group
\item propensityScore (numeric): Propensity score
}
}
\examples{
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)

}
\references{
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
}
