One-way ANOVA

Model

\[ Y_{i t}=\mu_{i}+\epsilon_{i t} \text { or } Y_{i t}=\mu+\tau_{i}+\epsilon_{i t}, \text { for } i=1, \cdots, v, t=1, \cdots, r_{i} . \] where \(\mu_i\) is the treatment mean for treatment \(i\), and \(\epsilon_{it}\) are i.i.d. \(N(0, \sigma^2)\).

Hypotheses

\(H_{0}:\) all treatment means are equal versus \(H_{1}\) : not all treatment means are equal. Equivalently: \[ H_{0}: \mu_{1}=\mu_{2}=\cdots=\mu_{v} \text { or } H_{1}: \mu_{1}, \mu_{2}, \cdots,\mu_{v} \text{ are not all equal}. \] If \(H_{0}\) is true, we have a reduced model \[ Y_{i t}=\mu+\epsilon_{i t} . \]

  • Redueced Model: The sum of squares for error for this reduced model is \[ SSE_{0}=\sum_{i} \sum_{t}\left(Y_{i t}-\bar{Y}_{. .}\right)^{2} . \] Then \(S S E_{0} /(n-1)\) is an unbiased estimator of \(\sigma^{2}\) under the null hypothesis.

  • Under the full model (i.e., without assuming the treatment means are all equal), the sum of squares error is \[ SSE=\sum_{i} \sum_{t}\left(Y_{i t}-\bar{Y}_{i}\right)^{2}=\sum_{i}\left(r_{i}-1\right) S_{i}^{2} \] \(SSE /(n-v)\) is an unbiased estimator of \(\sigma^{2}\). In practice, we use this estimator because it is still an unbiased even when the treatment means are not equal.

ANOVA

Consider the difference of sums of squares, which is attributed to the treatments and called the sum squares for treatment (SST) \[ SST=SSE_{0}-SSE=\sum_{i} \sum_{t}\left(Y_{i t}-\bar{Y}_{. .}\right)^{2}-\sum_{i} \sum_{t}\left(Y_{i t}-\bar{Y}_{i .}\right)^{2} . \] Simplified into \[ S S T=\sum_{i} r_{i}\left(\bar{Y}_{i}-\bar{Y}_{. .}\right)^{2}=\sum_{i} r_{i}\left(\bar{Y}_{i .}\right)^{2}-n\left(\bar{Y}_{. .}\right)^{2}. \] Note the following

  • SST is independent of \(S S E\) because the sample means \(\bar{Y}_{i\cdot}\) and \(\bar{Y}_{\cdot\cdot}\)are independent of SSE.

  • \(E(S S T)=E\left(S S E_{0}\right)-E(S S E)=(n-1) \sigma^{2}-(n-v) \sigma^{2}=(v-1) \sigma^{2}\) if \(H_{0}\) is true.

  • \(MST=SST/(v-1)\) is an unbiased estimator of \(\sigma^{2}\) under \(H_{0}\).

  • The ratio \(F=\frac{M S T}{M S E}\) has an \(F\)-distribution with \(v-1\) and \(n-v\) degrees of freedom if \(H_{0}\) is true. Reject \(H_{0}\) if \(F>F_{v-1, n-v, \alpha}\) where \(\alpha\) is the significance level of the test and also the probability of Type I error. A Type I error is to reject \(H_{0}\) when it is true. The upper critical value \(F_{v-1, n-v, \alpha}\) is provided in Table A. 6 and can be calculated using the SAS function finv(1-\alpha, df1, df2).

  • Intuitively, both MST and MSE are unbiased estimators of \(\sigma^{2}\) if the treatment means are all equal. Hence the ratio should be excessively large if \(H_{0}\) is true.

  • SST represents the between-treatment variation and SSE the within-treatment variation.

The purpose of ANOVA is to compare the means.

Example. In an experiment to study the effects of drivers on the mpg of Toyota Prius, 12 new Prius were randomly assigned to three drivers so that each driver drove four cars and obtained the mpgs. This is a completely randomized design. The data are given below.

The SAS program to get the sample means and sample standard deviations:

