Error computing abnormal returns

I am trying to conduct an event study, but am running into an error when computing abnormal returns.

I have a dateframe consisting of Firm ID, Date, Stock Return, Market Return.
The returns are formated as numeric.

I want to create a new column, "AR" where I subtract the market return from the stock return. However, when I do this, I get the "Replacement has 0 rows, data as X"-error. I have tried using na.omit, but that did not work either.

Any help?

Please post the code you are trying to use and a small sample of your data made by running


where you replace DF with the actual name of the variable holding your data. Paste the output of that command in your message and put a line with three back ticks immediately before and after the output.
your output here

structure(list(PERMNO = c(10020L, 10020L, 10020L, 10020L, 10020L, 
10020L), DATE = structure(c(5866, 5870, 5871, 5872, 5873, 5874
), class = "Date"), RET = c(NA, NA, 0.025862, 0.058824, 0.039683, 
0.007634), VW = c(0.002665, 0.004343, 0.009631, 0.002445, -0.003073, 
0.009399), EW = c(0.001397, 0.00214, 0.003179, -0.000248, 0.000895, 
0.00539)), row.names = c(NA, 6L), class = "data.frame")

Code I was trying was just

r$AR <-  r$RET - r$VM

Taking this in a slightly different direction but you could try the mutate function from the dplyr package.


mutate(r,  AR = RET - VM)

The mutate function allows you to add variables to a dataframe while preserving the existing variables.

I think I solved it myself, just putting r$AR = r$RET - r$VW instead of using the "<-" operator

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.