Skip to contents

Creates a density plot comparing the distribution of propensity scores for treated and control units. Useful for assessing the overlap (common support) assumption required by many causal inference estimators.

Usage

plot_pscore_overlap(
  pscore,
  treatment,
  trim_bounds = NULL,
  title = "Propensity Score Overlap"
)

Arguments

pscore

Numeric vector of estimated propensity scores (values between 0 and 1).

treatment

Binary vector (0/1 or logical) indicating treatment assignment. Must be the same length as pscore.

trim_bounds

Numeric vector of length 2 specifying lower and upper bounds for trimming (e.g., c(0.1, 0.9)). If provided, vertical lines are drawn at these thresholds and observations outside the bounds are shaded. Default is NULL (no trimming lines).

title

Character string. Plot title. Default is "Propensity Score Overlap".

Value

A ggplot2 object.

Examples

if (FALSE) { # \dontrun{
# Simulate data
set.seed(42)
n <- 500
x <- rnorm(n)
treat <- rbinom(n, 1, plogis(0.5 * x))
ps <- plogis(0.5 * x + rnorm(n, 0, 0.1))

plot_pscore_overlap(pscore = ps, treatment = treat)
plot_pscore_overlap(pscore = ps, treatment = treat,
                    trim_bounds = c(0.1, 0.9))
} # }