[R-SIG-Finance] rolling regression estimate std. error / t value

邓一硕 dengyishuo at 163.com
Wed Jun 1 09:07:50 CEST 2011


快捷回复给:Lu Fan, r-sig-finance
At 2011-05-18 02:41:03,"Lu Fan" <lfanff at gmail.com> wrote:
>Dear all,
>
>The following codes is for a multi-factor rolling regression with rolling
>window = 60:
>
>> z<-read.table("C:/.../dataset.txt")
>> library(zoo)
>> mydata=zoo(z)
>> coef=rollapply(mydata,width=60,function(x) coef(lm(y~f1+f2+f3+f4+f5,
>data=as.data.frame(x))),by.column=FALSE,align="right")
>
>The result is shown below:
>
>     (Intercept)          f1          f2           f3          f4         f5
>60    2.61433094  0.16136881 -0.72852878  -1.62169901 -28.7663294 -1.0079586
>61    2.36795263  0.14779184 -0.72893841  -1.42712190 -28.9783777 -1.0877425
>62    1.80016092  0.13134766 -0.75010570  -0.92525342 -27.2138634 -1.0736837
>63    1.76904728  0.05141441 -0.94569512  -0.34299478 -19.7857978 -0.6615184
>64    2.29169442  0.13725741 -0.65519163  -1.44045686 -24.1101822 -0.8517188
>65    2.19904020  0.16520775 -0.58812883  -1.52981468 -24.9350513 -0.9234610
>66    1.84645778  0.23440231 -0.54350214  -1.42709733 -21.7792819 -0.8785267
>67    1.60558115  0.30913187 -0.25909438  -1.82122203 -21.1839368 -0.8866916
>68    1.49679459  0.31441766 -0.40952404  -1.52307138 -18.5434502 -1.0317272
>69    2.02789774  0.20500137 -0.65737973  -1.34524065 -17.1654126 -0.8685087
>70    2.11604869  0.09416856 -0.93294824  -0.74672358 -16.8795155 -0.8370804
>71    1.73134487 -0.01723606 -1.41291550   0.53813772 -15.0169149 -0.9722847
>
>So these are the regression coefficients; my question is how can I get
>estimate std. error or t-value for these coefficients on a rolling basis?
>Can I also add multicollinearity testing in this code?
>
>Thank you in advance!
>
>	[[alternative HTML version deleted]]
>
>_______________________________________________
>R-SIG-Finance at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>-- Subscriber-posting only. If you want to post, subscribe first.
>-- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list