The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Package {fixes}


Type: Package
Title: Tools for Creating and Visualizing Fixed-Effects Event Study Models
Version: 0.8.1
Date: 2026-05-10
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, Rcpp
License: MIT + file LICENSE
Encoding: UTF-8
Suggests: knitr, rmarkdown, haven, testthat, plotly, tidyr, did, didimputation
VignetteBuilder: knitr
URL: https://github.com/yo5uke/fixes
BugReports: https://github.com/yo5uke/fixes/issues
Config/roxygen2/version: 8.0.0
RoxygenNote: 7.3.3
LinkingTo: Rcpp
NeedsCompilation: yes
Packaged: 2026-05-10 03:57:23 UTC; yo5uk
Author: Yosuke Abe [aut, cre]
Maintainer: Yosuke Abe <yosuke.abe0507@gmail.com>
Repository: CRAN
Date/Publication: 2026-05-10 05:30:02 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 es_result returned by run_es().

ci_level

Confidence level (numeric, e.g., 0.95). Passed to plot_es().

type

Plot type: "ribbon" (default) or "errorbar". Passed to plot_es().

...

Additional arguments forwarded to plot_es.

Value

A ggplot2 ggplot object.

Examples

# res <- run_es(...)
# ggplot2::autoplot(res, ci_level = 0.95, type = "ribbon")


Plot the ATT(g,t) matrix from a Callaway-Sant'Anna event study

Description

Visualises the full cohort-by-period ATT(g,t) matrix stored in the att_gt attribute of an es_result object produced by run_es(estimator = "cs"). Two display styles are available:

Both types draw a vertical dashed line at t = g (treatment onset) for each cohort.

Usage

plot_att_gt(
  x,
  type = c("heatmap", "facet"),
  ci_level = 0.95,
  zero_line = TRUE,
  theme = c("bw", "minimal", "classic"),
  color = "#B25D91FF",
  fill = "#B25D91FF",
  alpha = 0.2
)

## S3 method for class 'att_gt_result'
autoplot(object, ...)

Arguments

x

An es_result object returned by run_es(estimator = "cs"), or an att_gt_result data frame produced by extracting attr(x, "att_gt") and giving it class "att_gt_result".

type

"heatmap" (default) or "facet".

ci_level

Confidence level for pointwise intervals (default 0.95).

zero_line

Logical; draw a horizontal reference line at zero in the "facet" display (default TRUE).

theme

One of "bw" (default), "minimal", or "classic".

color

Line and point colour used in the "facet" display (default "#B25D91FF", matching plot_es).

fill

Ribbon fill colour in the "facet" display (default "#B25D91FF").

alpha

Ribbon transparency in the "facet" display (default 0.2).

object

An att_gt_result object (extracted from an es_result via attr(result, "att_gt")).

...

Passed to plot_att_gt.

Value

A ggplot object.

Bootstrap annotation

When attr(x, "bootstrap") is present (i.e., run_es() was called with bootstrap = TRUE), both plot types add simultaneous inference overlays sourced from the (g,t)-level bootstrap object.

See Also

plot_es, run_es

Examples

## Not run: 
cs_result <- run_es(data = mydata, outcome = y, time = year,
                    timing = g, unit = id, fe = ~id + year,
                    staggered = TRUE, estimator = "cs")
plot_att_gt(cs_result)
plot_att_gt(cs_result, type = "facet")

## End(Not run)


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",
  show_simultaneous = FALSE
)

Arguments

data

An object of class es_result returned by run_es().

ci_level

Confidence level to display (e.g., 0.95).

type

One of "ribbon" (default) or "errorbar".

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 "bw", "minimal", or "classic" for ggplot theme.

show_simultaneous

Logical; if TRUE, overlays the simultaneous bootstrap CI (lighter band, alpha 0.15) alongside the standard pointwise CI (alpha 0.3), with a legend distinguishing the two bands. Requires bootstrap = TRUE in the originating run_es() call. Default FALSE.

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,
  show_simultaneous = FALSE,
  height = NULL,
  width = NULL
)

