 
Principles
A common extension of one way ANOVA is to have additional nominal variables (factors) nested within the main factor of interest. By nested we mean that each level of the 'lower' nominal variable occurs in only one level of the 'higher' nominal variable. For example in a trial of fertilizers, we might have 15 plots with 5 plots randomly allocated to each of three treatments. We assess yield on just one plant in each plot. In this case our plots are nested in treatment because any particular plot only gets one of the three treatment levels. But since we only have one observation for each plot, we use these observations as replicates in a simple oneway ANOVA.
However, we may consider that there is too much variation between plants within plots to rely on the yield of just one plant. Hence we measure yield on (say) 20 different plants in each plot. Plot becomes a second (nested) factor in the experiment, but plots still consitute the replicates for the treatment factor (they were the unit randomly allocated to treatment). Since any particular plant only occurs in one plot, the variable 'plant' is nested within plot. Plants therefore become 'replicates' for the plot factor and are properly termed evaluation units. They do not constitute replicates for the treatment factor.
If the top level nominal variable (in this case treatment) is a fixed factor (for example treatment), and the lower level nominal variable is a random variable, then we are dealing with a mixed effects nested ANOVA. If the top level nominal variable is a random factor, and the lower level nominal variable is a random variable, then we have a random effects (or pure Model II) nested ANOVA. In nested ANOVA all lower level nominal variables are usually random factors.
As in oneway ANOVA, in nested ANOVA we compare two estimates of the null population's variance: one derived from the variance of the sample means about their overall (grand) mean, and the other obtained by combining the variances of each group of observations about their respective group mean. But there is a crucial difference between a nested ANOVA and a simple oneway ANOVA. In a simple one way ANOVA you have a single error term. In a nested ANOVA you have several different error terms reflecting each level of the hierarchy. Hence in a two level nested ANOVA one calculates a separate Fratio for each level.
Model & expected mean squares
The mixed effects nested ANOVA with the top level nominal variable a fixed factor is based on the following mathematical model:
Factor A fixed, factor B random
Y_{ijk} = μ
 +
 α_{i
}  +
 B_{j{i}
}  +
 ε_{ijk
}   
where:
 Y_{ijk} is the kth observation in subgroup j of group i,
 μ is the population (grand) mean,
 α_{i} is the fixed effect for the ith level of factor A,
 B_{j{i}} is the random effect for the jth subgroup of the ith group.
The notation B_{j{i}} indicates that the effect of level B_{j} is nested within A,
 ε_{ijk} is the random error effect.

Source of variation
 df
 Expected MS
 Variance ratio


1.  Groups
 a1
 σ^{2
}  + nσ^{2}_{B {α}
}  + nbΣα^{2}/(a1)
 MS_{1}/MS_{2
} 
2.  Subgroups w'in groups
 (b1)a
 σ^{2
}  + nσ^{2}_{B {α}
} 
 MS_{2}/MS_{3
} 
3.  Residual
 (n1)ab
 σ^{2
} 



Total variation
 N1




  
where
 a is the number of groups, and b is the number of subgroups in each group,
 n is the number of observations per subgroup, and N is the total number of observations (= abn),
 σ^{2} is the error variance,
 nσ^{2}_{B {α}} is the subgroups within group variance component,
 nbΣα^{2}/(a1) is the added group component.

Random effects nested ANOVA (both factors random) is based on the following mathematical model:
Factors A and B both random
Y_{ijk} = μ
 +
 A_{i
}  +
 B_{j{i}
}  +
 ε_{ijk
}   
where:
 Y_{ijk} is the kth observation in subgroup j of group i,
 μ is the population (grand) mean,
 A_{i} is the random effect for the ith level of factor A,
 B_{j{i}} is the random effect for the jth subgroup of the ith group.
The notation B_{j{i}} indicates that the effect of level B_{j} is nested within A,
 ε_{ijk} is the error term.

Source of variation
 df
 Expected MS
 Variance ratio


1.  Groups
 a1
 σ^{2
}  + nσ^{2}_{B {α}
}  + nσ^{2}_{A
}  MS_{1}/MS_{2
} 
2.  Subgroups w'in groups
 (b1)a
 σ^{2
}  + nσ^{2}_{B {α}
} 
 MS_{2}/MS_{3
} 
3.  Residual
 (n1)ab
 σ^{2
} 



Total variation
 N1




  
where
 a is the number of groups, and b is the number of subgroups in each group,
 n is the number of observations per subgroup, and N is the total number of observations (= abn),
 σ^{2} is the error variance,
 nσ^{2}_{B {α}} is the subgroups within group variance component,
 nσ^{2}_{A} is the groups added variance component.

