the rolling regression in R using roll apply
问题 My imported data contains 7 variables: Y and X1 , X2 , X3 , X4 , X5 , X6 . I tried applying the rollapply function in zoo in order to run a rolling regression within an in-sample with a window of 262 obs. (work days in a year). date Y X1 X2 1 10/1/07 -0.0080321720 4.690734e-03 3.333770e-03 2 10/2/07 0.0000000000 -2.818413e-03 5.418223e-03 3 10/3/07 0.0023158650 -4.178744e-03 -3.821100e-04 4 10/4/07 -0.0057491710 -5.071030e-03 -8.321550e-04 5 10/5/07 0.0073570500 3.065045e-03 5.179574e-03 6 10