Skip to main content
Statistics LibreTexts

10.4: ANOVA

  • Page ID
    49078
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    In the previous sections, we compared proportions from three or more populations. In this section, we will learn about Analysis of Variance, which allows us to compare three or more means. We abbreviate Analysis of Variance as ANOVA. To use One-Way ANOVA, we must make sure that samples are random, independent, and are drawn from each of \(k\) populations that are normal with equal variances. The test is robust meaning that moderate departures from these assumptions still yield fairly reliable results.
     

    Dentists use metal alloys to make fillings. Many metals, such as pure gold, are too soft to use for fillings, but they can be hardened by adding other metals at different melting temperatures to make alloys.

    Researchers used three different methods to make gold alloys for dental fillings. Vickers hardness numbers are recorded for samples of each method below. A Vickers Hardness Number is a measure of a material’s hardness. The higher the number, the harder the material. For example, diamonds are extremely hard and have a Vickers hardness number of 10,000.
     

    The table below displays the Vickers hardness numbers for gold alloys from three different methods.
     

    (C) Method 3

    805

    856

    608

    675

    956

    927

    702

    892

    926

    793

    956

    861

    689

    1214

    764

    804

    724

    645

    919

     

    743

    765

       


    We will use these data to test the claim that the mean hardness number is the same for each alloy method at a 5% level of significance.

    Step 1: Determine the Hypotheses

    The null hypothesis is that the population means (three or more) are equal which opposes the alternative hypothesis that at least one population mean is different from one of the others.

    1. State the null and alternative hypotheses for this hypothesis test.
       

      \(H_0:\)


       

      \(H_a:\)




       

    Step 2: Collect the Data

    When conducting the ANOVA test by hand, we must determine the mean and variance of each sample.

    1. Calculate the mean for each sample using desmos.


      \(\bar{x}_1=\operatorname{mean}(A)=\)
       

      \(\bar{x}_2=\operatorname{mean}(B)=\)
       

      \(\bar{x}_3=\operatorname{mean}(C)=\)
       

    2. Compute the variance (rounded to two decimal places) for each sample using the var function in desmos. Recall that the variance is the square of the standard deviation.


      \(s_1^2=\operatorname{var}(A) \approx\)
       

      \(s_2^2=\operatorname{var}(B) \approx\)
       

      \(s_3^2=\operatorname{var}(C) \approx\)
       

    Step 3: Assess the Evidence

    To conduct the test, a sample is drawn from each of the \(k\) populations. When the sample sizes are all equal, the \(F\)-statistic uses two different estimates of the variance \((\sigma^2)\) that is common to each of the \(k\) populations. The test statistic is denoted as \(F\), named for the statistician, Ronald Fisher.

    \[F=\frac{n \cdot s_{\bar{x}}^2}{s_p^2}=\frac{n \cdot \text { variance of the sample means }}{\text { mean of the sample variances }}=\frac{\text { variance between the samples }}{\text { variance within the samples }}\nonumber\]

    When the sample sizes are not all equal these variances become more complicated. Variance is the square of standard deviation. We have seen the formula for standard deviation before.

    \[s=\sqrt{\frac{\Sigma(x-\bar{x})^2}{n-1}}\nonumber\]

    Squaring this gives the formula for variance.

    \[s^2=\frac{\Sigma(x-\bar{x})^2}{n-1}\nonumber\]

    The variance between the samples uses \(s_\bar{x}^2\), the variance of k sample means.

    \[s_{\bar{x}}^2=\frac{\Sigma(\bar{x}-\overline{\bar{x}})^2}{k-1}\nonumber\]

    We can update the variance between the samples by moving the variable sample size into the sum which is the variance of the sample means.

    \[\sigma^2 \approx n s_{\bar{x}}^2=n \frac{\Sigma(\bar{x}-\overline{\bar{x}})^2}{k-1}=\frac{\Sigma n(\bar{x}-\overline{\bar{x}})^2}{k-1}\nonumber\]
     

    In this formula, \(k\) is the number of samples, and \(\overline{\bar{x}}\) is the grand mean. The grand mean can be found in two ways:

    • The mean of all the observations. So, you find the sum of all of the values in all of the samples and divide by the total number of observations.
       
    • The weighted mean of the sample means. The weighted mean assigns weights to values based on the sample sizes. The weighted mean assigns weights to values based on the sample sizes. This weighted mean can be expressed by the formula below where n refers to a sample size, \(\bar{x}\) refers to a sample mean, and N is the sum of the sample sizes, or total number of observations: \[\overline{\bar{x}}=\frac{\sum n \bar{x}}{N}\nonumber\]
    1. Compute the grand mean.
       
      1. Multiply each sample mean by its weight - its sample size. In the table below, for each sample, enter the product \(n \cdot \bar{x}\) into the corresponding cell in the third column.
         
      2. In the Totals row of the table, enter in the total number of observations, \(N\), and the sum of the products \(n \cdot \bar{x}\).
         

        Method

        \(n\)

        \(\bar{x}\)

        \(n \cdot \bar{x}\)

        1

             

        2

             

        3

             

        Totals

         

        -----------------

         

         
      3. The grand mean \(\overline{\bar{x}}\) is the sum of the products \(n \cdot \bar{x}\) divided by N. Enter in the grand mean below. Round to two decimal places.
         

        \[\overline{\bar{x}}=\frac{\Sigma n \bar{x}}{N}=\underline{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\nonumber\]
         

    The numerator of the \(F\)-statistic estimates the common population variance \((\sigma^2)\) using the variance between the samples. The numerator of the variance between the samples is often referred to as the Sum of Squares between the samples \(\left(\mathrm{SS}_{\text {between }}\right)\),
     

    \[\mathrm{SS}_{\text {between }}=\sum n(\bar{x}-\overline{\bar{x}})^2=n_1\left(\bar{x}_1-\overline{\bar{x}}\right)^2+n_2\left(\bar{x}_2-\overline{\bar{x}}\right)^2+\ldots+n_k\left(\bar{x}_k-\overline{\bar{x}}\right)^2\nonumber\]

    To compute this, for each sample mean, we find the square of sample mean minus grand mean, and multiply this value by the sample size. We then add all the products together.






     

    1. Compute \(\mathrm{SS}_{\text {between}}\) using the table below.
       
      1. For each sample, find the difference between the sample mean and grand mean, square it, then multiply the squared difference by the sample size. Enter the result into the corresponding cell in the third column in the table below.
         

        Method

        \(n\)

        \(\bar{x}\)

        \(\mathrm{n} \cdot(\bar{x}-\overline{\bar{x}})^2\)

        1

             

        2

             

        3

             

        Totals

         

        ---------------------

         

         
      2. Sum of Squares between the samples, \(\mathrm{SS}_{\text {between}}\), is the sum of the values in the third column in the previous table. Enter the value below. Round to two decimal places. \[\mathrm{SS}_{\text {between }}=\underline{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\nonumber\]


    Dividing \(\mathrm{SS}_{\text {between}}\) by its degrees of freedom \((k – 1)\) gives the variance between samples. The variance between the samples is labeled \(\mathrm{MS}_{\text {between}}\), because it is the Mean of the Squared deviations between the sample means and the grand mean \((\text { denoted } \mathrm{MS}_{\text {between}})\),

    \[\mathrm{MS}_{\text {between}}=\frac{\sum n(\bar{x}-\overline{\bar{x}})^2}{k-1}=\frac{\mathrm{S S}_{\text {between}}}{k-1}\nonumber\]
     

    1. Compute \(\mathrm{MS}_{\text {between}}\) by dividing \(\mathrm{SS}_{\text {between}}\) by its degrees of freedom. Remember that k is the number of samples.

      \[\mathrm{MS}_{\text {between}}=\frac{\mathrm{SS}_{\text {between}}}{k-1}=\underline{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\nonumber\]
       

    The denominator of the F-statistic estimates the common population variance \((\sigma^2)\) using the variance within the samples. When the sample sizes are different, this is the weighted mean of the sample variances, using the degrees of freedom (n − 1) as weights.


    \[s_p^2=\frac{\Sigma(n-1) s^2}{N-k}\nonumber\]


    The numerator of the variance within the samples is the corresponding sum of squares \(\left(\mathrm{SS}_{\text {within }}\right)\),

    \[\mathrm{SS}_{\text {within }}=\sum(n-1) s^2=\left(n_1-1\right) s_1^2+\left(n_2-1\right) s_2^2+\ldots+\left(n_k-1\right) s_k^2\nonumber\]

     

    1. Compute \(\mathrm{SS}_{\text {within}}\) using the table below.
       
      1. For each sample, multiply the degrees of freedom by variance. Enter the result into the corresponding cell in the third column in the table below. Round to the nearest whole number.
         

        Method

        \(n\)

        \(s^2\)

        \((n-1) \cdot s^2\)

        1

             

        2

             

        3

             

        Totals

         

        -----------------

         
      2. Sum of Squares within the samples, \(\mathrm{SS}_{\text {within}}\), is the sum of the values in the third column in the previous table. Enter the value below.
        \[\mathrm{SS}_{\text {within}}=\underline{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\nonumber\]

    The degrees of freedom for \(\mathrm{SS}_{\text {within}}\) is the sum of the degrees of freedom for each variance that it uses, \(\Sigma(n-1)=N-k\). The variance within the samples is labeled \(\mathrm{MS}_{\text {within}}\), because it is the Mean of the Squared deviations within the samples. This is \(\mathrm{SS}_{\text {within}}\) divided by its degrees of freedom.

    \[\mathrm{MS}_{\text {within }}=\frac{\mathrm{SS}_{\text {within }}}{N-k}\nonumber\]

    1. Compute \(\mathrm{MS}_{\text {within}}\) below. Round to two decimal places.

      \[\mathrm{MS}_{\text {within }}=\frac{\mathrm{SS}_{\text {within }}}{N-k}=\underline{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\nonumber\]

    As before, the \(F\)-test statistic is the ratio of the variance between the samples \((\mathrm{MS}_{\text{between}})\) and the variance within the samples \((\mathrm{MS}_{\text {within}})\).
    \[F=\frac{\mathrm{M S}_{\text{between }}}{\mathrm{MS}_{\text{within }}}\nonumber\]
     

    1. Compute the \(F\)-test statistic for this hypothesis test. Round to two decimal places.
      \[F=\frac{\mathrm{M S}_{\text{between }}}{\mathrm{MS}_{\text{within }}}=\underline{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\nonumber\]


    The degrees of freedom for the numerator of the test statistic are \(\mathrm{df}_1=\mathrm{k}-1\). The degrees of freedom for the denominator of the test statistic are \(\mathrm{df}_2=\mathrm{N}-\mathrm{k}\).
     

    1. What are the degrees of freedom for variance in the numerator and in the denominator of the F-test statistic?

      \[\begin{gathered}
      \mathrm{df}_1=\underline{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ } \\ \\
      \mathrm{df}_2=\underline{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
      \end{gathered}\]
       

    Both \(\mathrm{MS}_{\text {between}}\) and \(\mathrm{MS}_{\text {within}}\) are estimates of the common population variance \((\sigma^2)\), computed under the assumption that the null hypothesis is true. If the null hypothesis is true, and the samples are from populations with the same mean, the two estimates of the common population variance should be similar, and the \(F\)-test statistic should be close to one.

    When the null hypothesis is false, the sample means should be very different, and their standard deviation, \(s_\bar{x}\), will be large, causing the variance between the samples to be larger than the variance within the samples. This will yield a large \(F\)-test statistic and a small P-value in the right tail of the distribution of \(F\)-statistics. This is why the \(F\)-test is always a right-tailed test.

    1. We use the desmos graph, https://www.desmos.com/calculator/cmjmq0smlb, to determine P-values for this F-test. Compute the P-value for this hypothesis test.

       

    Step 4: Make a Decision and State a Conclusion

    1. What can we conclude about the null and alternative hypotheses?



       
    2. Write a conclusion to the hypothesis test in the context of this problem.



       

    Summary

    When conducting a test comparing \(k = 3\) or more means using One-Way ANOVA with unequal sample sizes, the null and alternative hypotheses are


    This page titled 10.4: ANOVA is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Hannah Seidler-Wright.

    • Was this article helpful?