Hi,
Thanks for reply!

Three things:
1.
I did not write that some of the data has more then 31 NA in the column and
then it is not possible to run lm()

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
  0 (non-NA) cases

In this case program should return "NA" symbol and go further, in the case
when length of the observations is shorter then 31 program should always
return "NA" but go further .

2. in your result matrix there are only 4 columns (for estimates of the
coefficients), is it possible to put there 4 more columns with p-values and
one column with R squared

3. basic statistical test for the regressions:

inflation factors can be captured by:
res2 <- do.call(rbind,lapply(lst2,function(x)
rollapply(x,width=32,FUN=function(z)
  vif(lm(r~
F.1+F.2+F.3,data=as.data.frame(z))),by.column=FALSE,align="right")))

and DW statistic:
res3 <- do.call(rbind,lapply(lst2,function(x)
rollapply(x,width=32,FUN=function(z)
  durbinWatsonTest(lm(r~
F.1+F.2+F.3,data=as.data.frame(z))),by.column=FALSE,align="right")))

3a) is that right?
3b) how to do and have in user-friendly form durbinWatsonTest for more then
1 lag?
3c) how to apply: jarque.bera.test from library(tseries) and ncvTest from
library(car) ???




Pozdrowienia,

Tomasz Schabek


On 30 November 2013 07:42, arun <smartpink...@yahoo.com> wrote:

> Hi,
> The link seems to be not working.  From the description, it looks like:
> set.seed(432)
> dat1 <- as.data.frame(matrix(sample(200,154*337,replace=TRUE),ncol=337))
>  colnames(dat1) <- c(paste("F",1:3,sep="."),paste("r",1:334,sep="."))
> lst1 <- lapply(paste("r",1:334,sep="."),function(x)
> cbind(dat1[,c(1:3)],dat1[x]))
>
>  lst2 <- lapply(lst1,function(x) {colnames(x)[4] <-"r";x} )
> library(zoo)
>
> res <- do.call(rbind,lapply(lst2,function(x)
> rollapply(x,width=32,FUN=function(z) coef(lm(r~
> F.1+F.2+F.3,data=as.data.frame(z))),by.column=FALSE,align="right")))
>
> row.names(res) <- rep(paste("r",1:334,sep="."),each=123)
>  dim(res)
> #[1] 41082     4
>
> coef(lm(r.1~F.1+F.2+F.3,data=dat1[1:32,]) )
> #(Intercept)         F.1         F.2         F.3
> #109.9168150  -0.1705361  -0.1028231   0.2027911
> coef(lm(r.1~F.1+F.2+F.3,data=dat1[2:33,]) )
> #(Intercept)         F.1         F.2         F.3
> #119.3718949  -0.1660709  -0.2059830   0.1338608
> res[1:2,]
> #    (Intercept)        F.1        F.2       F.3
> #r.1    109.9168 -0.1705361 -0.1028231 0.2027911
> #r.1    119.3719 -0.1660709 -0.2059830 0.1338608
>
> A.K.
>
>
>
>
>
> On Friday, November 29, 2013 6:43 PM, nooldor <nool...@gmail.com> wrote:
> Hi all!
>
>
> I am just starting my adventure with R, so excuse me naive questions.
>
> My data look like that:
>
> <http://r.789695.n4.nabble.com/file/n4681391/data_descr_img.jpg>
>
> I have 3 independent variables (F.1, F.2 and F.3) and 334 other variables
> (r.1, r.2, ... r.334) - each one of these will be dependent variable in my
> regression.
>
> Total span of the time is 154 observations. But I would like to have
> rolling
> window regression with length of 31 observations.
>
> I would like to run script like that:
>
> summary(lm(r.1~F.1+F.2+F.3, data=data))
> vif(lm(r.1~F.1+F.2+F.3, data=data))
>
> But for each of 334 (r.1 to r.334) dependent variables separately and with
> rolling-window of the length 31obs.
>
> Id est:
> summary(lm(r.1~F.1+F.2+F.3, data=data)) would be run 123 (154 total obs -
> 31. for the first regression) times for rolling-fixed period of 31 obs.
>
> The next regression would be:
> summary(lm(r.2~F.1+F.2+F.3, data=data)) also 123 times ... and so on till
> summary(lm(r.334~F.1+F.2+F.3, data=data))
>
> It means it would be 123 x 334 regressions (=41082 regressions)
>
> I would like to save results (summary + vif test) of all those 41082
> regressions in one read-user-friendly file like this given by e.g command
> capture.output()
>
> Could you help with it?
>
> Regards,
>
> T.S.
>
>     [[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.
>
>

        [[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.

Reply via email to