| Type: | Package |
| Title: | Tools for Creating and Visualizing Fixed-Effects Event Study Models |
| Version: | 0.7.2 |
| Date: | 2026-05-02 |
| Description: | Provides functions for creating, analyzing, and visualizing event study models using fixed-effects regression. Supports staggered adoption, multiple confidence intervals, flexible clustering, and panel/time transformations in a simple workflow. |
| Depends: | R (≥ 4.1.0) |
| Imports: | dplyr, ggplot2, fixest, broom, tibble, rlang |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Suggests: | knitr, rmarkdown, haven, testthat, plotly, tidyr |
| VignetteBuilder: | knitr |
| URL: | https://github.com/yo5uke/fixes |
| BugReports: | https://github.com/yo5uke/fixes/issues |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-05-02 01:02:08 UTC; yo5uk |
| Author: | Yosuke Abe [aut, cre] |
| Maintainer: | Yosuke Abe <yosuke.abe0507@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-05-02 18:40:14 UTC |
Autoplot for event-study results
Description
S3 method that plots an es_result (from run_es()).
It forwards arguments to plot_es.
Usage
## S3 method for class 'es_result'
autoplot(object, ci_level = 0.95, type = "ribbon", ...)
Arguments
object |
An |
ci_level |
Confidence level (numeric, e.g., 0.95). Passed to |
type |
Plot type: |
... |
Additional arguments forwarded to |
Value
A ggplot2 ggplot object.
Examples
# res <- run_es(...)
# ggplot2::autoplot(res, ci_level = 0.95, type = "ribbon")
Plot event-study results with ribbons or error bars
Description
Plot event-study results with ribbons or error bars
Usage
plot_es(
data,
ci_level = 0.95,
type = "ribbon",
vline_val = 0,
vline_color = "#000",
hline_val = 0,
hline_color = "#000",
linewidth = 1,
pointsize = 2,
alpha = 0.2,
barwidth = 0.2,
color = "#B25D91FF",
fill = "#B25D91FF",
theme_style = "bw"
)
Arguments
data |
An object of class |
ci_level |
Confidence level to display (e.g., 0.95). |
type |
One of |
vline_val, hline_val |
Numeric locations for vertical/horizontal reference lines (default 0). |
vline_color, hline_color |
Colors for reference lines. |
linewidth, pointsize, alpha, barwidth |
Styling parameters for lines/points/bands/bars. |
color, fill |
Optional, override line/point color and ribbon fill. |
theme_style |
One of |
Value
A ggplot object.
Examples
# Assuming `res <- run_es(...)`
# p <- plot_es(res, ci_level = 0.95, type = "ribbon")
# print(p)
Interactive event-study plot with hover details
Description
Creates an interactive plotly visualization of event study results with hover-over displays showing coefficients, confidence intervals, and other details.
Usage
plot_es_interactive(
data,
ci_level = 0.95,
vline_val = 0,
hline_val = 0,
vline_color = "#000",
hline_color = "#000",
color = "#B25D91FF",
fill = "#B25D91FF",
alpha = 0.2,
linewidth = 2,
markersize = 8,
show_ribbon = TRUE,
height = NULL,
width = NULL
)
Arguments
data |
An object of class |
ci_level |
Confidence level to display (e.g., 0.95). Default is 0.95. |
vline_val |
Numeric location for vertical reference line (default 0). |
hline_val |
Numeric location for horizontal reference line (default 0). |
vline_color |
Color for vertical reference line (default "#000"). |
hline_color |
Color for horizontal reference line (default "#000"). |
color |
Point and line color (default "#B25D91FF"). |
fill |
Ribbon/band fill color (default "#B25D91FF"). |
alpha |
Ribbon transparency (default 0.2). |
linewidth |
Line width (default 2). |
markersize |
Marker size (default 8). |
show_ribbon |
Logical; if TRUE, shows confidence interval as a ribbon band (default TRUE). |
height |
Plot height in pixels (default NULL for auto). |
width |
Plot width in pixels (default NULL for auto). |
Details
The hover tooltip displays:
Relative time to treatment
Point estimate (coefficient)
Confidence interval bounds
Standard error
P-value
Value
A plotly object that can be displayed interactively.
Examples
## Not run:
# Assuming res <- run_es(...)
plot_es_interactive(res)
plot_es_interactive(res, ci_level = 0.99, show_ribbon = FALSE)
## End(Not run)
Event Study Estimation for Panel Data
Description
Runs an event study regression on panel data, supporting both classic (universal timing) and staggered (unit-varying timing via sunab).
The function builds the design (lead/lag factor or sunab), estimates with fixest, and returns a tidy table with metadata.
Usage
run_es(
data,
outcome,
treatment,
time,
timing,
fe = NULL,
lead_range = NULL,
lag_range = NULL,
covariates = NULL,
cluster = NULL,
weights = NULL,
baseline = -1L,
interval = 1,
time_transform = FALSE,
unit = NULL,
staggered = FALSE,
method = c("classic", "sunab"),
conf.level = 0.95,
vcov = "HC1",
vcov_args = list()
)
Arguments
data |
A data.frame containing panel data. |
outcome |
Unquoted outcome (name or expression, e.g., |
treatment |
Unquoted treatment indicator (0/1 or logical). Used only when |
time |
Unquoted time variable (numeric or Date). |
timing |
For |
fe |
One-sided fixed-effects formula, e.g., |
lead_range, lag_range |
Integers for pre/post windows. If |
covariates |
One-sided formula of additional controls, e.g., |
cluster |
Cluster specification (one-sided formula like |
weights |
Observation weights (a name/one-sided formula or a numeric vector of length |
baseline |
Integer baseline period (default |
interval |
Numeric spacing of the time variable (default |
time_transform |
Logical; if |
unit |
Unit identifier variable (required when |
staggered |
Logical; if |
method |
Either |
conf.level |
Numeric vector of confidence levels (default |
vcov |
VCOV type passed to |
vcov_args |
List of additional arguments forwarded to |
Value
A data.frame of class "es_result" with columns:
-
term,estimate,std.error,statistic,p.value -
conf_low_XX,conf_high_XX(for each requestedconf.level) -
relative_time(integer; 0 = event),is_baseline(logical; marks the reference period)
Attributes include: lead_range, lag_range, baseline, interval, call, model_formula, conf.level,
N, N_units, N_treated, N_nevertreated, fe, vcov_type, cluster_vars, staggered, sunab_used.
Key Features
One-step event study: specify outcome, treatment, time, timing, fixed effects, and (optionally) covariates.
Switch between Classic (factor expansion) and Staggered-SAFE (
method = "sunab").Flexible clustering, weights, and VCOV choices (e.g.,
vcov = "HC1" | "HC3" | "CR2" | "iid" ...).Automatic lead/lag window detection and customizable baseline period.
Returns an
"es_result"object compatible withprint()andautoplot().