# \donttest{
data(sample_prices_weekly); data(sample_prices_daily)
mom <- panel_lag(calc_momentum(sample_prices_weekly, 12), 1)
vol <- panel_lag(align_to_timeframe(
calc_rolling_volatility(sample_prices_daily, 20),
sample_prices_weekly$Date, "forward_fill"), 1)
Y <- make_labels(sample_prices_weekly, horizon = 4, type = "log")
fit_lm <- function(X,y){ Xc <- cbind(1,X); list(coef=stats::lm.fit(Xc,y)$coefficients) }
pred_lm <- function(m,X){ as.numeric(cbind(1,X) %*% m$coef) }
S <- roll_fit_predict_seq(list(mom=mom, vol=vol), Y,
steps = 26, horizon = 4,
fit_fn = fit_lm, predict_fn = pred_lm,
is_periods = 104, oos_periods = 4, step = 4)
head(S)
# }
Run the code above in your browser using DataLab