# [R] lme with poly(x,2) terms

Andrew Beckerman a.beckerman at sheffield.ac.uk
Wed Jul 7 15:09:18 CEST 2004

```Hi there.

Mac OSX 3.3.4 R 1.9.1

I am analysing a data set with the following model

m4<-
lme(fixed=sr~time*poly(energy,2)*poly(dist,2),random=~time|pot,data=deh)

where time is one of six months, pot is a jar in which the repeated
measures of species number (sr) was made.  energy and dist
(disturbance) are fixed experimental treatments. We are trying to test
the hypothesis that there is an interaction between energy and
disturbance that varies through time, with the expectation that sr
varies quadratically with energy and with disturbance.  Our difficulty
is interpreting the various outputs from the model, assuming it is
specified correctly - sorry if this is more a stats question than a R
mechanics question.

summary(m1) and anova(m1) produce the tables below the --------.

Q1) Am i correct to assume that the anova table is sequential?
Q2) How does one interpret the fixed effects/"coefficients table"?  Do
the insignificant terms for poly(dist)2 all the way down (Up) to its
main effect suggest that a quadratic function in dist is not
significant?
Q3) If we remove the quadratic term in dist and compare it to the model
with poly(dist,2), the anova says the polynomial is significant

> anova(update(m2,~.,method="ML"),update(m4,~.,method="ML"))
Model df      AIC      BIC    logLik
Test L.Ratio p-value
update(m2, ~., method = "ML")     1 16 2781.683 2858.271 -1374.841
update(m4, ~., method = "ML")     2 22 2771.380 2876.688 -1363.690 1 vs
2  22.303  0.0011

despite only the main effect of poly(dist,2) being significant in the
terms. Is the best approach to use the anova test or the coefficients?
How does one justify the insignificance of every term with poly(dist)2
in it?

andrew

---------------------------------
>summary(m1)
Linear mixed-effects model fit by REML
Data: deh
AIC      BIC    logLik
2687.974 2792.830 -1321.987

Random effects:
Formula: ~time | pot
Structure: General positive-definite, Log-Cholesky parametrization
StdDev    Corr
(Intercept) 1.5503393 (Intr)
time        0.1858609 -0.862
Residual    0.9234853

Fixed effects: sr ~ time * poly(energy, 2) * poly(dist, 2)
Value Std.Error  DF   t-value
p-value
(Intercept)                            8.2424   0.14576 721  56.54737
0.0000
time                                  -1.1447   0.02376 721 -48.16926
0.0000
poly(energy, 2)1                      18.2052   4.34118 721   4.19361
0.0000
poly(energy, 2)2                     -43.8133   4.34213 721 -10.09028
0.0000
poly(dist, 2)1                        -9.9600   4.34169 721  -2.29403
0.0221
poly(dist, 2)2                       -10.6639   4.34198 721  -2.45599
0.0143
time:poly(energy, 2)1                  1.7320   0.70705 721   2.44961
0.0145
time:poly(energy, 2)2                  5.6245   0.70695 721   7.95608
0.0000
time:poly(dist, 2)1                   -0.6569   0.70701 721  -0.92908
0.3532
time:poly(dist, 2)2                    0.0400   0.70697 721   0.05657
0.9549
poly(energy, 2)1:poly(dist, 2)1      356.6786 128.77967 721   2.76968
0.0058
poly(energy, 2)2:poly(dist, 2)1      -99.7288 128.60505 721  -0.77547
0.4383
poly(energy, 2)1:poly(dist, 2)2      -11.4295 129.65263 721  -0.08816
0.9298
poly(energy, 2)2:poly(dist, 2)2      149.5420 129.80979 721   1.15201
0.2497
time:poly(energy, 2)1:poly(dist, 2)1 -79.3803  20.96606 721  -3.78613
0.0002
time:poly(energy, 2)2:poly(dist, 2)1  59.4570  20.93577 721   2.83997
0.0046
time:poly(energy, 2)1:poly(dist, 2)2 -20.6131  21.10723 721  -0.97659
0.3291
time:poly(energy, 2)2:poly(dist, 2)2 -22.3304  21.13159 721  -1.05673
0.2910

> anova(m4)
numDF denDF   F-value p-value
(Intercept)                            1   721  888.6686  <.0001
time                                   1   721 2321.2473  <.0001
poly(energy, 2)                        2   721   77.1328  <.0001
poly(dist, 2)                          2   721   22.9940  <.0001
time:poly(energy, 2)                   2   721   34.6873  <.0001
time:poly(dist, 2)                     2   721    0.4551  0.6345
poly(energy, 2):poly(dist, 2)          4   721    2.5824  0.0361
time:poly(energy, 2):poly(dist, 2)     4   721    6.1290  0.0001

```