[R] Linear regressions: producing multiple outputs

Toby Marthews toby.marthews at ouce.ox.ac.uk
Thu Feb 17 12:40:09 CET 2011


Hi RTSlider,

I suspect you rather need to use the lme command (or perhaps glmmPQL or lmer) because you have a random predictor?

   lme(fixed=LeafLength~AirTemp*SnowFreeDate,random=~1|Species)

See http://socserv.mcmaster.ca/jfox/Books/Companion-1E/appendix-mixed-models.pdf for a tutorial on lme.

Toby

________________________________________
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of RTSlider [rob.t.slider at gmail.com]
Sent: 16 February 2011 18:13
To: r-help at r-project.org
Subject: [R] Linear regressions: producing multiple outputs

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.

--
View this message in context: http://r.789695.n4.nabble.com/Linear-regressions-producing-multiple-outputs-tp3309411p3309411.html
Sent from the R help mailing list archive at Nabble.com.

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



More information about the R-help mailing list