[R] Linear regression using matrices

iliketurtles isaacm200 at gmail.com
Wed Jan 4 13:07:06 CET 2012


I've done a lot of research on this very topic and found a few solutions. But
all the ways I've discovered involve loops.

Applying it to what you want, the best way I've found is to do (stolen from
an experienced R user, of course):

y<-array(rnorm(100),dim=c(10,10))
x<-array(rnorm(100),dim=c(10,10))

regg<-list()
for(i in 1:ncol(y))
 {
 regg[[i]]<-lm(y[,i]~x[,i])
 }

Now the reason I've stuck onto the list() method is because the output is
still in lm() format. So you can write neat functions to extract every
statistic you want off summary(regg[[N]]). 

-----
----

Isaac
Research Assistant
Quantitative Finance Faculty, UTS
--
View this message in context: http://r.789695.n4.nabble.com/Linear-regression-using-matrices-tp4260945p4260988.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list