Result Extraction and Export
Simon Mueller
2026-09-06
Source:vignettes/result-extraction.Rmd
result-extraction.RmdIntroduction
After running an event study, you need to extract and export results
for analysis, tables, and publication. This vignette covers all the ways
to get results out of an EventStudyTask.
Running the Example
First, let’s set up a complete event study (using synthetic data for reproducibility):
library(EventStudy)
# Create task with synthetic data
task <- create_mock_task(n_firms = 5) # helper for testing
params <- ParameterSet$new()
task <- run_event_study(task, params)Extracting Results Programmatically
Abnormal Returns
# Get AR for a specific event
ar <- task$get_ar(event_id = 1)
ar
# # A tibble: 11 x 2
# relative_index abnormal_returns
# <dbl> <dbl>
# 1 -5 0.00234
# ...Cumulative Abnormal Returns
# Get CAR for a specific event
car <- task$get_car(event_id = 1)
car
# # A tibble: 11 x 3
# relative_index abnormal_returns car
# <dbl> <dbl> <dbl>
# 1 -5 0.00234 0.00234
# ...The tidy() Method
The tidy.EventStudyTask() method returns results in
broom-compatible long format, making it easy to use with standard
tidyverse workflows.
Tidy AR
tidy_ar <- tidy.EventStudyTask(task, type = "ar")
tidy_ar
# # A tibble: 55 x 7
# event_id group firm_symbol term estimate std.error statistic
# <int> <chr> <chr> <chr> <dbl> <dbl> <dbl>
# 1 1 TestGroup FIRM_A -5 0.00234 0.0102 0.229
# ...Tidy CAR
tidy_car <- tidy.EventStudyTask(task, type = "car")
# Includes cumulative AR with window labels as termsTidy AAR
tidy_aar <- tidy.EventStudyTask(task, type = "aar")
# Includes AAR, CAAR, and their test statistics with p-valuesTidy Model
tidy_model <- tidy.EventStudyTask(task, type = "model")
# Returns alpha, beta, sigma, r.squared for each eventExporting Results
Export to CSV
# Export all results (creates separate files: results_ar.csv, results_car.csv, etc.)
export_results(task, "results.csv")
# Export specific results
export_results(task, "model_stats.csv", which = "model")Export to Excel
# Requires the openxlsx package
# Each result type gets its own worksheet
export_results(task, "results.xlsx")Export to LaTeX
# Produces publication-ready LaTeX tables
# Requires the knitr package
export_results(task, "results.tex", which = c("model", "aar"))Cross-Sectional Analysis of CARs
After extracting CARs, you can analyze what drives the cross-sectional variation:
# Extract CARs for all events
all_cars <- purrr::map2_dfr(
task$data_tbl$event_id,
task$data_tbl$firm_symbol,
function(eid, sym) {
car <- task$get_car(event_id = eid)
tibble::tibble(
event_id = eid,
firm_symbol = sym,
car_total = tail(car$car, 1)
)
}
)
# Now you can regress CARs on firm characteristics
# (see the cross_sectional_regression() function)Visualization
# Single-event plots
plot_event_study(task, type = "ar", event_id = 1)
plot_event_study(task, type = "car", event_id = 1)
# Multi-event plots
plot_event_study(task, type = "aar")
plot_event_study(task, type = "caar")
# Model diagnostics
plot_diagnostics(task, event_id = 1)Summary
| Method | Returns | Format |
|---|---|---|
get_ar() |
AR for one event | tibble |
get_car() |
CAR for one event | tibble |
get_aar() |
AAR/CAAR for one group | tibble |
get_model_stats() |
Model fit stats | list |
tidy.EventStudyTask() |
Broom-compatible results | tibble |
export_results() |
Write to file | CSV/XLSX/LaTeX |
plot_event_study() |
Visualization | ggplot2 |