[R] Linear regressions: producing multiple outputs

Gabor Grothendieck ggrothendieck at gmail.com
Thu Feb 17 14:34:16 CET 2011


On Wed, Feb 16, 2011 at 1:13 PM, RTSlider <rob.t.slider at gmail.com> wrote:
>
> Hello all,
> I’m running simple linear regressions on multiple species of plants,
> comparing abiotic factor X against plant trait Y (e.g. Species1: leaf length
> vs air temperature).
>
> Ideally, what I’m looking for is an output giving me the R2, p value,
> coefficient, and Y intercept for each regression. Something like the example
> below:
>
> Species1: leaf length vs air temperature
>        R2 = 0.10       p = 0.50        m = 5.23        b = 12.2
> Species2: leaf length vs air temperature
>        R2 = 0.10       p = 0.50        m = 5.23        b = 12.2
>
> Species1: leaf length vs snow-free date
> R2 = 0.10       p = 0.50        m = 5.23        b = 12.2
> Species2: leaf length vs snow-free date
> R2 = 0.10       p = 0.50        m = 5.23        b = 12.2
>
> I currently have my data in this form:
> Species LeafLength              AirTemp.        SnowFreeDate
> Species1        1.1                     20              160
> Species2        4.5                     20              160
> Species3        5.4                     20              160
>
> And thought I could try this formula:
> lm(formula = LeafLength~AirTemp, SnowFreeDate | Species)
>
> But R is not a fan of it.
> Is there a way to do this (or get something remotely close to this)?
> I realize the output will probably be a bit messier than this, but what I’m
> really looking to avoid is running these regressions individually.
>

lmList in lme4 supports that notation.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list