# [R] Help wilth lme for repeted measures design

Nicholas Lewin-Koh nikko at hailmail.net
Fri Nov 14 16:55:15 CET 2003

```Hi,
I am trying to figure out how to specify the model for a repeated
measures experiment using lme. I have the following structure for the
experiment:
There are 3 sites and at each site there are two depths, so site and
depth are crossed. At each site and depth there are 12 fragments of
Coral, each representing a seperate genotype, so genotype is crossed with
site and depth. On each coral fragment the size of 6 coralites is
measured so coralite is nested in fragment. Now in the model genotype
should be a random effect, and we are trying to measure the effect of
depth and site. So I fit the model
mod1<-lme(Factor1~Islands*Depths+Frags:Depths+Frags:Islands +
Frags:Depths:Islands,dhfactan,random=~1|Frags/Corallites)

and

anova(mod1)
numDF denDF   F-value p-value
(Intercept)              1   289  0.000000  1.0000
Islands                  2   289  2.503565  0.0836
Depths                   1   289 10.022984  0.0017
Islands:Depths           2   289  3.772553  0.0241
Depths:Frags            22   289  7.970114  <.0001
Islands:Frags           22   289  7.806390  <.0001
Islands:Depths:Frags    22   289  6.554670  <.0001

Now I know I have done something wrong here becuase there seem to be far
too many degrees of freedom
in the denominator. I am not sure if this is due to how I coded the data
frame or how I specified the model.
The data frame looks like

Corallites Frags Islands Depths    Factor1
1           1     1       1      1  0.9476487
2           2     1       1      1  0.4810762
3           3     1       1      1 -0.2544952
4           4     1       1      1 -0.3711468
5           5     1       1      1 -1.0486175
6           6     1       1      1 -0.9323673
7           1     2       1      1  0.6410660
8           2     2       1      1  0.7590714
9           3     2       1      1  2.3403437
10          4     2       1      1  1.8750632
11          5     2       1      1  0.7945611
12          6     2       1      1  2.0533272

Where Factor1 is the response. Any advice is much appreciated.

Thanks
Nicholas

```