Hi.

I would like to run a mixed effects model, but there's one aspect of  
the model that I don't know how to code. My goal is to analyze data  
from an experiment in which I tested the swimming performance (i.e.,  
Umax) of two species of fish from 4 different lakes (a sample of the  
data is below). Each fish was tested when it was rested and when it  
was tired, and each test was performed at the fishes' acclimation  
temperature and at an elevated test temperature. So, there are four  
repeated measures for each subject (i.e., fish). The effects are  
hierarchical and can be listed as such:

Lake (random effect with 4 levels)
Species (fixed effect with 2 levels) nested within Lake
Subject (random effect) nested within Species
Temperature (fixed effect with 2 levels) nested within Subject,  
crossed with Fatigue
Fatigue (fixed effect with 2 levels) nested within Subject, crossed  
with Temperature

So, using the lme function, the model should look something like this:

z <- lme(Umaxcm ~ Species*Temp*Fatigue, random= ~ 1 | Lake/Species/Sub/ 
(Temp*Fatigue))

The problem is how to specify that the Temp*Fatigue factorial  
treatments are nested within Subject (each subject was tested at both  
temperatures at both fatigue levels). Using the above formula is not  
correct (it gives the error message: Invalid formula for groups).

If I use the following formula, lme returns a df value that is three  
times higher than it should be for the tests of the effect of  
temperature and fatigue (i.e., it considers repeated measures on a  
single individual as independent):

z <- lme(Umaxcm ~ Species*Temp*Fatigue, random= ~ 1 | Lake/Species/Sub)

If I use the following formula, lme returns a df value that is twice  
as high as it should be for the test of the effect of Fatigue:

z <- lme(Umaxcm ~ Species*Temp*Fatigue, random= ~ 1 | Lake/Species/Sub/ 
Temp/Fatigue)

Can anyone please help me figure out how to code this model so that  
the effects of Temperature and Fatigue are tested properly?

Here's the sample data:

   Sub Lake Species Temp Umaxcm Fatigue
1 PWD1      PWD           E   acclim      41.83   rested
2 PWD1      PWD           E   acclim      35.08   tired
3 PWD1      PWD           E   test      42.00   rested
4 PWD1      PWD           E   test      31.75   tired
5 PWD2      PWD           H   acclim      39.58   rested
6 PWD2      PWD           H   acclim      44.92   tired
7 PWD2      PWD           H   test      51.00   rested
8 PWD2      PWD           H   test      47.08   tired

Sincerely,

Jon Mee
UBC Dept. of Zoology
Vancouver, BC
	[[alternative HTML version deleted]]


