Message-ID: <49572DDB.8030201@erasmusmc.nl>
Date: 2008-12-28T07:42:19Z
From: Dimitris Rizopoulos
Subject: how to generalize the arguments for lm() (r-help@lists.R-project.org)
In-Reply-To: <295029.92503.qm@web63908.mail.re1.yahoo.com>
you can just use a design matrix on the right hand side of 'formula', e.g.,
factors <- matrix(rnorm(100*10), 100, 10)
y <- rnorm(100)
lm(y ~ factors)
I hope it helps.
Best,
Dimitris
Math Girl wrote:
> Hello,
>
> How could I generalize the following statement for an arbitrary number of columns instead of 7?
>
> result[[i]]<-lm( returns[,i] ~ factors[,1] + factors[,2] + factors[,3] + factors[,4] + factors[,5] + factors[,6] + factors[,7] )
>
> Thank you,
>
> Mathgurl
>
>
>
>
> [[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.
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014