Hey @davis (or anyone else if Davis is busy),
I have another (dumb) followup question:
If I add future data for predicting it works for a single day:
EuStockMarkets %>%
as.tibble() %>%
mutate(bus_day = lubridate::date_decimal(as.numeric(time(EuStockMarkets)))) %>%
gather(key = "stk_name", value = "price", -bus_day) %>%
group_by(stk_name) %>%
nest() %>%
mutate(model = map(.x = data, .f = ~ lm(formula = price ~ bus_day, data = .x)),
tidy_model = map(model, tidy),
bus_day = seq.POSIXt(from = as.POSIXct(x = "2018-01-01 05:00:00", tz = "MST"),
to = as.POSIXct(x = "2018-01-01 05:00:00", tz = "MST"),
by = "day"),
yhat2018 = map2(.x = model, .y = bus_day, .f = ~ add_predictions(model = .x, data = data.frame(bus_day = .y)))) %>%
select(yhat2018) %>%
unnest()
But not for multiple days
EuStockMarkets %>%
as.tibble() %>%
mutate(bus_day = lubridate::date_decimal(as.numeric(time(EuStockMarkets)))) %>%
gather(key = "stk_name", value = "price", -bus_day) %>%
group_by(stk_name) %>%
nest() %>%
mutate(model = map(.x = data, .f = ~ lm(formula = price ~ bus_day, data = .x)),
tidy_model = map(model, tidy),
bus_day = seq.POSIXt(from = as.POSIXct(x = "2018-01-01 05:00:00", tz = "MST"),
to = as.POSIXct(x = "2018-01-05 05:00:00", tz = "MST"),
by = "day"),
yhat2018 = map2(.x = model, .y = bus_day, .f = ~ add_predictions(model = .x, data = data.frame(bus_day = .y)))) %>%
select(yhat2018) %>%
unnest()
Any suggestions?