[R-sig-eco] quadratic factor
Simon Blomberg
s.blomberg1 at uq.edu.au
Fri Aug 15 07:12:27 CEST 2008
To include a quadratic term, use I(Dor^2) instead of Dor^2. The problem
is that R interprets Dor^2 as a formula term ie the main effect as well
as the second-order interaction of Dor with itself (which is just Dor).
Using the I() construct tells R to treat the enclosed expression as a
mathematical expression.
Cheers,
Simon.
On Thu, 2008-08-14 at 21:30 -0700, Lingbo Li wrote:
> Hello R expert,
>
> I have fish length and corresponding otolith size at six times for 30 fish. Firstly, I use a linear mixed effect model to correlate the fish length (L) with otolith size in dorsal radius (Dor). Since the residuals are domeshaped, I then tried to add a quadratic factor. However, as the summary shown below, the quadratic factor was missing in the analysis. WHY?
>
> Thank you very much.
>
> Lingbo
>
>
> > back<-read.table("back.r", header=T)
>
> > attach(back)
>
> > names(back)
>
> [1] "Fish" "Treat" "Mark" "L" "Dor" "Dis" "Ven" "Width"
>
> > library(nlme)
>
> > ldor.lme=lme(L~Dor, random=~1|Fish)
>
> > ldor11.lme=lme(L~Dor+Dor^2, random=~1|Fish)
>
> > summary(ldor11.lme)
>
> Linear mixed-effects model fit by REML
>
> Data: NULL
>
> AIC BIC logLik
>
> 1539.336 1552.063 -765.6682
>
>
>
> Random effects:
>
> Formula: ~1 | Fish
>
> (Intercept) Residual
>
> StdDev: 31.90245 13.00981
>
>
>
> Fixed effects: L ~ Dor + Dor^2
>
> Value Std.Error DF t-value p-value
>
> (Intercept) -30.74635 9.775326 149 -3.14530 0.002
>
> Dor 157.14556 3.157083 149 49.77556 0.000
>
> Correlation:
>
> (Intr)
>
> Dor -0.797
>
>
>
> Standardized Within-Group Residuals:
>
> Min Q1 Med Q3 Max
>
> -2.47279716 -0.59191227 -0.09822955 0.49939862 3.12757256
>
>
>
> Number of Observations: 180
>
> Number of Groups: 30
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
--
Simon Blomberg, BSc (Hons), PhD, MAppStat.
Lecturer and Consultant Statistician
Faculty of Biological and Chemical Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au
Policies:
1. I will NOT analyse your data for you.
2. Your deadline is your problem.
The combination of some data and an aching desire for
an answer does not ensure that a reasonable answer can
be extracted from a given body of data. - John Tukey.
More information about the R-sig-ecology
mailing list