The attached sample data and request files were constructed to illustrate the use of the EventStudyTools R-package.
The files hold data about the addition of several well known firms to the S&P 500 index in the late 1990s. With this data, the R package will investigate for you the question whether a company’s stock value increases if the firm is added to the S&P 500 index. This is a common research question and has been addressed, among others, by Anthony W. Lynch and Richard R. Mendenha in a 1997 study: They found a positive effect of about 3.8% over the period starting the day after the announcement and ending the day before the effective date of the change.
You can use our R-package to easily investigate such and similar questions.
For performing an Event Study with our API you need:
http://api.eventstudytools.com)You get an API key from our website EventStudyTools. In the first step we need to authenticate to the web API. There are three ways to handle this two parameters:
Option 1 and 2: You can save API key and URL in the
options object
# The URL is already set by default
# options(EventStudy.URL = apiUrl)
options(EventStudy.KEY = apiKey)
# use EventStudy estAPIKey function
estAPIKey(apiKey)
# initialize object
estSetup <- EventStudyAPI$new()Option 2: Set the API Key and URL directly during
the EventStudyAPI R6-class initialization
This API package is designed to perform all analyses we provide on our website. Furthermore, all parameters can be set. You are able to set every parameter in R (we will provide more details later), or you can perform a fast Event Study with default parameters.
There will be soon a separate vignette for setting parameters.
Our API offers different types of Event Studies:
arcavcavycDefault parameters for all type of above Event Studies are:
arc and
avc and GARCH(1, 1) Model for avyccsvloglaterThe type of Event Study can be set by parameter:
By default all data files must be named as follows. Furthermore, they have to be in the current directory:
01_RequestFile.csv02_firmData.csv03_MarketData.csvYou are also able to set custom file names and paths by defining it in a named vector:
All results will be written by default into the directory
./results. You can easily change this path by setting it as
a parameter:
Attention
If the resultPath do not exist, the R package will
create this directory.
For performing an Event Study we need three files (file names can be chosen arbitrarily):
All files must be saved without header, semi-colon separated and
dates has to be in following format: 30.04.1997. In next
section we will describe the file structure based on the S&P 500
example Event Study more detailed. You always find more information (if
necessary) on our website: EventStudyTools.
We added the S&P 500 example Event Study to this package. The three necessary files can be easily generated by following command:
We named the request and data files in following manner:
01_RequestFile.csv02_FirmData.csv03_MarketData.csvIn your analysis, you can name them as you want.
01_RequestFile.csvThis csv file contains the event definitions. It contains 9 columns. The order must be in the following way, as the columns are not named in the csv.
30.04.1997]: Date of the
eventIn the following example, we have an event window of
[-2, 2] (an event window of length 5), an
estimation window of length 120, and the estimation window
ends 11 days before the event.
library(readr)
df <- readr::read_delim("01_RequestFile.csv", col_names = F, delim = ";")
names(df) <- c("Event ID", "Firm ID", "Market ID", "Event Date", "Grouping Variable", "Start Event Window", "End Event Window", "End of Estimation Window", "Estimation Window Length")
knitr::kable(head(df), pad=0)| Event ID | Firm ID | Market ID | Event Date | Grouping Variable | Start Event Window | End Event Window | End of Estimation Window | Estimation Window Length |
|---|---|---|---|---|---|---|---|---|
| 75510 | Adobe Systems | SP500 | 30.04.1997 | Addition | -2 | 2 | -11 | 120 |
| 64390 | Progressive | SP500 | 25.07.1997 | Addition | -2 | 2 | -11 | 120 |
| 23473 | Cincinnati | SP500 | 16.12.1997 | Addition | -2 | 2 | -11 | 120 |
| 70500 | Coca-Cola Enterprises | SP500 | 01.10.1998 | Addition | -2 | 2 | -11 | 120 |
| 70519 | Travelers Group | SP500 | 01.10.1998 | Addition | -2 | 2 | -11 | 120 |
| 76149 | Safeway | SP500 | 05.11.1998 | Addition | -2 | 2 | -11 | 120 |
Attention
The first column (Event IDs) must be unique and numeric.
02_FirmData.csvThe stock data for each firm defined in the request file. It contains 3 columns.
30.04.1997]: Date of the closing
price.The following table shows the first 20 entries of our
example firm data.
library(readr)
df <- readr::read_delim("02_FirmData.csv", col_names = F, delim = ";")
names(df) <- c("Firm ID", "Date", "Closing Price")
knitr::kable(head(df))| Firm ID | Date | Closing Price |
|---|---|---|
| Cincinnati | 01.10.1996 | 58.000 |
| Cincinnati | 02.10.1996 | 57.000 |
| Cincinnati | 03.10.1996 | 56.750 |
| Cincinnati | 04.10.1996 | 57.500 |
| Cincinnati | 07.10.1996 | 57.625 |
| Cincinnati | 08.10.1996 | 57.750 |
03_MarketData.csvThis file is similary structured as 02_FirmData.csv:
30.04.1997]: Date of the closing
price.The following table shows the first 20 entries of our
example firm data.
library(readr)
df <- readr::read_delim("03_MarketData.csv", col_names = F, delim = ";")
names(df) <- c("Market ID", "Date", "Closing Price")
knitr::kable(head(df))| Market ID | Date | Closing Price |
|---|---|---|
| SP500 | 30.09.1996 | 100.0000 |
| SP500 | 01.10.1996 | 100.2575 |
| SP500 | 02.10.1996 | 100.9747 |
| SP500 | 03.10.1996 | 100.7958 |
| SP500 | 04.10.1996 | 102.0587 |
| SP500 | 07.10.1996 | 102.3380 |
You are also able to apply a Fama-French 3-Factor Model or a Fama-French Momentum-4-Factor Model. This will change the necessary data you need for performing an Event Study (e.g. by adding Fama-French Factors). You find more information at https://www.eventstudytools.com/instructions-axc.
Please cite our work in your publication.