1 Put Design Name Here

by: Peter Keller,

A completely randomized design for comparing the mean of multiple populations calls for an ANOVA test. Usually in the experimental design portion of an ANOVA test, there are a few characteristics known. The alpha, or probability of type one error, and the beta, probability of type two error, are quantities that are set in advance. This is similar to a T test. The difference comes in when calculating the number of samples that are required to have the required power. When using a T test with a normal distribution, alpha beta and n(sample size) are all related directly and if you have two, you can find the third. This is more complicated when using an ANOVA test to compare multiple populations because the ANOVA test follows an F distribution. The F distribution changes as the parameters change. Knowing the alpha and beta of your experiment doesn’t mean that it is possible to calculate the number of samples required directly.

The ANOVA F statistic is the mean square treatment over the mean squared error, which are both \(\chi^2\) distributions. Combined, they make an F distribution with two degrees of freedom. This \(F=\left[\frac{MST_r}{MSE}\right] \sim F_{\nu_1,\nu_2}\) .

\(\nu_1=\) the degrees of freedom of the mean square treatment

\(\nu_2=\) the degrees of freedom of the mean square error

To find the expected value of F, you look at the expected value of the mean square treatment over the expected value of the mean square error.

\(E[MST_r]=\sigma^2+\sigma_{Trt}^2\)

\(E[MSE]=\sigma^2\)
\(E[F]=\left[\frac{E[MST_r]}{E[MSE]}\right]=1+\left[\frac{\sigma_{Trt}^2}{\sigma^2}\right]\)

The value for \(\sigma_{Trt}^2\) changes between fixed effects and random effects models. For fixed effects, \(\sigma_{Trt}^2=\frac{J\sum{\tau_i}}{I-1}\) For random effects, \(\sigma_{Trt}^2=\sigma_{\tau_i}^2\). The hypothesis of the ANOVA test changes with fixed effects and random effects models.

For Fixed effects: \(H_0:\tau_i=0\) and \(H_a:\tau_i \not= 0\)

For random effects: \(H_0:\sigma_{\tau i}^2=0\) and \(H_0:\sigma_{\tau i}^2\not=0\)

If the null hypothesis is true, \(\sigma_{Trt}^2\) will equal zero. This means that the expected value for F will be driven to 1. When the expected value of F is one, you have a central F distribution. However, Whenever \(\sigma_{Trt}^2\) does not equal 0, the expected value of F will change. This causes the null hypothesis to be rejected in favor of the alternative hypothesis. The term \(\left[\frac{\sigma_{Trt}^2}{\sigma^2}\right]\) is called the “non centrality parameter”

When you have a non centrality parameter, your non central F now has 3 parameters. This changes the shape of the F distribution.

\(F \sim F_{\nu_1,\nu_2,[non\ centrality\ parameter] }\) .

It is worth noting that there are multiple ways for this to be written. It is popular for the same concept to be written as:

\(1+\left[\frac{\sigma_{Trt}^2}{\sigma^2}\right]=1+\left[\frac{\sigma_{between}^2}{\sigma_{within}^2}\right]\)

The power calculation process is very taxing and is not done by hand anymore. There used to be tables that would be referenced when looking for an F statistic with certain parameters and certain power. Now, We have programs like R to do all of the work for us. This guide will show how to use R to calculate the power and number of samples in an ANOVA test.

To find the number of samples required for an experimental design in ANOVA, a power analysis of the experimental design can be done. This analysis requires that there is already information known about the data sets. This is information on the variability of the data. Both the \(\sigma_{between}^2\) and the \(\sigma_{within}^2\) must be known or estimated.

\(\sigma_{between}^2\) can be estimated by \(S^2\), \(S^2=\frac{\sum (\mu_i-\mu.)^2}{n-1}\)

To do the power analysis in R, the power.anova.test function will be used. Following is the usage guide provided by R for the power.anova.test

power.anova.test(groups = NULL, n = NULL,between.var = NULL, within.var = NULL, sig.level = 0.05, power = NULL)

1.0.1 Arguments

groups Number of groups
n Number of observations (per group)
between.var Between group variance
within.var Within group variance
sig.level Significance level (Type I error probability)
power Power of test (1 minus Type II error probability)

1.0.2 Details

Exactly one of the parameters groups, n, between.var, power, within.var, and sig.level must be passed as NULL, and that parameter is determined from the others. Notice that sig.level has non-NULL default so NULL must be explicitly passed if you want it computed.

What if the variances aren’t known values? This proves to be an issue because the power.anova.test is no longer usable. Instead the function pwr.anova.test is used. First, the library “pwr” must be added to your script using “library(pwr)” command. The variability is now estimated using Cohen’s method.