Arguments

data

An object of class es_result returned by run_es().

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).

show_simultaneous

Logical; if TRUE, overlays a second (lighter) ribbon for the simultaneous bootstrap CI and extends the hover tooltip with simultaneous CI bounds. Requires bootstrap = TRUE in the originating run_es() call. Default FALSE.

height

Plot height in pixels (default NULL for auto).

width

Plot width in pixels (default NULL for auto).

Details

The hover tooltip displays:

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)
plot_es_interactive(res, show_simultaneous = TRUE)

## 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 = NULL,
  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"),
  estimator = c("twfe", "cs", "sa", "bjs"),
  control_group = c("nevertreated", "notyettreated"),
  anticipation = 0L,
  conf.level = 0.95,
  vcov = "HC1",
  vcov_args = list(),
  bootstrap = FALSE,
  B = 999L,
  alpha = 0.05,
  boot_seed = NULL
)

Arguments

data

A data.frame containing panel data.

outcome

Unquoted outcome (name or expression, e.g., log(y)).

treatment

Unquoted treatment indicator (0/1 or logical). Used only when method = "classic".

time

Unquoted time variable (numeric or Date).

timing

For classic: a numeric/Date (universal) or a variable (unquoted) if staggered = TRUE. For sunab: an unquoted variable with adoption time. For estimator = "cs": unquoted column giving each unit's first treatment period (NA = never treated).

fe

One-sided fixed-effects formula, e.g., ~ id + year. Can be NULL for no fixed effects. Ignored when estimator = "cs".

lead_range, lag_range

Integers for pre/post windows. If NULL, determined automatically.

covariates

One-sided formula of additional controls, e.g., ~ x1 + log(x2).

cluster

Cluster specification (one-sided formula like ~ id + year, a single character column name, or a vector of length nrow(data)).

weights

Observation weights (a name/one-sided formula or a numeric vector of length nrow(data)).

baseline

Integer baseline period (default -1); reference period excluded from results for both "classic" and "sunab" methods.

interval

Numeric spacing of the time variable (default 1; ignored internally for Dates).

time_transform

Logical; if TRUE, creates consecutive integer time within unit.

unit

Unit identifier variable (required when estimator = "cs" or time_transform = TRUE); also used for metadata when supplied.

staggered

Logical; if TRUE, timing is a variable (classic) or is used by sunab.

method

Either "classic" or "sunab" (default: "classic").

estimator

Estimation strategy: "twfe" (default, existing fixest-based paths), "cs" for the Callaway-Sant'Anna (2021) group-time ATT estimator, or "sa" for the Sun-Abraham (2021) interaction-weighted estimator.

control_group

For estimator = "cs": comparison group, either "nevertreated" (default) or "notyettreated".

anticipation

For estimator = "cs": number of anticipation periods before treatment (non-negative integer, default 0L).

conf.level

Numeric vector of confidence levels (default 0.95).

vcov

VCOV type passed to fixest::vcov() or used via broom::tidy(vcov = ...). Default "HC1".

vcov_args

List of additional arguments forwarded to fixest::vcov().

bootstrap

Logical; if TRUE and estimator = "cs", compute simultaneous confidence bands via the multiplier bootstrap (Algorithm 1, Callaway and Sant'Anna 2021). Adds conf_low_sim and conf_high_sim columns to the result and stores the full (g,t)-level bootstrap object as attr(result, "bootstrap"). Default FALSE.

B

Integer number of bootstrap draws (default 999). Used only when bootstrap = TRUE and estimator = "cs".

alpha

Significance level for the simultaneous band (default 0.05). Note: this is independent of conf.level, which governs the pointwise delta-method CIs.

boot_seed

Integer seed for the bootstrap RNG; NULL (default) does not set a seed. Pass an integer for reproducible results.

Value

A data.frame of class "es_result" with columns:

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

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.