Instructions R-Package "EventStudy"

EventStudyTools maintains two R clients on its GitHub account. Both are API wrappers that draw on our server-hosted analytics, so the underlying methods stay current in one central place while you work entirely from R. Pick the one that fits your workflow:

  • EventStudy, the classic full-featured package: parameter objects, result parsers, plotting helpers, vignettes, and an RStudio addin. Choose this if you want guided workflows and ready-made plots.
  • r-wrapper, a lightweight client with only two dependencies (curl and jsonlite). Choose this for scripted, reproducible pipelines with a minimal footprint.

Get an API key

Both clients need an API key. Academic users can request a free key on our API access page using their university email address; keys are valid for one month. Key access for non-academic users is currently paused.

Option 1: the EventStudy package

The EventStudy package was previously published on CRAN but is archived there, so install.packages("EventStudy") no longer works. Install the current version from GitHub:

# install remotes first if needed
install.packages("remotes")
remotes::install_github("EventStudyTools/api-wrapper.r")

Quickstart

The snippet below runs an abnormal returns analysis (ARC) on the bundled S&P 500 example data and writes the result files to a local folder:

library(EventStudy)

apiKey <- "YOUR_API_KEY"

# generate the bundled S&P 500 example data in the working directory
getSP500ExampleFiles()

est <- EventStudyAPI$new()
est$authentication(apiKey)

dataFiles <- c(request_file = "01_RequestFile.csv",
               firm_data    = "02_FirmData.csv",
               market_data  = "03_MarketData.csv")

est$performDefaultEventStudy(estType   = "arc",
                             dataFiles = dataFiles,
                             destDir   = "results")

The package also includes a ResultParser class that reads the result files back into R and plots abnormal returns, cumulative averages, and test statistics. The vignettes (Get Started, Parameters, the Dieselgate use case, and the RStudio addin) walk through these features step by step.

Option 2: the lightweight r-wrapper

The r-wrapper is the lean successor for scripted workflows. It depends only on curl and jsonlite:

# install.packages("remotes")
remotes::install_github("EventStudyTools/r-wrapper")

Quickstart

library(eventstudytools)

client <- est_client("YOUR_API_KEY")

results <- est_run_study(
  client,
  est_arc_params(benchmark_model = "mm", return_type = "log"),
  files = c(request_file = "01_RequestFile.csv",
            firm_data    = "02_FirmData.csv",
            market_data  = "03_MarketData.csv"),
  dest_dir = "results"
)

To try it immediately with bundled sample data (20 US firms, S&P 500 benchmark), run est_run_study(client, est_arc_params(), est_sample_files()). Parameter helpers for the other research apps are included as well, for example est_avc_params() for abnormal volume and est_cata_params() for news analytics.

Worked examples

For guidance on how to use the EventStudy package in real research settings, please visit these hands-on examples:

  • Reconstitution events of the S&P 500: This example teaches you how to use the package to perform a sample return event study with different event dates, companies, and reference indices.
  • Dieselgate: This example teaches you how to use the package to perform not only return but also volume and volatility event studies, and shows how to capture the required capital market data using a third-party R package.

If you prefer to run your analyses from the RStudio IDE, please visit the page on our EventStudy RStudio addin.

Protocol reference

Both R clients implement the same upload-and-process protocol as our other language wrappers. For the protocol steps, input file formats, and the full parameter reference, see the API documentation.

Step-by-step tutorial

New to event studies in R? The guided tutorial How to run an event study in R walks from data preparation to abnormal returns and significance tests, with complete code. Working in Python instead? Follow the Python version of the workflow.