The famous statistician Jacob Cohen created a method for estimating the variability when the exact values of the means are unknown. This is done by choosing one of three options: minimum variability, intermediate variability, and maximum variability. Each option is selected based on the predicted spread of the means. He classifies each group as having an effect represented by f(different from the F statistic). Each option has a different equation to find the effect.

These equations use the following variables:

\(\sigma =\) Standard deviation

\(d=\frac{\mu_{max} - \mu_{min}}{\sigma}\)

\(k=\) the number of populations

Minimum variability is chosen if the bulk of the means are clustered around the central part of the data. An example of this would be if the means of 6 populations are thought to be (2.0, 2.4, 2.5, 2.5, 2.6, 3.0). The means are clustered around the midpoint, and there is approximately equal space between the cluster and the high and low means.

\(\text{f}_{min}=d\sqrt{\frac{1}{2k}}\)

Intermediate variability is chosen of the means are equally distributed across the group of the data. For example, if there were five populations with the following estimated means, they would be a good candidate for using the intermediate variability model. (7.0, 8.5, 10.1, 11.6, 12.9). All of the means are almost equally spaced out.

\(\text{f}_{int}=\frac{d}{2}\sqrt{\frac{k+1}{3(k-1)}}\)

Maximum variability is used for situations where there is bi-modal data with two clusters of means at the high and low end of the spread. An example of this would be if six populations had means predicted to be (100, 101, 98, 176, 174, 175). All of the data is very clustered around the two end points.

For odd observations:

\(\text{f}_{int}=\frac{d}{2}\sqrt{\frac{k+1}{3(k-1)}}\)

For even observations:

\(\text{f}_{max}=\frac{d}{2}\)

This r value will now be used with the pwr.anova.test function to calculate either the power or number of samples required per group. Following is the usage guide provided by R for the pwr.anova.test.

pwr.anova.test(k = NULL, n = NULL, f = NULL, sig.level = 0.05, power = NULL)

1.0.3 Arguments

k Number of groups
n Number of observations (per group)
f Effect size
sig.level Significance level (Type I error probability)
power Power of test (1 minus Type II error probability)

1.0.4 Details

Exactly one of the parameters ‘k’,‘n’,‘f’,‘power’ and ‘sig.level’ must be passed as NULL, and that parameter is determined from the others. Notice that the last one has non-NULL default so NULL must be explicitly passed if you want to compute it.

##Experimental Design

With the power test complete, all of the information needed to plan the data collection is now collected. The assumptions of normality and equal variance have been checked and the sample size has been determined. The type one and two errors, and thus power, have been predetermined. The next step before data collection is the experimental design. To be a completely randomized design, the data collection needs to be randomized.

The package “agricolae” in R will be used to generate the experimental design. This is a package created for analysis of many experiments commonly used in agricultural fields. It has a good analysis of CRD that is useful to us.

To use this package, first doenload it using the install.packages(“agricolae”) command. Next load the package using the library(agricolae) command. The package is now ready for use in your R script.

The design.crd is a package inside of the agricolae package. To set up the use of the design.crd package, format your information in the following way:

For a CRD with I=4 levels (lvl1, lvl2, lvl3, lvl4), specify the I levels of a factor/treatment in a vector:

trt1<-c(“lvl1”,“lvl2”,“lvl3”,“lvl4”)

Following is the usage guide provided by R for the design.crd

design.crd(trt, r, serie = 2, seed = 0, kinds = "Super-Duper",randomization=TRUE) 

1.0.5 Arguments

trt Treatments
r Replications
serie number plot, 1: 11,12; 2: 101,102; 3: 1001,1002
seed seed
kinds method for to randomize
randomization TRUE or FALSE - randomize

For our purposes, the only options needed are trt, r, and seed. The other options have to do with the type of randomization algorithm. The default settings will work for our experimental design. Continuing with our example for a CRD with four levels and six replications, the R code would look like the following:

library(agricolae)
trt1<-c("lvl1","lvl2","lvl3","lvl4") 
design<-design.crd(trt=trt1,serie=0,r=6,seed=8240)
design$book
##    plots r trt1
## 1      1 1 lvl4
## 2      2 1 lvl2
## 3      3 2 lvl4
## 4      4 1 lvl3
## 5      5 1 lvl1
## 6      6 2 lvl2
## 7      7 2 lvl1
## 8      8 3 lvl1
## 9      9 3 lvl2
## 10    10 4 lvl1
## 11    11 2 lvl3
## 12    12 3 lvl4
## 13    13 3 lvl3
## 14    14 4 lvl2
## 15    15 4 lvl4
## 16    16 5 lvl2
## 17    17 5 lvl1
## 18    18 4 lvl3
## 19    19 5 lvl3
## 20    20 5 lvl4
## 21    21 6 lvl2
## 22    22 6 lvl3
## 23    23 6 lvl4
## 24    24 6 lvl1

The seed number is the start to the random number generator that randomizes the results. The results of the previous code block will be a