I have to do roll regression based on the Daily data. I use the past three weeks of daily returns as the estimation window and the regression is estimated rolling forward one week at a time generating time series estimates of beta. I know I should use the rollapply in zoo package. but I am not sure how to do.
data example: stock day week y x "00001" 2009-01-02 2009-01 0.89 2.45 "00001" 2009-01-03 2009-01 1.21 1.90 "00001" 2009-01-04 2009-01 0.12 0.89 "00001" 2009-01-05 2009-01 1.45 2.78 "00001" 2009-01-06 2009-01 1.98 0.98 "00001" 2009-01-09 2009-02 3.34 1.23 "00001" 2009-01-10 2009-02 0.12 0.89 "00001" 2009-01-11 2009-02 1.45 2.78 "00001" 2009-01-13 2009-02 1.98 0.98 "00001" 2009-01-16 2009-03 3.38 0.93 "00001" 2009-01-17 2009-03 6.56 3.90 "00001" 2009-01-18 2009-03 5.09 3.45 "00001" 2009-01-19 2009-03 5.89 3.78 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.