Dear R users,

I have run into a very unexpected problem and I was hoping someone could
explain it to me.

I have a 650 000 by 12 matrix and I want to perform a rolling regression on
it, width 36 or 48, using the package performanceAnalytics.

ie: rol.lm<-rollingRegression(lm(y~x1+x2+x3+x4+x5),data=denise,width=36)

The regressions occur without a problem and I store my output (coefficients,
standard errors and r squared value of each regression) in a matrix.  No
error or warning comes up.  Eventually I realise that some of the R squared
values have turned up to be NaN.  Looking at the definition in the help
page: *R^2 = 1 - Sum(R[i]^2) / Sum((y[i]- y*)^2) *
I am sure that the denominator is not zero.  Some of my y's are zero in the
original data, but not enough so that the sum (y-y*) is zero.

What puzzles me more is that going back to the original data and performing
regressions manually on subsets of the data (ie simple lm models), NaN does
not come up but instead for that particular part of the data the R^2 (and
residual standard error) does not change from regression to regression- ie
as I do lm over 36-row intervals I get the same R^2 and residual standard
error for all the regressions.

Any ideas what could be going on?
Thank you all in advance,
Denise

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