Overview
Robust event study results require careful validation and professional presentation. The R package v0.40.0 provides comprehensive diagnostic tools and multiple export formats.
Data Validation
Before running an event study, validate your input data:
library(EventStudy)
task <- EventStudyTask$new(
data = stock_data,
event_date = "2020-03-15",
estimation_window = c(-250, -11),
event_window = c(-5, 5)
)
# Validate task setup
validate_task(task)validate_task() checks for:
- Missing values in the event or estimation window
- Sufficient data points in the estimation window
- Correct date format and ordering
- Matching firm and market data availability
Model Diagnostics
After fitting a return model, assess its quality:
model <- MarketModel$new()
model$fit(task)
# Run comprehensive diagnostics
diagnostics <- model_diagnostics(task)
print(diagnostics)Shapiro-Wilk Normality Test
Tests whether estimation window residuals follow a normal distribution. If rejected, consider non-parametric test statistics.
Durbin-Watson Test
Tests for first-order autocorrelation in residuals. Values near 2 indicate no autocorrelation. If rejected, standard errors may be understated.
Ljung-Box Test
Tests for higher-order serial correlation, complementing the Durbin-Watson test for higher-order patterns.
Visual Diagnostics
# Plot diagnostic charts
plot_diagnostics(task)This produces:
- Residual time series plot
- Residual histogram with normal overlay
- Q-Q plot
- ACF (autocorrelation function) plot
Pre-Trend Testing
Pre-trend tests check whether abnormal returns existed before the event:
# Test for pre-event abnormal returns
pretrend <- pretrend_test(task, window = c(-10, -1))
print(pretrend)A significant pre-trend suggests information leakage, confounding events, or a misspecified event date.
Diagnostic Checklist
| Check | Tool | What to look for |
|---|---|---|
| Data quality | validate_task() |
Missing values, date issues |
| Normality | Shapiro-Wilk | p > 0.05 for parametric tests |
| Autocorrelation | Durbin-Watson | Values near 2.0 |
| Serial correlation | Ljung-Box | p > 0.05 for independence |
| Pre-trends | pretrend_test() |
No significant pre-event ARs |
| Model fit | R-squared | Reasonable explanatory power |
Exporting Results
The R package provides multiple export formats to fit your workflow.
CSV Export
export_results(task, format = "csv", path = "results/")Creates separate CSV files for AR, CAR, AAR, CAAR, and test statistics.
Excel Export
export_results(task, format = "excel", path = "results/event_study.xlsx")Multi-sheet Excel workbook with formatted tables. Requires the openxlsx package.
LaTeX Export
export_results(task, format = "latex", path = "results/tables/")Publication-ready LaTeX tables with significance stars, standard errors in parentheses, and table notes.
Broom Integration
library(broom)
# Tidy output of event study results
tidy_results <- tidy(task)
print(tidy_results)Returns a tibble compatible with the tidyverse, making it easy to pipe into ggplot2 or other tools.
Result Extraction Helpers
# Get specific result components
ar <- get_ar(task) # Abnormal returns
car <- get_car(task) # Cumulative abnormal returns
aar <- get_aar(task) # Average abnormal returns
model_stats <- get_model_stats(task) # Model statisticsExample Workflow
library(EventStudy)
# 1. Run event study
task <- EventStudyTask$new(data = stock_data, ...)
model <- MarketModel$new()
model$fit(task)
# 2. Validate
validate_task(task)
model_diagnostics(task)
# 3. Run test statistics
PatellZ$new()$compute(task)
RankTest$new()$compute(task)
# 4. Export everything
export_results(task, format = "excel", path = "output/results.xlsx")
export_results(task, format = "latex", path = "output/tables/")
# 5. Visualize
plot_event_study(task)
plot_diagnostics(task)