The Analysis of Variance (ANOVA) - Part 3

M. Drew LaMar
April 5, 2017

Class Announcements

  • Reading Assignment for Friday (Optional): Chapter 16, Correlation

Planned and unplanned comparisons

So there is a difference between means amongst all groups. Now what? I want to know which means are different from one another!!!

Discuss: Which groups do you think have significantly different means?

Planned comparisons

Definition: A planned comparison is a comparison between means planned during the design of the study, identified before the data are examined.

A planned comparison must have a strong a priori justification, such as an expectation from theory or a prior study.

Only one or a small number of planned comparisons is allowed, to minimize inflating the Type I error rate.

Unplanned comparisons

Definition: An unplanned comparison is one of multiple comparisons, such as between all pairs of means, carried out to help determine where differences between means lie.

Unplanned comparisons are a form of data dredging, so we need to minimize the rising Type I errors that we get from performing many tests.

Unplanned comparison (details)

Definition: With the Tukey-Kramer method, the probability of making at least one Type I error throughout the course of testing all pairs of means is no greater than the significance level \( \alpha \).

library(multcomp)
tukeyResults <- glht(caffResults, 
                     linfct = mcp(ppmCaffeine = "Tukey"))

Unplanned comparison (example)

Unplanned comparison (visualization)

Groups in the figure are assigned the same symbol if their means are not significantly different.

Unplanned comparison (visualization)

Groups in the figure are assigned the same symbol if their means are not significantly different.

Tukey-Kramer Assumptions

  • Same assumptions as ANOVA.
  • \( P \)-value for T-K is exact for balanced designs.
  • \( P \)-value for T-K is conservative for unbalanced designs.
  • Conservative means real probability of making at least one Type I error is smaller than \( \alpha \), which makes it harder to reject \( H_{0} \).

Fixed-effects ANOVA

Definition: Fixed-effects ANOVA is ANOVA on fixed groups, i.e. when different categories of the explanatory variable are
     - predetermined,
     - of direct interest,
     - and repeatable.

Any conclusion reached about differences among fixed groups apply only to those fixed groups.

Random-effects ANOVA

Definition: Random-effects ANOVA is ANOVA on randomly chosen groups, which are groups sampled from a much larger “population” of groups.

Conclusions reached about differences among randomly chosen groups can be generalized to the whole population of groups.

Examples:

  • Geographical site for an observational field study
  • Subject or individual, in a study involving repeated measures on an individual.

Fixed vs Random-effects

Definition: An explanatory variable is called a fixed effect if the groups are predefined and are of direct interest. An explanatory variable is called a random effect if the groups are randomly sampled from a population of possible groups.

Important: The main use of random-effects ANOVA is to estimate variance components, i.e. the amount of the variance in the data that is among random groups and the amount that is within groups.

Examples:

  • Explanatory variables: Genes, Environment
  • Response variable: Phenotypic trait

What explains more of the variance in the phenotype - genes or environment?

Fixed vs Random-effects

Important: The main use of random-effects ANOVA is to estimate variance components, i.e. the amount of the variance in the data that is among random groups and the amount that is within groups.

Examples:

  • Explanatory variables: Genes, Environment
  • Response variable: Phenotypic trait

Question: What explains more of the variance in the phenotype - genes or environment?

Variance components

Single-factor ANOVA with random effects has two levels of random variation in the response variable \( Y \) - the error and the groups.

Definition: The variance within groups in the population is written \( \sigma^2 \), with
\[ \sigma^2 \approx \mathrm{MS}_{\mathrm{error}}. \]

Definition: The variance between groups (second level of random variation in random-effects ANOVA) is the variance among the group means in the population of groups and is denoted \( \sigma_{A}^{2} \). The grand mean \( \mu_{A} \) is the mean of group means.

Variance components

Random-effects ANOVA assumes that the group means are normally distributed, i.e.

\[ \mu_{G} \sim N(\mu_{A},\sigma^{2}_{A}). \]

Definition: The parameters \( \sigma^{2} \) and \( \sigma_{A}^{2} \) are called variance components. They describe all the variance in the response variable \( Y \).

For a balanced design, \( \sigma_{A}^{2} \) can be estimated by

\[ s_{A}^{2} = \frac{\mathrm{MS}_{\mathrm{groups}} - \mathrm{MS}_{\mathrm{error}}}{n}. \]

Repeatability

Definition: Repeatability is the fraction of the summed variance that is present among groups:

\[ \mathrm{Repeatability} = \frac{s_{A}^2}{s_{A}^{2} + \mathrm{MS}_{\mathrm{error}}}. \]

A repeatability near zero indicates that most of the variation is within groups.

A repeatability near one indicates that most of the variation is between groups.

Random-effects ANOVA (Example)

Random-effects ANOVA (Example)

Practice Problem #11

One way to assess whether a trait in males has a genetic basis is to determine how similar the measurements of that trait are among his offspring born to different, randomly chosen females. In a lab experiment, Kotiaho et al. (2001) randomly sampled 12 male dung beetles, Onthophagus taurus, and mated each of them to three different virgin females. The average body-condition score of offspring born to each of the three females was measured. ANOVA was used to test whether males differed in the mean condition of their offspring using the three measurements for each male.

Random-effects ANOVA (Example)

Let's load the data:

dungData <- read.csv("http://whitlockschluter.zoology.ubc.ca/wp-content/data/chapter15/chap15q11DungBeetleCondition.csv")
str(dungData)
'data.frame':   36 obs. of  2 variables:
 $ male              : int  1 1 1 2 2 2 3 3 3 4 ...
 $ offspringCondition: num  0.82 0.44 0.92 0.35 0.19 1.39 0.12 0.84 0.16 0.49 ...

Random-effects ANOVA (Example)

Let's visualize the data (see Chap. 15 R-Pubs):

plot of chunk unnamed-chunk-4

Random-effects ANOVA (Example)

Let's get the variance components. We will use a new package called nlme:

library(nlme)
dungBeetleAnova <- lme(fixed = offspringCondition ~ 1, 
                       random = ~ 1|male, 
                       data = dungData)
(tmp <- VarCorr(dungBeetleAnova))
male = pdLogChol(1) 
            Variance  StdDev   
(Intercept) 0.2361843 0.4859879
Residual    0.1950916 0.4416917

Random-effects ANOVA (Example)

male = pdLogChol(1) 
            Variance  StdDev   
(Intercept) 0.2361843 0.4859879
Residual    0.1950916 0.4416917

(Intercept) corresponds to \( s_{A}^{2} \), which estimates \( \sigma_{A}^{2} \) (variance between groups)

Residual corresponds to \( \mathrm{MS}_{\mathrm{error}} \), which estimates \( \sigma^{2} \) (variance within groups)

Random-effects ANOVA (Example)

Definition: The heritability of a trait is the fraction of variation in the trait in the population that is genetic rather than environmental.

In our example, differences among males indicate a genetic component, because they were randomly mated and their offspring were raised in a common (lab) environment (if properly designed, of course).

In our case, heritability is the same as the repeatability defined earlier, i.e.

\[ \mathrm{Heritability} = \frac{s_{A}^2}{s_{A}^{2} + \mathrm{MS}_{\mathrm{error}}}. \]

Random-effects ANOVA (Example)

Let's calculate heritability:

varAmong  <- as.numeric( tmp[1,1] )
varWithin <- as.numeric( tmp[2,1] )
heritability <- varAmong / (varAmong + varWithin)
heritability
[1] 0.5476408

So an estimated 55% of the variation in offspring body-condition scores was due to genetic differences among males.