forgive me if this question is trivial for some of you but I am a complete newbie to R...
I want to use the function "evReturn()" from the R Package "erer". It is a function to calculate cumulative abnormal returns and looks like this for one firm and one market index:
hh <- evReturn(y = dataset, firm = "Firm1",
y.date = "date", index = "Index1", est.win = 250,
digits = 3, event.date = 19990505, event.win = 5)
This works just fine if I have a matrix with 3 columns (Date, Stock returns of firm 1 and index return of index 1).
Now the case is a bit more complicated. I have appr. 3000 firms and 3000 different indices. So in column 1, I have the dates. In columns 2-3001, I have the stock returns for all firms. In columns 3002-6001 I have the returns of the indices.
I thought I could run the evReturn() function for all firms and all indices with a for loop like this
> for(i in 2:3001)
{hh <- evReturn(y=numt,firm=i,event.date=20140102,y.date="Date",
index=i+3000,event.win=2,est.win=230,digits=3)}
But it only returns
Error in [.data.frame`(y, (loca - event.win - est.win):
(loca - event.win - : undefined columns selected
I am aware of several posts that resolve the error of "undefined columns selected" but none helps here. Has anyone an idea how I could create a for loop to let the evReturn() run through all my columns?
Any help is appreciated!
Cheers,
Paul