plot.scm_placebo: Plot SCM In-Space Placebo Results

View source: R/plot.R

plot.scm_placeboR Documentation

Plot SCM In-Space Placebo Results

Description

Visualizes the placebo study returned by mspe_ratio_pval(), following Abadie, Diamond & Hainmueller (2010, Section 3.4).

Usage

## S3 method for class 'scm_placebo'
plot(
  x,
  type = c("gaps", "ratios"),
  mspe_prune = NULL,
  colors = NULL,
  labels = NULL,
  linetypes = NULL,
  vline = list(),
  vline_offset = .VLINE_OFFSET_DEFAULT,
  hline = list(),
  ...
)

Arguments

x

A scm_placebo object from mspe_ratio_pval().

type

One of "gaps" (ADH 2010, Figures 4-7) or "ratios" (ADH 2010, Figure 8).

mspe_prune

Exclude placebo units whose pre-treatment MSPE exceeds mspe_prune times the treated unit's. NULL (default) reuses the cutoff mspe_ratio_pval() computed the p-value under, so the picture and the test describe the same set of placebo runs; Inf keeps every run whatever the test did. A rule stated on the RMSPE scale, such as tidysynth's "2 times the treated unit's pre-period RMSPE", corresponds to the squared multiple (mspe_prune = 4).

colors

A named vector overriding series colors, e.g. c(treated = "black"). Valid keys: "treated", "placebo".

labels

A named vector overriding the legend text of individual series, e.g. c(treated = "California"). Valid keys: "treated", "placebo". Series not mentioned keep their default label; colors and labels address series by the same keys, independent of the displayed legend text.

linetypes

Only for type = "gaps": a named vector overriding the line type of individual series, e.g. c(placebo = "dotted"). Valid keys: "treated", "placebo" (both default to "solid"). Values are ggplot2 line type names ("solid", "dashed", "dotted", "dotdash", "longdash", "twodash", "blank") or the equivalent integer codes 0:6. Series are addressed by the same keys as colors and labels. Ignored for type = "ratios" (points, not lines).

vline

Only for type = "gaps": aesthetic overrides for the vertical treatment-time line, as a list passed to ggplot2::geom_vline(). NULL or FALSE hides the line entirely. The list may also carry an xintercept element giving one or more absolute positions on the time axis, replacing the default treatment-time position.

vline_offset

Only for type = "gaps": where to draw the vertical treatment line, in periods relative to the first post-treatment period. The default -1 puts the line on the last pre-treatment period; 0 moves it onto the first post-treatment period, and fractional values interpolate between adjacent observed times. Cannot be combined with an xintercept element in vline.

hline

Only for type = "gaps": aesthetic overrides for the horizontal zero line, as a list passed to ggplot2::geom_hline(). NULL or FALSE hides the line entirely.

...

Ignored.

Details

type = "gaps" overlays the treated unit's gap path (treated minus synthetic control) on the placebo gap paths obtained by reassigning the intervention to each donor unit (ADH 2010, Figure 4). Placebo units whose synthetic control fits poorly before treatment carry no information about the rarity of a large post-treatment gap, so ADH exclude units whose pre-treatment MSPE exceeds a multiple of the treated unit's: 20, 5, and 2 in their Figures 5-7 (mspe_prune).

type = "ratios" shows the statistic behind the two-sided permutation p-value, one point per unit (ADH 2010, Figure 8): the post/pre-treatment MSPE ratio, or the post-treatment MSPE where the test was run with statistic = "post_mspe". The ratio needs no pruning cutoff by construction, which is why mspe_ratio_pval() leaves mspe_prune at Inf; where the test did prune, the same runs are dropped here so that the points and the p-value in the subtitle describe one set of placebo runs.

Value

A ggplot2 plot object.

See Also

mspe_ratio_pval()

Examples

set.seed(1)
panel <- expand.grid(unit = 1:10, year = 1:20)
panel$treated <- as.integer(panel$unit == 5 & panel$year > 15)
panel$gdp <- panel$unit + 0.5 * panel$year +
  rnorm(nrow(panel)) + 3 * panel$treated
fit <- scm_fit(gdp ~ treated | unit + year, data = panel, method = "scm")
placebo <- mspe_ratio_pval(fit)


# Treated gap overlaid on the donor-pool placebo gaps (ADH 2010, Fig. 4)
plot(placebo, type = "gaps")

# Prune poorly fitting placebos and relabel the legend
plot(placebo, type = "gaps", mspe_prune = 5,
     labels = c(treated = "Unit 5"))

# Set the line type of the placebo paths off against the treated one
plot(placebo, type = "gaps", linetypes = c(placebo = "dotted"))

# Move the treatment line onto the first post-treatment period
plot(placebo, type = "gaps", vline_offset = 0)

# Post/pre-treatment MSPE ratios (ADH 2010, Fig. 8)
plot(placebo, type = "ratios")


coresynth documentation built on Oct. 11, 2026, 5:07 p.m.