Event study conundrum

59 views
Skip to first unread message

Jude Eastwood

unread,
Apr 12, 2021, 7:23:46 AM4/12/21
to unmarked
Hi, 
I am currently trying to run an event study for final project in school and I keep hitting road blocks, I am able to run the event study using the event studies package however, I am unable to calculate market return or run that with the package. I am attaching my data and codes and would be glad to have some assistance. 

Kindly see errors I keep encountering below:
 
> # Event study using Market Model
> es.mm = eventstudy(firm.returns = stprices,
+                    event.list = stockdates,
+                    event.window = 30,
+                    type = "None",
+                    remap = "cumsum",
+                    inference = TRUE, 
+                    inference.strategy = "bootstrap",
+                  model.args = list(
+                    market.returns = stprices[, "GSPTSE"]
+                  )
+ )
Warning message:
In eventstudy(firm.returns = stprices, event.list = stockdates,  :
  "type" = "None" does not take extra arguments, ignoring them.
> # Event study using Market Model
> es.mm = eventstudy(firm.returns = stprices,
+                    event.list = stockdates,
+                    event.window = 30,
+                    type = "marketModel",
+                    remap = "cumsum",
+                    inference = TRUE, 
+                    inference.strategy = "bootstrap",
+                  model.args = list(
+                    market.returns = stprices[, "GSPTSE"]
+                  )
+ )
Error in rval[i, j, drop = drop., ...] : subscript out of bounds
 
This are the codes I run: 
rm(list = ls())
cat("\014")  
this.dir = dirname(parent.frame(2)$ofile)
setwd(this.dir)

#Set the list of packages required
packageList = c("eventstudies")

#Function to test of a package is installed
newPackages = packageList[!(packageList %in% installed.packages()[,"Package"])]
if(length(newPackages)){
  install.packages(newPackages)

#Install all packages that are not already installed
lapply(packageList, library, character.only = TRUE)

other_return = read.csv("/Users/mbp/Documents/othprice.csv")
other_return$Date = as.Date(other_return$Date, "%m/%d/%Y")
str(other_return)

stockdates = read.csv("/Users/mbp/Documents/eveproj/stockdates.csv")
stockdates$when = as.Date(stockdates$when, "%m/%d/%Y")

stprices = read.csv("/Users/mbp/Documents/eveproj/Stprices.csv")
zoo_index = as.Date(stprices$Date, "%m/%d/%Y")
stprices = stprices[,2:ncol(stprices)]

for(i in 2:length(colnames(stprices))){
  
  stprices[2:nrow(stprices),i] = (stprices[2:nrow(stprices),i]/stprices[1:(nrow(stprices)-1),i])-1
  stprices[1,i] = NA
  
  
}

stprices = zoo(stprices, order.by = zoo_index)
str(stprices)

# Event study 
es = eventstudy(firm.returns = stprices,
                event.list = stockdates,
                event.window = 30,
                type = "None",
                remap = "cumsum",
                inference = TRUE, 
                inference.strategy = "bootstrap")
               
str(es)
plot(es)

# Event study using Market Model
es.mm = eventstudy(firm.returns = stprices,
                   event.list = stockdates,
                   event.window = 30,
                   type = "marketModel",
                   remap = "cumsum",
                   inference = TRUE, 
                   inference.strategy = "bootstrap",
                 model.args = list(
                   market.returns = stprices[, "GSPTSE"]
                 )
)
str(es.mm)
plot(es.mm)


Thank you. 
Reply all
Reply to author
Forward
0 new messages