data prius;
input driver mpg;
lines;
1 50.33
1 46.83
1 51.57
1 45.33
2 48.11
2 50.14
2 43.22
2 47.26
3 49.08
3 48.89
3 49.96
3 49.70
;
run;
proc print data=prius;
run;

proc glm data=prius;
class driver;
 model mpg=driver;
run;

Partial output:

The p‐value is 0.4502. Hence we fail to reject \(H_0\) and there is no significant evidence to support that the three drivers have different MPG.

Try the following SAS program with optional argument

proc glm data=prius;
class driver;
 model mpg=driver/solution;
 lsmeans driver;
 means driver;
 run;

Power and Sample Sizes

Suppose \(\mu_{1}, \cdots, \mu_{\nu}\) are a given set of treatment means that not all equal (i.e., \(H_0\) is not true). The experimenter would like be able to claim a significant difference with certain probability (this probability is called the power). What sample size is sufficient for that?

In this case, the test statistic \(F\) has a noncentral F-distribution with a noncentrality parameter \(\delta^{2}\). To determine the noncentrality parameter, note \[ S S T=r \sum_{i=1}^{\nu}\left(\bar{Y}_{i .}-\bar{Y}_{. .}\right)^{2} . \] The noncentrality parameter \[ \delta^{2} =r \sum_{i=1}^{\nu}\left(\mu_{i}-\bar{\mu} .\right)^{2} / \sigma^{2}. \] where \(\bar{\mu}\). is the average of \(\mu_{i}, i=1, \cdots, \nu\). The power is \(P\left(F>F_{\nu-1, \nu(r-1), \alpha}\right)\) which can be calculated for any given \(r\) where \(F\) with \((\nu-1)\) and \((n-\nu)\) degrees of freedom has the F-distribution with the noncentrality parameter \(\delta^2\). Then one can choose the \(r\) that yields satisfactory power, say, \(0.90\).

SAS Code - An Example

In a study to compare the effects of 4 diets on the weights of mice of 20 days old, the experimenter wishes to detect a difference of 10 grams. The experimenter estimates that the standard deviation σ is no larger than 5 grams. How many replicates is necessary to have a probability of 90% to detect a difference of 10 grams using the F-test for \(\alpha= 0.05\)?

A difference of 10 grams means that the maximum and the minimum treatment means differ by 10 grams. The scenario that the noncentrality parameter is the largest is when the other two treatment means are all at the middle. Hence the four treatment means are \(a, a+5, a+5, a+10\) for some constant \(a\). Then \[ \delta^{2}=r \sum_{i=1}^{\nu}\left(\mu_{i}-\bar{\mu} .\right)^{2} / \sigma^{2}=\frac{r \Delta^{2}}{2 \sigma^{2}} \]

SAS code:

data power;
input r @@;
v=4;
diff=10;
sigma=5;
alpha=0.05;
df1=v-1;
df2=v*(r-1);
ncp=r*diff**2/(2*sigma**2);
Falpha=finv(1-alpha, df1, df2);
power=1-probf(Falpha, df1, df2, ncp);
lines;
3 4 5 6 7 8 9
;
run;
proc print; 
var r power; 
run;

You will get the output as

\[{\small\begin{array}{llr}\text { Obs } & r & \text { power }\\ 1 & 3 & 0.33906 \\ 2 & 4 & 0.50370 \\ 3 & 5 & 0.64423 \\ 4 & 6 & 0.75459 \\ 5 & 7 & 0.83613 \\ 6 & 8 & 0.89360 \\ 7 & 9 & 0.93258\end{array} }\] Note SAS has a procedure proc power that can calculate the necessary sample size for a desired power for a one-way ANOVA model.

proc power
onewayanova test=overall
  alpha=.05
  groupmeans=(0 5 5 10) /* or you can use (5 10 10 15) and get the same result*/
  stddev= 5 /* standard deviation sigma */
  power=.90  /*power for the overall F test*/
  npergroup=.; /*sample size per treatment level*/
run;

However, proc power only applies to one-way ANOVA and is not recommended to use for two-way or multiple-way ANOVA.