# NOT RUN {
n_vars <- 10
n_obs <- 1000
x <- matrix(rnorm(n_obs * n_vars), nrow = n_obs, ncol = n_vars)
y <- matrix(rnorm(n_obs), nrow = n_obs, ncol = 1)
# Rolling principal component regressions
result <- roll_pcr(x, y, 252, comps = 1)
# Rolling principal component regressions with exponential decay
weights <- 0.9 ^ (251:0)
result <- roll_pcr(x, y, 252, comps = 1, weights)
# }
Run the code above in your browser using DataLab