[R] Hi

Chuck Cleland ccleland at optonline.net
Tue Jun 16 00:19:45 CEST 2009


On 6/15/2009 5:42 PM, Oscar Bayona wrote:
> Hi I have a simple question. I want to run a "n times" a simple linear
> regession and save beta in a matrix but I´m not able.
> 
> Imagine:
> 
> Data.txt is a 10*5 file and want to run 4 different stimations always
> regressing first column on the rest.
> 
> So I try this:
> 
> First I run Data on memory
> 
> This is my function
> 
> mrp <- function(){
> mr<-matrix(0,4,1)
> for(i in 1:4)
> r(i)=lm(dat(,i+1)~dat(,1)
>  mr[i] <- coefficients(r(i)))
> }
> 
> I execute mrp usin source file choose option but nothing happens....
> 
> Where I´m wrong?

  It's hard to tell exactly what you want, but does this help?

mr <- lm(as.matrix(cbind(dat[,2:ncol(dat)])) ~ dat[,1])

summary(mr)

> 	[[alternative HTML version deleted]] 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-help at 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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list