Hi,

I would like to fit lm-models to a matrix with 'samples' of a dependent 
variable (each row represents one sample of the dependent variable).
The independent variable is a vector that stays the same:


y <- c(1:10)
x <- matrix(rnorm(5*10,0,1), 5, 10)



now I would like to avoid looping over the rows, since my original matrix is 
much larger;



for(t in 1:dim(x)[1]) {

        print(lm(y ~ x[t,]))

}


Is there a time-efficient way to do this?

______________________________________________
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