Teach yourself statistics
One-Way Analysis of Variance: Example
In this lesson, we apply one-way analysis of variance to some fictitious data, and we show how to interpret the results of our analysis.
Note: Computations for analysis of variance are usually handled by a software package. For this example, however, we will do the computations "manually", since the gory details have educational value.
Problem Statement
A pharmaceutical company conducts an experiment to test the effect of a new cholesterol medication. The company selects 15 subjects randomly from a larger population. Each subject is randomly assigned to one of three treatment groups. Within each treament group, subjects receive a different dose of the new medication. In Group 1, subjects receive 0 mg/day; in Group 2, 50 mg/day; and in Group 3, 100 mg/day.
The treatment levels represent all the levels of interest to the experimenter, so this experiment used a fixed-effects model to select treatment levels for study.
After 30 days, doctors measure the cholesterol level of each subject. The results for all 15 subjects appear in the table below:
In conducting this experiment, the experimenter had two research questions:
- Does dosage level have a significant effect on cholesterol level?
- How strong is the effect of dosage level on cholesterol level?
To answer these questions, the experimenter intends to use one-way analysis of variance.
Is One-Way ANOVA the Right Technique?
Before you crunch the first number in one-way analysis of variance, you must be sure that one-way analysis of variance is the correct technique. That means you need to ask two questions:
- Is the experimental design compatible with one-way analysis of variance?
- Does the data set satisfy the critical assumptions required for one-way analysis of variance?
Let's address both of those questions.
Experimental Design
As we discussed in the previous lesson (see One-Way Analysis of Variance: Fixed Effects ), one-way analysis of variance is only appropriate with one experimental design - a completely randomized design. That is exactly the design used in our cholesterol study, so we can check the experimental design box.
Critical Assumptions
We also learned in the previous lesson that one-way analysis of variance makes three critical assumptions:
- Independence . The dependent variable score for each experimental unit is independent of the score for any other unit.
- Normality . In the population, dependent variable scores are normally distributed within treatment groups.
- Equality of variance . In the population, the variance of dependent variable scores in each treatment group is equal. (Equality of variance is also known as homogeneity of variance or homoscedasticity.)
Therefore, for the cholesterol study, we need to make sure our data set is consistent with the critical assumptions.
Independence of Scores
The assumption of independence is the most important assumption. When that assumption is violated, the resulting statistical tests can be misleading.
The independence assumption is satisfied by the design of the study, which features random selection of subjects and random assignment to treatment groups. Randomization tends to distribute effects of extraneous variables evenly across groups.
Normal Distributions in Groups
Violations of normality can be a problem when sample size is small, as it is in this cholesterol study. Therefore, it is important to be on the lookout for any indication of non-normality.
There are many different ways to check for normality. On this website, we describe three at: How to Test for Normality: Three Simple Tests . Given the small sample size, our best option for testing normality is to look at the following descriptive statistics:
- Central tendency. The mean and the median are summary measures used to describe central tendency - the most "typical" value in a set of values. With a normal distribution, the mean is equal to the median.
- Skewness. Skewness is a measure of the asymmetry of a probability distribution. If observations are equally distributed around the mean, the skewness value is zero; otherwise, the skewness value is positive or negative. As a rule of thumb, skewness between -2 and +2 is consistent with a normal distribution.
- Kurtosis. Kurtosis is a measure of whether observations cluster around the mean of the distribution or in the tails of the distribution. The normal distribution has a kurtosis value of zero. As a rule of thumb, kurtosis between -2 and +2 is consistent with a normal distribution.
The table below shows the mean, median, skewness, and kurtosis for each group from our study.
In all three groups, the difference between the mean and median looks small (relative to the range ). And skewness and kurtosis measures are consistent with a normal distribution (i.e., between -2 and +2). These are crude tests, but they provide some confidence for the assumption of normality in each group.
Note: With Excel, you can easily compute the descriptive statistics in Table 1. To see how, go to: How to Test for Normality: Example 1 .
Homogeneity of Variance
When the normality of variance assumption is satisfied, you can use Hartley's Fmax test to test for homogeneity of variance. Here's how to implement the test:
where X i, j is the score for observation i in Group j , X j is the mean of Group j , and n j is the number of observations in Group j .
Here is the variance ( s 2 j ) for each group in the cholesterol study.
F RATIO = s 2 MAX / s 2 MIN
F RATIO = 1170 / 450
F RATIO = 2.6
where s 2 MAX is the largest group variance, and s 2 MIN is the smallest group variance.
where n is the largest sample size in any group.
Note: The critical F values in the table are based on a significance level of 0.05.
Here, the F ratio (2.6) is smaller than the Fmax value (15.5), so we conclude that the variances are homogeneous.
Note: Other tests, such as Bartlett's test , can also test for homogeneity of variance. For the record, Bartlett's test yields the same conclusion for the cholesterol study; namely, the variances are homogeneous.
Analysis of Variance
Having confirmed that the critical assumptions are tenable, we can proceed with a one-way analysis of variance. That means taking the following steps:
- Specify a mathematical model to describe the causal factors that affect the dependent variable.
- Write statistical hypotheses to be tested by experimental data.
- Specify a significance level for a hypothesis test.
- Compute the grand mean and the mean scores for each group.
- Compute sums of squares for each effect in the model.
- Find the degrees of freedom associated with each effect in the model.
- Based on sums of squares and degrees of freedom, compute mean squares for each effect in the model.
- Compute a test statistic , based on observed mean squares and their expected values.
- Find the P value for the test statistic.
- Accept or reject the null hypothesis , based on the P value and the significance level.
- Assess the magnitude of the effect of the independent variable, based on sums of squares.
Now, let's execute each step, one-by-one, with our cholesterol medication experiment.
Mathematical Model
For every experimental design, there is a mathematical model that accounts for all of the independent and extraneous variables that affect the dependent variable. In our experiment, the dependent variable ( X ) is the cholesterol level of a subject, and the independent variable ( β ) is the dosage level administered to a subject.
For example, here is the fixed-effects model for a completely randomized design:
X i j = μ + β j + ε i ( j )
where X i j is the cholesterol level for subject i in treatment group j , μ is the population mean, β j is the effect of the dosage level administered to subjects in group j ; and ε i ( j ) is the effect of all other extraneous variables on subject i in treatment j .
Statistical Hypotheses
For fixed-effects models, it is common practice to write statistical hypotheses in terms of the treatment effect β j . With that in mind, here is the null hypothesis and the alternative hypothesis for a one-way analysis of variance:
H 0 : β j = 0 for all j
H 1 : β j ≠ 0 for some j
If the null hypothesis is true, the mean score (i.e., mean cholesterol level) in each treatment group should equal the population mean. Thus, if the null hypothesis is true, mean scores in the k treatment groups should be equal. If the null hypothesis is false, at least one pair of mean scores should be unequal.
Significance Level
The significance level (also known as alpha or α) is the probability of rejecting the null hypothesis when it is actually true. The significance level for an experiment is specified by the experimenter, before data collection begins.
Experimenters often choose significance levels of 0.05 or 0.01. For this experiment, let's use a significance level of 0.05.
Mean Scores
Analysis of variance begins by computing a grand mean and group means:
X = ( 1 / 15 ) * ( 210 + 210 + ... + 270 + 240 )
- Group means. The mean of group j ( X j ) is the mean of all observations in group j , computed as follows:
X 1 = 258
X 2 = 246
X 3 = 210
In the equations above, n is the total sample size across all groups; and n j is the sample size in Group j .
Sums of Squares
A sum of squares is the sum of squared deviations from a mean score. One-way analysis of variance makes use of three sums of squares:
SSB = 5 * [ ( 238-258 ) 2 + ( 238-246) 2 + ( 238-210 ) 2 ]
SSW = 2304 + ... + 900 = 9000
- Total sum of squares. The total sum of squares (SST) measures variation of all scores around the grand mean. It can be computed from the following formula: SST = k Σ j=1 n j Σ i=1 ( X i j - X ) 2
SST = 784 + 4 + 1084 + ... + 784 + 784 + 4
SST = 15,240
It turns out that the total sum of squares is equal to the between-groups sum of squares plus the within-groups sum of squares, as shown below:
SST = SSB + SSW
15,240 = 6240 + 9000
Degrees of Freedom
The term degrees of freedom (df) refers to the number of independent sample points used to compute a statistic minus the number of parameters estimated from the sample points.
To illustrate what is going on, let's find the degrees of freedom associated with the various sum of squares computations:
Here, the formula uses k independent sample points, the sample means X j . And it uses one parameter estimate, the grand mean X , which was estimated from the sample points. So, the between-groups sum of squares has k - 1 degrees of freedom ( df BG ).
df BG = k - 1 = 5 - 1 = 4
Here, the formula uses n independent sample points, the individual subject scores X i j . And it uses k parameter estimates, the group means X j , which were estimated from the sample points. So, the within-groups sum of squares has n - k degrees of freedom ( df WG ).
n = Σ n i = 5 + 5 + 5 = 15
df WG = n - k = 15 - 3 = 12
Here, the formula uses n independent sample points, the individual subject scores X i j . And it uses one parameter estimate, the grand mean X , which was estimated from the sample points. So, the total sum of squares has n - 1 degrees of freedom ( df TOT ).
df TOT = n - 1 = 15 - 1 = 14
The degrees of freedom for each sum of squares are summarized in the table below:
Mean Squares
A mean square is an estimate of population variance. It is computed by dividing a sum of squares (SS) by its corresponding degrees of freedom (df), as shown below:
MS = SS / df
To conduct a one-way analysis of variance, we are interested in two mean squares:
MS WG = SSW / df WG
MS WG = 9000 / 12 = 750
MS BG = SSB / df BG
MS BG = 6240 / 2 = 3120
Expected Value
The expected value of a mean square is the average value of the mean square over a large number of experiments.
Statisticians have derived formulas for the expected value of the within-groups mean square ( MS WG ) and for the expected value of the between-groups mean square ( MS BG ). For one-way analysis of variance, the expected value formulas are:
Fixed- and Random-Effects:
E( MS WG ) = σ ε 2
Fixed-Effects:
Random-effects:.
E( MS BG ) = σ ε 2 + nσ β 2
In the equations above, E( MS WG ) is the expected value of the within-groups mean square; E( MS BG ) is the expected value of the between-groups mean square; n is total sample size; k is the number of treatment groups; β j is the treatment effect in Group j ; σ ε 2 is the variance attributable to everything except the treatment effect (i.e., all the extraneous variables); and σ β 2 is the variance due to random selection of treatment levels.
Notice that MS BG should equal MS WG when the variation due to treatment effects ( β j for fixed effects and σ β 2 for random effects) is zero (i.e., when the independent variable does not affect the dependent variable). And MS BG should be bigger than the MS WG when the variation due to treatment effects is not zero (i.e., when the independent variable does affect the dependent variable)
Conclusion: By examining the relative size of the mean squares, we can make a judgment about whether an independent variable affects a dependent variable.
Test Statistic
Suppose we use the mean squares to define a test statistic F as follows:
F(v 1 , v 2 ) = MS BG / MS WG
F(2, 12) = 3120 / 750 = 4.16
where MS BG is the between-groups mean square, MS WG is the within-groups mean square, v 1 is the degrees of freedom for MS BG , and v 2 is the degrees of freedom for MS WG .
Defined in this way, the F ratio measures the size of MS BG relative to MS WG . The F ratio is a convenient measure that we can use to test the null hypothesis. Here's how:
- When the F ratio is close to one, MS BG is approximately equal to MS WG . This indicates that the independent variable did not affect the dependent variable, so we cannot reject the null hypothesis.
- When the F ratio is significantly greater than one, MS BG is bigger than MS WG . This indicates that the independent variable did affect the dependent variable, so we must reject the null hypothesis.
What does it mean for the F ratio to be significantly greater than one? To answer that question, we need to talk about the P-value.
In an experiment, a P-value is the probability of obtaining a result more extreme than the observed experimental outcome, assuming the null hypothesis is true.
With analysis of variance, the F ratio is the observed experimental outcome that we are interested in. So, the P-value would be the probability that an F statistic would be more extreme (i.e., bigger) than the actual F ratio computed from experimental data.
We can use Stat Trek's F Distribution Calculator to find the probability that an F statistic will be bigger than the actual F ratio observed in the experiment. Enter the between-groups degrees of freedom (2), the within-groups degrees of freedom (12), and the observed F ratio (4.16) into the calculator; then, click the Calculate button.
From the calculator, we see that the P ( F > 4.16 ) equals about 0.04. Therefore, the P-Value is 0.04.
Hypothesis Test
Recall that we specified a significance level 0.05 for this experiment. Once you know the significance level and the P-value, the hypothesis test is routine. Here's the decision rule for accepting or rejecting the null hypothesis:
- If the P-value is bigger than the significance level, accept the null hypothesis.
- If the P-value is equal to or smaller than the significance level, reject the null hypothesis.
Since the P-value (0.04) in our experiment is smaller than the significance level (0.05), we reject the null hypothesis that drug dosage had no effect on cholesterol level. And we conclude that the mean cholesterol level in at least one treatment group differed significantly from the mean cholesterol level in another group.
Magnitude of Effect
The hypothesis test tells us whether the independent variable in our experiment has a statistically significant effect on the dependent variable, but it does not address the magnitude of the effect. Here's the issue:
- When the sample size is large, you may find that even small differences in treatment means are statistically significant.
- When the sample size is small, you may find that even big differences in treatment means are not statistically significant.
With this in mind, it is customary to supplement analysis of variance with an appropriate measure of effect size. Eta squared (η 2 ) is one such measure. Eta squared is the proportion of variance in the dependent variable that is explained by a treatment effect. The eta squared formula for one-way analysis of variance is:
η 2 = SSB / SST
where SSB is the between-groups sum of squares and SST is the total sum of squares.
Given this formula, we can compute eta squared for this drug dosage experiment, as shown below:
η 2 = SSB / SST = 6240 / 15240 = 0.41
Thus, 41 percent of the variance in our dependent variable (cholesterol level) can be explained by variation in our independent variable (dosage level). It appears that the relationship between dosage level and cholesterol level is significant not only in a statistical sense; it is significant in a practical sense as well.
ANOVA Summary Table
It is traditional to summarize ANOVA results in an analysis of variance table. The analysis that we just conducted provides all of the information that we need to produce the following ANOVA summary table:
Analysis of Variance Table
This ANOVA table allows any researcher to interpret the results of the experiment, at a glance.
The P-value (shown in the last column of the ANOVA table) is the probability that an F statistic would be more extreme (bigger) than the F ratio shown in the table, assuming the null hypothesis is true. When the P-value is bigger than the significance level, we accept the null hypothesis; when it is smaller, we reject it. Here, the P-value (0.04) is smaller than the significance level (0.05), so we reject the null hypothesis.
To assess the strength of the treatment effect, an experimenter might compute eta squared (η 2 ). The computation is easy, using sum of squares entries from the ANOVA table, as shown below:
η 2 = SSB / SST = 6,240 / 15,240 = 0.41
For this experiment, an eta squared of 0.41 means that 41% of the variance in the dependent variable can be explained by the effect of the independent variable.
An Easier Option
In this lesson, we showed all of the hand calculations for a one-way analysis of variance. In the real world, researchers seldom conduct analysis of variance by hand. They use statistical software. In the next lesson, we'll analyze data from this problem with Excel. Hopefully, we'll get the same result.
User Preferences
Content preview.
Arcu felis bibendum ut tristique et egestas quis:
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
- Duis aute irure dolor in reprehenderit in voluptate
- Excepteur sint occaecat cupidatat non proident
Keyboard Shortcuts
10.2 - a statistical test for one-way anova.
Before we go into the details of the test, we need to determine the null and alternative hypotheses. Recall that for a test for two independent means, the null hypothesis was \(\mu_1=\mu_2\). In one-way ANOVA, we want to compare \(t\) population means, where \(t>2\). Therefore, the null hypothesis for analysis of variance for \(t\) population means is:
\(H_0\colon \mu_1=\mu_2=...\mu_t\)
The alternative, however, cannot be set up similarly to the two-sample case. If we wanted to see if two population means are different, the alternative would be \(\mu_1\ne\mu_2\). With more than two groups, the research question is “Are some of the means different?." If we set up the alternative to be \(\mu_1\ne\mu_2\ne…\ne\mu_t\), then we would have a test to see if ALL the means are different. This is not what we want. We need to be careful how we set up the alternative. The mathematical version of the alternative is...
\(H_a\colon \mu_i\ne\mu_j\text{ for some }i \text{ and }j \text{ where }i\ne j\)
This means that at least one of the pairs is not equal. The more common presentation of the alternative is:
\(H_a\colon \text{ at least one mean is different}\) or \(H_a\colon \text{ not all the means are equal}\)
Recall that when we compare the means of two populations for independent samples, we use a 2-sample t -test with pooled variance when the population variances can be assumed equal.
For more than two populations, the test statistic, \(F\), is the ratio of between group sample variance and the within-group-sample variance. That is,
\(F=\dfrac{\text{between group variance}}{\text{within group variance}}\)
Under the null hypothesis (and with certain assumptions), both quantities estimate the variance of the random error, and thus the ratio should be close to 1. If the ratio is large, then we have evidence against the null, and hence, we would reject the null hypothesis.
In the next section, we present the assumptions for this test. In the following section, we present how to find the between group variance, the within group variance, and the F-statistic in the ANOVA table.
IMAGES
VIDEO
COMMENTS
The following examples show how to decide to reject or fail to reject the null hypothesis in both a one-way ANOVA and two-way ANOVA. Example 1: One-Way ANOVA. Suppose we want to know whether or not three different exam prep programs lead to different mean scores on a certain exam. To test this, we recruit 30 students to participate in a study ...
However, directional hypotheses can also be tested provided post-hoc analyses are performed following the one-way ANOVA. For the one-way ANOVA, the non-directional research hypothesis is that the sample means will be different from each other. The corresponding null hypothesis is that the sample means will not be different from each other.
A one-way ANOVA uses the following null and alternative hypotheses: H 0 (null hypothesis): μ 1 = μ 2 = μ 3 = … = μ k (all the population means are equal) H 1 (alternative hypothesis): at least one population mean is different from the rest; You will typically use some statistical software (such as R, Excel, Stata, SPSS, etc.) to perform a ...
One-way ANOVA example As a crop researcher, you want to test the effect of three different fertilizer mixtures on crop yield. You can use a one-way ANOVA to find out if there is a difference in crop yields between the three groups. ... The null hypothesis (H 0) of ANOVA is that there is no difference among group means. The alternative ...
With that in mind, here is the null hypothesis and the alternative hypothesis for a one-way analysis of variance: Null hypothesis: The null hypothesis states that the independent variable (dosage level) has no effect on the dependent variable (cholesterol level) in any treatment group. Thus,
For example, one-way ANOVA can determine whether parts made from four materials have different mean strengths. In this post, learn about the hypotheses, assumptions, and interpreting the results for one-way ANOVA. ... Null hypothesis: All population group means are equal. Alternative hypothesis: ...
176 CHAPTER 7. ONE-WAY ANOVA 7.2 How one-way ANOVA works 7.2.1 The model and statistical hypotheses One-way ANOVA is appropriate when the following model holds. We have a single \treatment" with, say, klevels. \Treatment" may be interpreted in the loosest possible sense as any categorical explanatory variable. There is a population of
Before we go into the details of the test, we need to determine the null and alternative hypotheses. Recall that for a test for two independent means, the null hypothesis was \(\mu_1=\mu_2\). In one-way ANOVA, we want to compare \(t\) population means, where \(t>2\).
There was one score per subject. The null hypothesis tested by ANOVA is that the population means for all conditions are the same. This can be expressed as follows: H 0: μ 1 = μ 2 = ... = μ k. where H 0 is the null hypothesis and k is the number of conditions. In the "Smiles and Leniency" study, k = 4 and the null hypothesis is
The following examples show how to decide to reject or fail to reject the null hypothesis in both a one-way ANOVA and two-way ANOVA. Example 1: One-Way ANOVA. Suppose we want to know whether or not three different exam prep programs lead to different mean scores on a certain exam. To test this, we recruit 30 students to participate in a study ...