Re: [R] Linear regression using matrices

2012-01-04 Thread Mark Sanderson
OK thanks.

In my case I think it might be possible to work around this by reshaping my
data and then using lmlist() to run separate regressions for each data
group. lmlist() is new to me but it looks like it will do the job.


--
View this message in context: 
http://r.789695.n4.nabble.com/Linear-regression-using-matrices-tp4260945p4261368.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] Linear regression using matrices

2012-01-04 Thread iliketurtles
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.

__
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.