0

I have a large panel dataset containing daily observations for different stocks. It looks like this: https://i.stack.imgur.com/FOoX0.jpg (the variable symbol depicts the different stocks).

I want to run the following regression for each stock i between day t and day t - 21:regression

I tried to do this using rollregres:

fit_ivol <- roll_regres(panel_data$excess_return_stock ~ panel_data$excess_return_market + panel_data$SMB + panel_data$HML, panel_data, width=list(c(0:-20)), do_compute = "sigmas")

but since the first value of excess_return_stock for each symbol is NA, I get an error message saying "Error in na.fail.default(list(panel data$excess_return_stock = c(NA, : missing values in object".

Is there a way to tell rollregres to just skip the rows containing NAs?

Kharon
  • 17
  • 3
  • 1
    Hi and welcome to Stack Overflow. Please don't post data as an image but use the function `dput()` instead. Also, check out how to pose a [great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), so that other users can help you better. – Ric S Jul 25 '20 at 16:59
  • Remove `panel_data$` from the formula, use `excess_return_stock ~ excess_return_market + SMB + HML` and `data = na.omit(panel_data)`. – Rui Barradas Jul 25 '20 at 17:13

0 Answers0