plot.fdid: Plot Results from FDID Analysis

View source: R/plot.R

plot.fdidR Documentation

Plot Results from FDID Analysis

Description

Provides visualisations for FDID results, including raw means, dynamic effects, and propensity-score overlap. The comparison plot of multiple methods has been removed; use plot.fdid_list() for that.

Usage

## S3 method for class 'fdid'
plot(
  x,
  type = c("raw", "dynamic", "overlap"),
  connected = FALSE,
  ci = TRUE,
  shade_periods = x$tr_period,
  alpha_shade = 0.2,
  palette = "Set2",
  group_labels = c("Group 0", "Group 1"),
  xlab = NULL,
  ylab = NULL,
  main = NULL,
  ylim = NULL,
  ...
)

Arguments

x

An fdid object.

type

One of "raw", "dynamic", or "overlap".

connected

Logical; if TRUE, connects points with lines in the "raw" and "dynamic" plots. Default is FALSE.

ci

Logical; if TRUE, draw 95% CIs when available. Default is TRUE.

shade_periods

Shaded intervals on the time axis. Default uses x$tr_period, i.e. event periods. Set to NULL to remove shaded area.

alpha_shade

Transparency for shading the treatment period.

palette

A palette name from RColorBrewer. Default "Set2".

group_labels

Labels for the two groups.

xlab, ylab, main

Axis labels and main title.

ylim

Y-axis limits. Default NULL (computed automatically).

...

Additional graphics parameters.

Value

Produces a plot; invisibly returns NULL.

Author(s)

Rivka Lipkovitz, Enhan Liu

Examples


data(fdid)
mortality$uniqueid <- paste(mortality$provid, mortality$countyid, sep = "-")
mortality$G <- ifelse(mortality$pczupu >= median(mortality$pczupu, na.rm = TRUE), 1, 0)
s <- fdid_prepare(
  data = mortality, Y_label = "mortality",
  X_labels = c("avggrain", "lnpop"),
  G_label = "G", unit_label = "uniqueid", time_label = "year"
)
result <- fdid(s, tr_period = 1958:1961, ref_period = 1957)
plot(result, type = "raw")
plot(result, type = "dynamic")


fdid documentation built on March 23, 2026, 5:07 p.m.