Note that for both the mixed and random effects models the denominator for the variance ratio for testing an effect is taken from the level below it in the hierarchy. Hence the Fratio for the 'group effect' is obtained by dividing MS_{A} by MS_{B}. The Fratio for the 'subgroup effect' is then obtained by dividing MS_{B} by MS_{W}.
Some authorities advocate pooling of the mean square (subgroups within groups) and the mean square (error) if the subgroups within groups effect is not significant at some specified level. We have discussed this issue in the core text  suffice to say we do not recommend the practice and expect that (sooner or later) it will regarded as unacceptable pseudoreplication.
Computational formulae
As designs get more complicated we have to modify our notation somewhat to cope. We take a balanced experiment with 'a' group (= treatment) levels (1...i...a), each replicated in 'b' experimental units (1...j...b) and with 'n' (1...k...n) evaluation units in each. For an observational study, there would be 'a' group levels (1...i...a), with 'b' sampling units in each (1...j...b) and 'n' (1...k...n) evaluation units per sampling unit. This notation is shown diagrammatically below:
Groups  1  i  a  Total

Subgroups  1  j  b  1  j  b  1  j  b 

Evaln units:
 1
 Y_{1,1,1}  Y_{1,j,1}  Y_{1,b,1}
 Y_{i,1,1}  Y_{i,j,1}  Y_{i,b,1}
 Y_{a,1,1}  Y_{a,j,1}  Y_{a,b,1}

k
 Y_{1,1,k}  Y_{1,j,k}  Y_{1,b,k
}  Y_{i,1,k}  Y_{i,j,k}  Y_{i,b,k
}  Y_{a,1,k}  Y_{a,j,k}  Y_{a,b,k
} 
n
 Y_{1,1,n}  Y_{1,j,n}  Y_{1,b,n
}  Y_{i,1,n}  Y_{i,j,n}  Y_{i,b,n
}  Y_{a,1,n}  Y_{a,j,n}  Y_{a,b,n
} 
Subgroup tots  S_{1}  S_{j}  S_{b
}  S_{1}  S_{j}  S_{b
}  S_{1}  S_{j}  S_{b
} 
Group tots  T_{1}  T_{i}  T_{a}  G
  
Observations are shown as Y_{1,1,1} to Y_{a,b,n}, group totals as T_{1} to T_{a}, subgroup totals as S_{1} to S_{b} and the grand total as G. Each of the subgroup totals is comprised of n observations, group totals are comprised of b x n observations and the grand total is comprised of N (=Σ(n_{i}) observations. There are no totals for evaluation units as evaluation unit of treatment 1 has nothing in common with evaluation unit 1 of treatment 2.
The group, subgroup within group, within subgroup and total sums of squares are calculated as follows:
Algebraically speaking 
SS_{Total
}  =
 Σ(
 Y_{ijk}^{2
}  )
 −
 G^{2
} 

N

 
where:
 SS_{Total} is the total sums of squares (or Σ()^{2},where is the overall mean),
 Y_{ijk} is the value of the kth observation in subgroup j and treatment group i,
 G is the overall total (or ΣY_{ijk}) and N is the total number of observations (or abn).
SS_{A (Groups)
}  =  Σ(
 T_{i}^{2
}  )
 −
 G^{2
} 

 
bn  N
  
where:
 SS_{A} is the groups (treatment) sums of squares, (or nbΣ(_{i})^{2}),
 T_{i} is the sum of the observations in treatment group i,
 b is the number of subgroups and n is the number of observations in each subgroup
SS_{B(A) (Subgroups within groups)
}  =  SS_{subgroups} − SS_{groups}

 =  Σ(
 S_{j}^{2
}  )
 −
 Σ(
 T_{i}^{2
}  )

 
n  bn

 
where:
 SS_{B(A)} is the subgroups within groups sums of squares, (or nΣ(_{ij}_{i})^{2})
 S_{j} is the sum of the observations in subgroup j.
SS_{W (Within subgroups)
}  =  SS_{Total}  SS_{A }  SS_{B (A)}
  
where:
 SS_{W} is the within subgroups sums of squares (or Σ(Y_{ijk}_{ij})^{2})

Assumptions
The same assumptions made for simple one way ANOVA also apply to nested ANOVA. We briefly repeat these assumptions here:
 Random sampling
Random sampling from populations or random allocation to treatments is an essential precondition for analysis of variance (as it is for most other statistical analysis). For nested ANOVA this applies both to the groups and the subgroups. If strictly random sampling is not possible, then every effort should still be made to avoid bias, so that as representative a sample as possible is obtained.
 Independent and identical error distribution
The distribution of errors in each (sub)group must represent the same population.
 Normal errors
Parametric nested ANOVA assumes that the distribution of errors in each of the subgroups groups is normal. This is often difficult to assess if there are few observations in each group, although QQ plots are still useful. The distribution of residuals should also be checked for normality after fitting the model.
 Additive Effects
The ANOVA model assumes that effects are additive. If the biological model is multiplicative, then a log transformation may be required.
