7.7 Predict stock return on the event day

First, keep only the event days.

pred_dt <- price_merge %>% 
  filter(event_diff == 0)

Next, make the predictions and store them in a dataframe called predictions. Note that predict() function, when used with the argument interval will output 3 values labeled as fit, lwr, and uhr. The last two are the lower and upper prediction intervals, respectively.

predictions <- structure(list(fit = numeric(),
                              lwr = numeric(),
                              upr = numeric()),
                         class = "data.frame")

for (i in 1:length(lm_list)) {
  predictions <- rbind(predictions,
                       predict(lm_list[[i]],
                               pred_dt[i, ],
                               interval = "predict")
                       )
}

Finally, add the columns for real returns (adjusted for the risk-free returns) and ticker.

predictions <- predictions %>% 
  mutate(ticker = pred_dt$ticker,
         ret = pred_dt$ret)