/applied-micro:event-study-carsfrom applied-micro
Computes cumulative abnormal returns (CARs) with robust event-study test statistics, replicating Stata's eventstudy2. Handles thin-trading, multiple windows, and boundary contamination.
Ships in applied-micro. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
A complete methodology reference for computing publication-quality CARs with robust test statistics, matching the rigor of Kaspereit's eventstudy2 (v3.2b) for Stata. This skill is generic — applicable to any market, asset class, or event type.
scripts/eventstudy.py is a complete, runnable Python replication of
eventstudy2, validated against the Stata package to floating-point precision
(AR ~1e-8, CAR ~6e-8, CAAR and the implemented test statistics ~1e-7) on a
generic CRSP sample across all four models (FM, COMEAN, MA, RAW). It is generic —
all column names, the model, windows, thin-trading, and log handling are CLI
flags. When a user wants CARs computed, run this engine; do not author a new
pipeline.
python scripts/eventstudy.py --selftest # synthetic self-check, no inputs
python scripts/eventstudy.py \
--returns returns.csv --market market.csv --events events.csv \
--id-col permno --ret-col ret --event-date-col event_date --mkt-col vwretd \
--model FM --car-windows "-1,1;-5,5;-10,10" \
--eswlb -250 --eswub -30 --evwlb -10 --evwub 10 --out-dir out/
Inputs are CSV/Parquet: returns (id, date, ret), market/factors
(date, mkt[, factors]), events (id, event_date). Outputs: ar_panel.csv,
car_panel.csv, test_statistics.csv. Requires numpy/pandas/scipy. Run
--help for all flags (--factor-cols smb,hml, --model MA,
--no-thin-trading, ...). The sections below document the methodology the engine
implements; read them to audit, extend, or port it.
Construct a master list of valid trading dates from the security returns file.
delweekend).dateline_threshold: drop dates where the count of return
observations falls below threshold × mean(daily_count). A threshold of
0.2 works well for international samples with heterogeneous holidays.For each event:
max_shift calendar days (default: 3), exclude
the event entirely — do not silently map it to a distant trading day.For each firm-event pair, define windows in relative trading time (offsets from the event day on the dateline):
[esw_lb, esw_ub] — default [-250, -30].[evw_lb, evw_ub] — determined by the widest CAR window
requested.Exclusion checks (per firm-event):
min_esw_obs,
default 120).evw_lb or last observed return date falls before evw_ub, exclude
the firm-event. These are survivorship-biased observations.For markets with non-trivially thin trading (most markets outside US mega-caps), apply the Maynes-Rumsey (1993) trade-to-trade transformation by default.
Read
references/thin_trading.mdfor the complete transformation, including thecum_periodsconstruction, the regression specification withnocons, and the boundary contamination guard.
Summary: Non-trading days accumulate into the next trading day's return.
All variables (returns, factors, intercept) are divided by sqrt(cum_periods).
OLS is run with nocons because the intercept regressor 1/sqrt(d) replaces
the standard constant. This is a GLS correction for the heteroscedasticity
introduced by multi-period returns.
For each firm-event pair, estimate the benchmark model over the estimation window and compute the standard deviation of forecast (STDF) for every observation (estimation + event window).
Read
references/estimation_models.mdfor model specifications (RAW, COMEAN, MA, FM, BHAR).
STDF (Theil 1971 prediction error correction):
For each observation t, the forecast standard deviation is:
STDF_it = sigma_hat_i * sqrt(1 + x'_t (X'X)^{-1} x_t)
where x_t is the regressor vector at time t, X is the estimation-window
design matrix, and sigma_hat_i = sqrt(SSR / (T_i - 2 - df)) is the OLS
residual standard deviation. df is the number of additional factors beyond
the market (0 for market model, 2 for FF3, etc.).
The STDF accounts for both the inherent noise in returns (sigma) and the estimation uncertainty in the model coefficients (which grows when event-window factor values are far from estimation-window means).
Python: after numpy.linalg.lstsq, compute the hat matrix
H = X @ inv(X'X) @ X' and h_t = x'_t @ inv(X'X) @ x_t for each
event-window observation. Then STDF_t = sigma_hat * sqrt(1 + h_t).
AR_it = R_it - predicted_it
where predicted_it comes from the estimated benchmark model applied to
event-window factor values.
Critical rule: do NOT zero-fill missing event-window returns. A missing return means the stock did not trade — setting it to zero biases CARs toward zero for illiquid stocks. Leave it as NaN and let the accumulation step handle the count of valid ARs.
For each requested CAR window [lb, ub] and each firm-event:
CAR_i = sum of AR_it for t in [lb, ub] where AR_it is not NaN
Boundary contamination guard (from eventstudy2):
cum_periods > 1, the return on
that day spans back before the window start. Set CAR = NaN.cum_periods > 1 has its AR set
to NaN (the multi-period return cannot be attributed to a single day).Track n_valid_ar per CAR: the count of non-NaN ARs in the window. A valid
CAR should have n_valid_ar == window_length. CARs with fewer valid days
should be flagged or excluded depending on the analysis.
Compute at minimum: Patell (1976), BMP (Boehmer et al. 1991), Kolari-Pynnonen adjusted BMP, and the generalized sign test (Cowan 1992). For maximum rigor, compute all 13 tests.
Read
references/test_statistics.mdfor exact formulas, null hypotheses, distributions, and Python implementation notes for all 13 tests.
Read
references/kolari_pynnonen.mdfor the cross-correlation adjustment procedure (ADJ factor) and the GRANK-T test.
Test statistics are reported at two levels:
Read
references/estimation_models.mdfor full mathematical specifications.
| Model | When to Use |
|---|---|
| RAW | Baseline/diagnostic only. No benchmark subtracted. |
| COMEAN | Simplest parametric benchmark (constant mean return). |
| MA (market-adjusted) | When factor data is unavailable. Subtracts market return directly. |
| FM (factor model) | Standard choice for short-window event studies. Market model (1 factor) or FF3/FF5/Carhart (multi-factor). |
| BHAR | Long-horizon event studies (months/years). Requires skewness-adjusted bootstrap (Lyon et al. 1999). |
Default: FM with market model (1 factor) for short-window studies.
NEVER replace missing event-window returns with zero. This biases CARs toward zero for illiquid stocks. The only exception is BHAR models, which assume continuous holding.
NEVER compute CARs when the stock's first/last trading date falls inside the event window (IPO/delisting bias).
NEVER sum CARs when a boundary day has cum_periods > 1 — the return
spans outside the intended window.
NEVER run OLS with a standard constant when using the trade-to-trade
transformation. Use nocons with 1/sqrt(cum_periods) as the intercept
regressor.
NEVER report CARs without at least one parametric and one non-parametric test statistic.
NEVER mix log and simple returns between the LHS and RHS of the market
model. If stock returns are in logs, factor returns must also be in logs
(or convert both via ln(1+R) before estimation). Jensen's inequality
creates bias otherwise.
A valid CAR output dataset must contain:
Identifiers (column names vary by project):
firm_id, event_id, event_dateEstimation diagnostics (per firm-event, per model):
alpha, beta (per factor), nobs, r2, sigma_hatPer CAR window per model:
car_value — NaN if invalidn_valid_ar — count of non-NaN ARs in the windowExclusion reason (per firm-event):
insufficient_est_obs, insufficient_evt_obs, ipo_in_window,
delisting_in_window, event_off_dateline, boundary_contaminationTest statistics (separate output):
These can be overridden by the user:
| Parameter | Default | Notes |
|---|---|---|
| Estimation window | [-250, -30] | ~1 year of trading days |
| Min estimation obs | 120 | Conservative; eventstudy2 defaults to 30 |
| Event window | Widest CAR window | Determined by user's CAR windows |
| Max event-date shift | 3 calendar days | Beyond this, exclude the event |
| Dateline threshold | 0.0 | Include all trading days (set ~0.2 for international samples) |
| Thin-trading adjustment | ON | Disable only for extremely liquid markets |
| Log returns | Convert via ln(1+R) | Unless input is already in logs |
| Min event-window obs | 1 | Per eventstudy2 default |
| Kolari-Pynnonen ADJ | Computed | Skip only if N > 500 firms (O(N^2) cost) |
Read these for detailed formulas and implementation guidance:
| File | Contents | When to Read |
|---|---|---|
references/estimation_models.md | RAW, COMEAN, MA, FM, BHAR model specs | When choosing or implementing a benchmark model |
references/thin_trading.md | Maynes-Rumsey (1993) transformation with Python code | When implementing the trade-to-trade adjustment |
references/test_statistics.md | All 13 test statistics with formulas | When implementing or debugging test statistics |
references/kolari_pynnonen.md | Cross-correlation adjustment (2010) and GRANK-T (2011) | When implementing Kolari-Pynnonen tests |
references/implementation_checklist.md | 10 most common mistakes in naive implementations | When auditing or upgrading an existing CAR pipeline |
After computing CARs, run scripts/validate_cars.py to check output
integrity:
python scripts/validate_cars.py --car-file output.parquet \
--firm-col firm_id --event-col event_id \
--car-cols CAR_m1_p1,CAR_m5_p5 \
--exclusion-col exclusion_reason \
--nar-cols n_ar_m1_p1,n_ar_m5_p5 \
--window-lengths 3,11
The script checks: no CARs where exclusion reasons exist, valid AR counts match window lengths, required columns are present, and test statistic files exist alongside the CAR panel.
CLAUDE.md (opens in a new tab)LICENSE (opens in a new tab)README.md (opens in a new tab)references/estimation_models.md (opens in a new tab)references/implementation_checklist.md (opens in a new tab)references/kolari_pynnonen.md (opens in a new tab)references/test_statistics.md (opens in a new tab)references/thin_trading.md (opens in a new tab)scripts/eventstudy.py (opens in a new tab)scripts/validate_cars.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
17 skills in this plugin
/adjudication-sheetsBuild human adjudication / hand-labeling sheets from LLM-pipeline data without
evidence truncation. Use when: (1) preparing a CSV/Excel sheet for a human to
rule on cases an LLM classifier or rater panel judged, (2) a labeler reports
"there is no information to label from" or cells look empty in Excel,
(3) excerpt columns cluster at one exact length (e.g. all 1,500 chars — a hard
truncation cap). Covers: full rating-basis recovery, Excel 32,767-char cell cap,
multi-line CSV mangling, ruling dropdowns, companion text files.
/adversarial-empirical-reviewN-round adversarial review pipeline for empirical research output — the chain from data to LaTeX tables to a manuscript that cites them. A Claude drafter proposes minimal diffs, a deterministic mechanical battery gates every diff from a clean state with a regression gate, a Codex reviewer files check-backed critiques, and a blind judge panel decides residual disputes. Manual-invoke ONLY: trigger when the user explicitly runs /adversarial-empirical-review or names 'adversarial-empirical-review' / 'adversarial empirical review'. Do NOT auto-trigger on generic 'review my results', 'check my tables', or manuscript-editing requests. For prose-style refinement use style-emulation instead; this skill AUDITS WHETHER THE TABLES ARE CORRECT — that each number in the tables is what the analysis code computes, reproduces from the data, and is internally consistent. It is an empirical + code review: the manuscript is read only to resolve table numbering, and prose is not examined.npx claudepluginhub kennethkhoocy/applied-micro-skills --plugin applied-microOther plugins' skills for the same job