6
$\begingroup$

The lme4 package in R includes the cake dataset.

library(lme4)
head(cake[,2:4], 20)
   recipe temperature angle
1       A         175    42
2       A         185    46
3       A         195    47
4       A         205    39
5       A         215    53
6       A         225    42
7       B         175    39
8       B         185    46
9       B         195    51
10      B         205    49
11      B         215    55
12      B         225    42
13      C         175    46
14      C         185    44
15      C         195    45
16      C         205    46
17      C         215    48
18      C         225    63
19      A         175    47
20      A         185    29

I've analysed the cake dataset using two different models below. The first model is a 2 factor ANOVA:

summary(aov(angle ~ temperature + recipe, cake))
             Df Sum Sq Mean Sq F value   Pr(>F)    
temperature   5   2100   420.1   6.918 4.37e-06 ***
recipe        2    135    67.5   1.112     0.33    
Residuals   262  15908    60.7                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

...and the second is a mixed effects model, with temperature as a random effect:

lmer(angle ~ recipe + (1| temperature), data=cake, REML=F)
Linear mixed model fit by maximum likelihood 
Formula: angle ~ recipe + (1 | temperature) 
   Data: cake 
  AIC  BIC logLik deviance REMLdev
 1893 1911 -941.7     1883    1877
Random effects:
 Groups      Name        Variance Std.Dev.
 temperature (Intercept)  6.4399  2.5377  
 Residual                60.2560  7.7625  
Number of obs: 270, groups: temperature, 6

Fixed effects:
            Estimate Std. Error t value
(Intercept)   33.122      1.320  25.093
recipeB       -1.478      1.157  -1.277
recipeC       -1.522      1.157  -1.315

Correlation of Fixed Effects:
        (Intr) recipB
recipeB -0.438       
recipeC -0.438  0.500

Is someone able to provide a summary of what the mixed effect model has done differently to the ANOVA?

$\endgroup$
6
$\begingroup$

I'm absolutely not a specialist, but this is my contribution:

  • In your ANOVA model, you treated both 'recipe' and 'temperature' as fixed factors, which can be thought of in terms of differences.

  • In your linear mixed model, you treated 'temperature' as a random factor, which is defined by a distribution and whose values are assumed to be chosen from a population with a normal distribution with a certain variance. It turns out that the corresponding output is now an estimate of this variance (line labeled 'temperature' in the Random effects section). And you can notice that the output for the 'recipe' is indeed an estimate for mean-differences (lines labeled recipeB and recipeC in the Fixed effects section).

$\endgroup$
  • $\begingroup$ Interesting that @EpiFunky is right, and I am pretty sure I am right too, but we gave such different answers! $\endgroup$ – Peter Flom Apr 17 '13 at 18:03
4
$\begingroup$

Very briefly: In a two factor ANOVA (or, more generally, in a model that can be analyzed with lm in R) variables are controlled for. That is, it asks "Holding other independent variables constant, what is the linear relationship of each independent variable with the dependent variable?" Such models have a number of assumptions, key here is that they assume that the errors (as estimated by the residuals) are independent. Often, this is reasonable; also, often, it is not. In the cake data set it is not, because each recipe is tested multiple times, and surely the errors from the model will be more similar within each recipe than across recipes.

Mixed models relax this assumption.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.