SkillAgentSearch skills...

EventStudyInteracts.jl

This package is a Julia replication of the Stata package eventstudyinteract provided by Sun and Abraham (2021).

Install / Use

/learn @xiaobaaaa/EventStudyInteracts.jl
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

EventStudyInteracts.jl

This package is a Julia replication of the Stata package eventstudyinteract provided by Sun and Abraham (2021).

The estimation process is identical to that of eventstudyinteract, and this package used FixedEffectModels.jl to implement the Stata command reghdfe functionality.

As introduced in the Stata package eventstudyinteract provided by Sun and Abraham (2021), the function of this package is:

eventstudyinteract implements the interaction weighted (IW) estimator and constructs pointwise confidence interval for the estimation of dynamic treatment effects. To estimate the dynamic effects of an absorbing treatment, researchers often use two-way fixed effects (TWFE) regressions that include leads and lags of the treatment (event study specification). Units are categorized into different cohorts based on their initial treatment timing. Sun and Abraham (2020) proposes this estimator as an alternative to the TWFE regression in the presence of treatment effects heterogeneous across cohorts. Under treatment effects heterogeneity, the TWFE regression can result in estimates with uninterpretable weights, which can be assessed by the Stata module eventstudyweights. The IW estimator is implemented in three steps. First, estimate the interacted regression with reghdfe, where the interactions are between relative time indicators and cohort indicators. Second, estimate the cohort shares underlying each relative time. Third, take the weighted average of estimates from the first step, with weights set to the estimated cohort shares.

Introduction

  • Julia is faster than Stata, and FixedEffectModels.jl is much faster than reghdfe.

  • I am a beginner in programming and the code is a complete translation of the Stata package eventstudyinteract. I used newbing to help me with programming, and it is very helpful for beginners.

  • I used FixedEffectModels.jl directly for estimation and I am grateful to the author of this package. Other parts of this package, such as reporting of estimation results, also refer to FixedEffectModels.jl.

  • The Stata package eventstudyinteract is very flexible, and one important feature is that it can compare event study estimates for subsamples, i.e. perform heterogeneous estimation. fixest can estimate Sun-Abraham specifications through sunab(...), but I still find the workflow design of the Stata package more user-friendly for these heterogeneous-estimation use cases.

  • This package fully supports the features of FixedEffectModels.jl, such as using GPU for estimation. The syntax of this package is similar to that of FixedEffectModels.jl.

Installation

EventStudyInteracts.jl is registered in the General registry.

The package is currently maintained against:

  • Julia 1.10+
  • FixedEffectModels.jl 1.13
  • Vcov.jl 0.8

You can install it at the REPL with ] add EventStudyInteracts.

For local development in this repository, run julia --project=. -e "using Pkg; Pkg.instantiate()".

For formatted regression tables, pair this package with RegressionTables.jl. The examples below use the current v0.7.x API; recent releases are listed on the official RegressionTables.jl releases page.

Local Validation

Before pushing a maintenance update, use the following local checks:

.\scripts\run_pkg_test.ps1
julia --project=. .\scripts\single_cohort_equivalence.jl

What these two commands cover:

  • scripts/run_pkg_test.ps1 bootstraps a local depot for this repository, rebuilds the local test manifest if needed, and runs the full Pkg.test() suite.
  • scripts/single_cohort_equivalence.jl generates a synthetic panel with one treated cohort and verifies that eventreg(...) matches a direct FixedEffectModels.reg(...) event-study regression exactly, including period-by-period standard errors and the aggregated ATE(g0:g3).

A change is ready to push to GitHub when all of the following are true:

  • Pkg.test() passes locally.
  • The single-cohort equivalence check reports zero differences.
  • The checked-in Stata reference comparison still passes.
  • README examples and benchmark claims are consistent with the current code.

Maintenance

