[R] regression for several responses
Spencer Graves
spencer.graves at pdf.com
Fri Jun 27 21:07:33 CEST 2003
Great suggestions, Thomas. Consider the following:
> y <- as.matrix(data.frame(y1=rep(1:4, each=2), y2=0.01*rnorm(8)))
> x <- 1:8
> coef(lm(y~x))
y1 y2
(Intercept) 0.3571429 0.011181184
x 0.4761905 -0.001528493
hth. spencer graves
Thomas W Blackwell wrote:
> Martin -
>
> My recollection is that if the left hand side in a model formula
> is a matrix (in your case an [n x 100] matrix) then either lm()
> or glm() will return a matrix of coefficients. These are the point
> estimates for a multivariate regression (meaning, multivariate
> response). I hunted just a bit: help("lm"), help("glm"),
> help.search("multivariate"), but I have not found where this
> behavior is documented in R. I'm sure it is documented somewhere.
>
> - tom blackwell - u michigan medical school - ann arbor -
>
> On Fri, 27 Jun 2003, Martin Wegmann wrote:
>
>
>>hello,
>>
>>I only want to get the slope of a linear regression of ca. 100 variables
>>against time.
>>
>>I can do for each response (100 times)
>>var1.lm <- lm(response~predictor)
>>
>>but I thought that there might be an easier way of doing this. If I am
>>including more variables it is doing a multiple regression and the output
>>(slope) differs.
>
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list