Hi,
I would like to get the coefficients from a rolling regression, using modeltime or tidymodel. So, for the sake of this example, I will be working with FANG dataset from the library "tidyquant".
The packages I will be using is this:
library(tidyselect)
library(tidyquant)
library(modeltime)
library(timetk)
The dataset I will be working with is FANG:
data <- FANG %>%
select(date, symbol, adjusted) %>%
pivot_wider(names_from = symbol,
values_from = adjusted)
Now, let suppose I want to run a rolling window regression, with a fixed width window of 20 observation. The regression I want to run is the following:
Y_t = \alpha X_{1t} + \beta X_{2t} + \gamma X_{3t} such that \alpha + \beta + \gamma = 1.
Y_t is FB, X_{1t} is AMZN, X_{2t} is NFLX and X_{3t} is GOOG.
The expected result is a matrix with the estimated coefficients and the date of the last observation used for estimating.
Any ideias?
How can I do it?