This repository includes separate maintenance automation in addition to CI:

  • CI runs package tests on main.
  • CompatHelper watches dependency compat updates.
  • TagBot handles tags and releases.
  • Maintenance runs weekly and checks whether FixedEffectModels.jl has a newer upstream release, runs Julia 1.10 tests, runs a Julia stable import smoke test, and writes a maintenance report.
  • The main test suite also includes a RegressionTables.jl smoke test so table output stays visible during dependency upgrades.

The maintenance check compares the nlswork example against the checked-in Stata baseline in reference/nlswork_stata.toml. Any additional *.toml file placed in reference/ is picked up automatically, so you can add reference/boss_reference.toml to compare against your boss's saved results as well.

If you want CompatHelper to open PRs automatically on GitHub, add the repository secret COMPATHELPER_PRIV.

Codex Workflow

This repository is maintained with Codex, using the current GPT-5 coding model together with the local Julia, R, and Stata toolchain on this machine.

The default maintenance workflow is:

  1. Weekly monitoring: Maintenance checks upstream dependency drift, especially FixedEffectModels.jl, and writes a machine-generated report.
  2. Upgrade trigger: when FixedEffectModels.jl or another important dependency changes, Codex updates compat bounds, adapts the package code, and reruns the local validation workflow.
  3. Validation gate: the change is not considered complete until Pkg.test() passes, the RegressionTables.jl smoke test passes, and the checked-in Stata reference comparison passes.
  4. Documentation refresh: if behavior, compat, or benchmark results change, README.md, benchmark artifacts, and reference files are updated in the same maintenance cycle.
  5. Optional external parity: if reference/boss_reference.toml is present, the same workflow also checks the package against your boss's saved output.

This workflow is intended to guarantee the following:

  • EventStudyInteracts.jl remains compatible with Julia 1.10 LTS, with an additional stable-version import smoke check.
  • The nlswork reference example remains numerically close to the checked-in Stata baseline, within the tolerances stored in reference/nlswork_stata.toml.
  • RegressionTables.jl integration keeps working as part of the main automated test suite.
  • README performance claims are backed by checked-in scripts and saved benchmark outputs under benchmark/.

This workflow does not guarantee the following:

  • Exact equality for all summary metadata across package versions. Values such as degrees of freedom, adjusted R2, or iteration counts can change slightly across FixedEffectModels.jl releases even when the core coefficient vector remains aligned.
  • Equality to any outside result that is not checked into reference/.
  • Fully automatic release decisions. Codex can implement and validate changes, but versioning, tagging, and registration still follow the normal repository release process.

Syntax

result = eventreg(
    df,
    formula,
    rel_varlist::Vector{Symbol},
    control_cohort::Symbol,
    cohort::Symbol,
    vcov;
    contrasts = contrasts,
    weights = weights,
    save = save,
    method = method,
    nthreads = nthreads,
    double_precision = double_precision,
    tol = tol,
    maxiter = maxiter,
    drop_singletons = drop_singletons,
    progress_bar = progress_bar,
    dof_add = dof_add,
    subset = subset,
)

The syntax is similar to FixedEffectModels.jl, and the current package line is tested against FixedEffectModels.jl 1.13 on Julia 1.10+. Users need to specify rel_varlist::Vector{Symbol}, control_cohort::Symbol, and cohort::Symbol explicitly. The rel_varlist is the list of relative time indicators as you would have included in the canonical two-way fixed effects regression. The rel_varlist must be defined as a Vector{Symbol}.

dof_add is still accepted for backward compatibility, but it is currently ignored when this package is used with FixedEffectModels.jl 1.13+.

rel_varlist = Symbol[:g_4, :g_3, :g_2, :g0, :g1, :g2, :g3]

See illustration for an example of generating these relative time indicators. The relative time indicators should take the value of zero for never treated units. Users should shape their dataset to a long format where each observation is at the unit-time level. See illustration for an example of specifying the syntax. The syntax is similar to [FixedEffectModels.jl](https://github.com/FixedEffects/FixedEff

Related Skills

View on GitHub
GitHub Stars10
CategoryDevelopment
Updated12d ago
Forks1

Languages

Julia

Security Score

80/100

Audited on Mar 22, 2026

No findings