[R] rollingRegression() aplied between vector and matrix

rcoder mpdotbook at gmail.com
Sat Aug 2 14:35:09 CEST 2008


Hi everyone,

I'm trying to use the rollingRegression() function to apply regression over
a rolling 'window' to some tine series data. Currently, I have:

#Code start
vec<-c(1:100)
mat<-matrix(abs(rnorm(1000)), nrow=100,ncol=100)
mat[,5]<-c(NA)
if(!all(is.na(mat))) {RegData<-rollingRegression(vec~mat,10)}
#Code end

I get the following error message: 
Error in eval(predvars, data, env) : not that many frames on the stack

I know the arguments in the rollingRegression() function are: (formula,
data, window), so I then combined the vector and matrix into a single data
frame as follows:

#Code start
vec<-c(1:100)
mat<-matrix(abs(rnorm(1000)), nrow=100,ncol=100)
mat[,5]<-c(NA)
comb<-data.frame(cbind(vec,mat))
if(!all(is.na(comb))) {RegData<-rollingRegression(vec~mat,comb,10)}
#Code end

...I get the following error message: 
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 
  0 (non-NA) cases

Can anyone see what I am doing incorrectly? I hope the example code helps.

Thanks,

rcoder
-- 
View this message in context: http://www.nabble.com/rollingRegression%28%29-aplied-between-vector-and-matrix-tp18788824p18788824.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list