[R] nested design in lme, need help with specifying model

Mike Dunbar mdu at ceh.ac.uk
Mon Feb 26 12:12:36 CET 2007

Dear Radka

I'm not sure I quite understand your design and quite where the nesting comes in.

But a quick suggestion is why are you adding species as random as well as fixed? I don't think you can do this or indeed should do it. I think this is why you get problems with your fixed effects. If you have 3 species then species ought to be fixed. Replicate is more the sort of effect that ought to be random, this ought to pick up the fact that prey within one run of the experiment won't be independent. But if you only have two replicates per treatment (species of prey?), then this will limit your ability to detect differences between species of prey, unless your within-replicate variation is very low. You can look at this very simply but not quite as powerfully by averaging the responses for each replicate and doing a non nested anova.

Re your second analysis, this seems along the right lines. How have you coded replicate? This may explain your results. Without more details on the plot you did its difficult to help further.



>>> Radka Ptacnikova <rpichlova at yahoo.com> 25/02/2007 23:32 >>>

I wonder if anyone can help me with specifying a right model for my analysis. I am a beginner to lme methods and though have spent already many hours studying from various books an on-line helps, I was unfortunately not able to find a solution to my problem on my own. 

Data structure:
I studied escape behavior of three species of a prey to a predator. The prey specimens (many) were in a vessel, together with one predator. Escape responses were video-recorded when a prey approached the predator close enough and jumped consequently away. Each set was run twice with a fresh predator and a fresh set of the prey specimens, leading to two replicates per treatment. Unequal number of shots (i.e. prey specimens) were analyzed in each of the two replicates for each of the three prey species (range 11-19). The data are therefore unbalanced and also variance for treatments/replicates is far from being homogeneous, so that a nested anova is not a good choice here. As the number of prey specimens was rather high, I assume that each shot represents a different prey individual. 

My questions:
1) Do the three prey species significantly differ in their escape response?
2) What was variability between replicates within a species and how much did it contribute to overall variability?

Now, to my best understanding, the model should be:

mod1<-lme(Escape.parameter~Species, random=~1|Species/Replicate)

as I am interested in Species as fixed effects and want to know variability caused by Replicates nested within Species as random effects. However, when running this model, I get 

Random effects:
 Formula: ~1 | Species
StdDev:    2.937479

 Formula: ~1 | Replicate %in% Species
        (Intercept) Residual
StdDev:    4.973931 4.266302

Fixed effects: Max_speed ~ Species 
                Value Std.Error        DF   t-value p-value
(Intercept) 23.792040  4.798143 39  4.958593       0
Spec2     -7.121766  6.747930   0 -1.055400     NaN
Spec3      -9.779830  6.725391  0 -1.454165     NaN

So I get variance within species and within replicates, but what the hell are these zero DF's, leading to zero p's and how should I interpret them?

Another model I tried was:
mod2<-lme(Escape.parameter~Species, random=~1|Replicate)

Random effects:
 Formula: ~1 | Replicate
         (Intercept) Residual
StdDev: 0.0002733313 5.180472

Fixed effects: Max_speed ~ Species
                              Value Std.Error        DF   t-value       p-value
(Intercept)                26.00364  1.561971  41  16.647963   0e+00
SpeciesSpec2          -7.93297  2.056430  41  -3.857641   4e-04
SpeciesSpec3        -11.81048  1.962713  41  -6.017425   0e+00

Alright, I get the among species differences, but I am confused here with the very low StdDev of Replicate as a random effect, since I know f.ex. from a plot, that it is relatively high. Which leads me to thinking, that something is wrong here. 

I'd appreciate any hints and suggestions.


Never Miss an Email

R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 
and provide commented, minimal, self-contained, reproducible code.

This message (and any attachments) is for the recipient only...{{dropped}}

More information about the R-help mailing list