aov and lme are not the same functions. aov is a wrapper for lm, the general linear model function. For balanced designs and one or two random levels, aov can cope with a random term by fitting linear models to different error strata (according to the help files). Significance testing is done using appropriate F statistics.
lme, on the other hand, fits a genuine mixed effects model using maximum likelihood (or REML) to obtain estimates of the parameters of the model. They are not required to give the same estimates.
It is also possible that your formulae are miss-specified, but I can't tell from the information you have supplied in the question. I don't see where there are two levels in the model. You have a 2x2 factorial with two replicates (the tanks) at each treatment level. The "tank effect" is simply the residual error -- unless you are taking several measurements from each tank.
Later
I simulated some data based on the OP's problem: a 2x2 factorial with 2 replicates at each level (the tank) and 9 measurements from each tank. There are 3 ways to analyse these data
- Use aov and the formula given by the OP
- Use lme (resp lmer) and the formula given by the OP
- Take the mean survivorship within each tank and use oav() on the means.
All three methods lead to the same conclusions. The first and the third produce numerically identical F statistics (as they should, given the problem is balanced).
aov and lme give different output. To see the coefficients for pH and temp you need to do coef() on the output of the aov() function. I got identical estimates. The p-values are slightly different, as one would expect given a different model, different estimation and different test statistic.
Notice that you get 7 degrees of freedom in the aov() model. The treatments are randomized to the 8 tanks, so basically, the sample size is 8. Taking repeated measurements in each tank gives a more precise measurement of whatever is going on inside each tank -- which is good -- but in a sense, this is still an experiment in which n=8.
So, you want to model one effect, date (see comments below). And three predictors. Based on what I know now I would say this is the way to go:
m.nlme = lmer(aphid ~ temperature*predator*species + 1|date,
data = My.Data)
This model assumes no nested structure. What part of the design makes you want to use a nested structure?
Best Answer
It doesn't make sense to both include tank as a random effect and nest tank within the pop/temp fixed effect. You only need one of these, depending on how tank is coded.
If tank is coded 1-8, you only need the tank random effect. Nesting it within the pop/temp fixed effect results in the same 8 units, so is not necessary.
If tank is coded 1-2 (that is, which rep it was), you only need to nest tank within the pop/temp fixed effect, because that gives you your 8 unique tanks. Including the tank random effect is only desired if the tanks were first divided into two groups and then randomized to treatment; if the eight tanks were completely randomized to treatment, this is not necessary.
You could do this with likelihood based solutions such those in
nlme
andlme4
but if everything is balanced, it might be simpler to use the traditional ANOVA approach usingaov
.Creating some sample data:
Using
aov
like this:or
lme
like this: