### Random and Mixed Effects ANOVA

```Fixed, Random, and Mixed
Effects ANOVA
And Nesting and Crossing of
Factors
Sampling Fractions
• Sampling fraction, sf, for classification
variable = levels in the sample divided by
levels in the population.
• If the sample includes every level in the
population of interest, sf = 1. This is a fixed
effect.
• If the sample has a random set of levels,
then sf = integer/ =0. This is a random
effect.
Fixed Effect
• Diagnosis given to patient
– Melancholic depression
– Postpartum depression
– Seasonal affective disorder
• There are no other levels of diagnosis in
which I am interested.
• sf = 3/3 = 1.
Random Effect
• Dose of experimental therapeutic drug
• Population of interest = all values from 0 to
100 units of the drug
• I randomly select 5 values, using SAS
– Do Value=1 To 5;
Dose=round(100*Uniform(0)); Output; End;
• sf =5/ = 0 .
Mixed Effects
• Factorial Design: Group (fixed) x Dose
(random)
• When there are random effects in the
model, one need carefully consider how to
compute the F ratios.
• It will not always be MSeffect / MSerror
How to Compute F
• You want F to be
Effect  Other Stuff
Other Stuff
• See page 433 of Howell for the expected values of
the mean squares for models that include random
factors.
Expected Values for MS
• Main effect of group (fixed)
– Group + Interaction + Error
• Main effect of dose (random)
– Dose + Error
• Interaction of group and dose
– Interaction + Error
• Within cells error (MSE)
– Error
F for Main Effect of Group
MSgroup
Group  Interaction  Error
F

MSGroup Dose
Interaction  Error
• If the null is true, group has no effect, and
we expect the F to equal
0  Interaction  Error
1
Interaction  Error
F for Main Effect of Dose
MSdose
Dose  Error
F

MSerror
Error
• If the null is true, dose has no effect, and we
expect the F to equal
0  Error
1
Error
F for Main Effect of Interaction
MSGroup Dose
Interaction  Error
F

MSerror
Error
• If the null is true, the interaction has no
effect, and we expect the F to equal
0  Error
1
Error
GLM’s Test Statement
Use Test to specify the denominator for any
effect where it should be other than MSE.
proc glm; class group dose; model score =
group|dose / ss3;
Test H = group E = group*dose;
title 'Mixed Effects ANOVA: Group is fixed,
dose is random'; run;
Power Considerations
• Interaction mean squares typically have few
degrees of freedom
• This can lower power, because MS = SS/df,
so the interaction MS tends to be large.
• You may be able to enhance power by
dropping the interaction term from the
model.
Pooled Interaction and Error
• If the p for the interaction term ≥ .25, drop it from
the model.
• Its SS and df are now pooled SSGroup Dose  SSerror
with the error SS and df.
dfGroup Dose  dferror
• You then use this pooled error term in the
denominator of F.
proc glm; class group dose; model score = group
dose / ss3;
title 'Main Effects Only, Interaction Pooled With
Within-Cells Error'; run;
Subjects as a Random Factor
• What we call “error” is really the effect of
subjects (nested within groups).
• We pretend that the values for the subjects
variable are a random sample of the
population of interest.
• If we considered subjects to be a fixed
factor, we would not need ANOVA, we
would have the entire population of interest.
Nested Factors
• Suppose one factor was Households and
another was Neighborhoods.
• Households would be nested within
Neighborhoods – each household is in only
one neighborhood.
• If you know the identity of the household,
you also know the identity of the
neighborhood.
Households Nested Within
Neighborhoods
Nborhd 1 Nborhd 2 Nborhd 3
H1
H6
H11
H2
H7
H12
H3
H8
H13
H4
H9
H14
H5
H10
H15
Crossed Factors
• Here we have each possible combination of level
of Factor A and level of Factor B.
• For example, suppose that one factor is Teachers,
the other is Schools, and each teacher taught at
each of the three schools.
School 1
School 2
School 3
T1
T1
T1
T2
T2
T2
T3
T3
T3
Between Subjects
With this design, the subjects factor is
nested within each level of the grouping
factor(s).
Group 1 Group 2 Group 3
S1
S4
S7
S2
S5
S8
S3
S6
S9
Within Subjects
With this design, the subjects factor is
crossed with the other factor.
Condition 1
Condition 2
Condition 3
S1
S1
S1
S2
S2
S2
S3
S3
S3
Omega Squared
• Its computation in model with random
factors is different than in models with only
fixed effects.
• See pages 438-440 in Howell.
```