Introduction to fixes

Yosuke Abe

May 02, 2026

Introduction

The fixes package provides an easy-to-use toolkit for creating, estimating, and visualizing event study models using fixed effects regression. With fixes, you can automatically generate lead and lag dummy variables, flexibly estimate fixed effects event study regressions, and visualize the results with ggplot2 using a single pipeline.

This vignette introduces the core functions of the package through simple examples, including recent updates such as multiple confidence interval support and improved plotting options.

Installation

Install the released version from CRAN:

install.packages("fixes")

Or with pak (recommended for fast install):

pak::pak("fixes")

To install the latest development version from GitHub:

pak::pak("yo5uke/fixes")

or

devtools::install_github("yo5uke/fixes")

Minimal Example

Below is a basic example using the built-in fixest::base_did dataset, running an event study, and visualizing the results.

# Load example data
df <- fixest::base_did

# Run the event study (supports multiple confidence levels)
event_study <- run_es(
  data       = df,
  outcome    = y,
  treatment  = treat,
  time       = period,
  timing     = 5,  # Treatment occurs at period 5
  fe         = ~ id + period,
  cluster    = ~ id,
  baseline   = -1,
  interval   = 1,
  lead_range = 3,
  lag_range  = 3,
  conf.level = c(0.90, 0.95, 0.99)  # Multiple CIs supported!
)

# View results
head(event_study)
#> Event Study Result (fixes)
#>   N: 1080  | Units: NA  | Treated units: 1080  | Never-treated: NA 
#>   FE: id + period
#>   VCOV: HC1  | Cluster: id 
#>   Method: classic  | lead_range: 3  lag_range: 3  baseline: -1

Visualizing Event Study Results

The fixes package provides plot_es() for flexible visualization. You can easily switch between ribbon-style or error bar CIs, select the displayed CI level, and customize appearance.

# Basic plot (default: ribbon, 95% CI)
plot_es(event_study)

# Plot with error bars and 99% CI
plot_es(event_study, type = "errorbar", ci_level = 0.99)

# Customize further with ggplot2
plot_es(event_study, type = "errorbar", ci_level = 0.9, theme_style = "classic") +
  scale_x_continuous(breaks = seq(-3, 3, by = 1)) +
  ggtitle("Event Study with 90% CI and Classic Theme")

Staggered Treatment with sunab

For staggered adoption designs where treatment timing varies across units, you can use method = "sunab" to implement the Sun & Abraham (2021) estimator, which is robust to heterogeneous treatment effects.

# Example with fixest::base_stagg data
df_stagg <- fixest::base_stagg

event_study_sunab <- run_es(
  data       = df_stagg,
  outcome    = y,
  treatment  = treated,
  time       = year,
  timing     = year_treated,
  fe         = ~ id + year,
  staggered  = TRUE,
  method     = "sunab",  # Use Sun & Abraham decomposition
  lead_range = 3,
  lag_range  = 3,
  cluster    = ~ id
)

head(event_study_sunab)
#> Event Study Result (fixes)
#>   N: 950  | Units: NA  | Treated units: 950  | Never-treated: NA 
#>   FE: id + year
#>   VCOV: HC1  | Cluster: id 
#>   Method: SUNAB (staggered-safe)
# Visualize sunab results
plot_es(event_study_sunab) +
  ggtitle("Staggered Adoption Event Study (Sun & Abraham 2021)")

New in v0.7.1: The baseline parameter now applies to both classic and sunab methods, and the baseline period is included in results with zero estimates for consistent visualization.

Package Highlights

Conclusion

The fixes package streamlines event study estimation and visualization for panel data researchers. With a minimal API, multiple CI support, and robust visualization, it accelerates the workflow for dynamic treatment effect analysis.

For further details and full argument documentation, see:

?run_es
?plot_es

Happy analyzing!🥂