[R] linear regression on groups of consecutive rows of a matrix

2009-11-24 Thread Jim Bouldin
I want to perform linear regression on groups of consecutive rows--say 5 to 10 such--of two matrices. There are many such potential groups because the matrices have thousands of rows. The matrices are both of the form: shp[1:5,16:20] SL495B SL004C SL005C SL005A SL017A -2649 1.06 0.56

Re: [R] linear regression on groups of consecutive rows of a matrix

2009-11-24 Thread David Winsemius
Perhaps along these lines: 1st #need to decide what your group width is , so the second number inside the extraction call will be that number minus 1: for (x in seq(1:1000, by=6) { temp - na,omit( shp[x:(x+5), ] ) # Need the parens in x:(x+5) lm( formula, data=temp) } Or

Re: [R] linear regression on groups of consecutive rows of a matrix

2009-11-24 Thread Jim Bouldin
But I do feel compelled to ask: Do you really get meaningful information from lm applied to 5 cases? Especially when the predictors used may not be the same from subset to subset??? Thanks again for your help David. Your question is a good one. It's a bit complicated but here's the