Re: [R] Row-by-row regression on matrix

2007-09-19 Thread Charles C. Berry
> system.time( lm( t(y) ~ x ) ) user system elapsed 0.008 0.000 0.010 On Wed, 19 Sep 2007, [EMAIL PROTECTED] wrote: > Folks, > > I have a 3000 x 4 matrix (y), which I need to regress row-by-row against a > 4-vector (x) to create a > matrix lm.y of intercepts and slopes. To illust

Re: [R] Row-by-row regression on matrix

2007-09-19 Thread Chuck Cleland
[EMAIL PROTECTED] wrote: > Folks, > > I have a 3000 x 4 matrix (y), which I need to regress row-by-row against a > 4-vector (x) to create a > matrix lm.y of intercepts and slopes. To illustrate: > > y <- matrix(rnorm(12000), ncol = 4) > x <- c(1/12, 3/12, 6/12, 1) > > system.time(lm.y <- t(appl

Re: [R] Row-by-row regression on matrix

2007-09-19 Thread Sundar Dorai-Raj
[EMAIL PROTECTED] said the following on 9/19/2007 9:50 AM: > Folks, > > I have a 3000 x 4 matrix (y), which I need to regress row-by-row against a > 4-vector (x) to create a > matrix lm.y of intercepts and slopes. To illustrate: > > y <- matrix(rnorm(12000), ncol = 4) > x <- c(1/12, 3/12, 6/12,

[R] Row-by-row regression on matrix

2007-09-19 Thread murali . menon
Folks, I have a 3000 x 4 matrix (y), which I need to regress row-by-row against a 4-vector (x) to create a matrix lm.y of intercepts and slopes. To illustrate: y <- matrix(rnorm(12000), ncol = 4) x <- c(1/12, 3/12, 6/12, 1) system.time(lm.y <- t(apply(y, 1, function(z) lm(z ~ x)$coefficient)))