10.1: The Chi-Square Distribution
- Page ID
- 49072
\( \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 previous lessons, we have learned about binomial experiments. A binomial experiment has n independent trials with only two outcomes per trial (success and failure). We will now consider multinomial experiments in which we allow two or more outcomes per trial in n independent trials. A binomial experiment is a special case of a multinomial experiment. We will explore multinomial experiments by returning to a hypothesis test for a single population proportion.
College Completion Rates
Research on college completion has shown that about 60% of students who begin college eventually graduate. A publication of higher education claims that the proportion for STEM (science, technology, engineering, math) majors is different. Researchers randomly select 102 STEM majors and determine that 51 eventually graduate.
Step 1.
We will let \(p\) represent the proportion of all STEM majors who begin college and ultimately graduate. The null hypothesis is \(H_0: p=0.60\). The alternative hypothesis is \(H_a: p \neq 0.60\). The publication authors have the burden of proof and must produce evidence to support their claim that the proportion of college graduates among STEM majors is different against the assumption that it is not.
Step 2.
Recall, the null hypotheses is
\[H_0: p=0.60\nonumber\]
The number of expected successes in the sample is \(n p=102(0.60)=61.2 \geq 10\). The number of expected failures in the sample is \(n(1-p)=n-n p=102-61.2=40.8 \geq 10\). Therefore, the sampling distribution of sample proportions is approximately normal.
The sample proportion is
\[\hat{p}=\frac{x}{n}=\frac{51}{102}=0.5\nonumber\]
Step 3.
The sampling distribution is shown below. The major tick marks have been labeled with values of \(\hat{p}\) and the corresponding Z-scores.
Images are created with the graphing calculator, used with permission from Desmos Studio PBC.
We compute the Z-score for the sample statistic,
\[Z=\frac{\hat{p}-p}{\sqrt{\frac{p(1-p)}{n}}}=\frac{0.5-0.60}{\sqrt{\frac{0.60)(1-0.60)}{102}}} \approx-2.06155\nonumber\]
The sample statistic is 2.06155 standard errors below the assumed population proportion. We perform a two-tailed test because the alternative hypothesis, \(H_a: p \neq 0.60\), contains a not equal to inequality. We can now find the P-value, which is the probability of seeing a sample proportion as extreme or more extreme than 0.5, by finding the probability from the standard normal distribution. The P-value is approximately 0.03925.
Step 4.
The level of significance is 5% which is 0.05 as a decimal. 0.03925<0.05 so we reject the null hypothesis and support the alternative hypothesis. The sample data support the claim that the proportion of all STEM majors who eventually graduate is different than 60%.
Chi-Square Statistic
The test statistic, Z, as in the example above, works well for binomial experiments consisting of only two outcomes per trial. When there are three or more outcomes per trial, things get more complicated and the Z statistics are insufficient. For multinomial experiments, we can use a different test statistic. This statistic is denoted \(\chi^2\) (\(\chi\) is the Greek letter chi and is pronounced like in Cobra Kai, and not like tea). The formula for the test statistic is
\[\chi^2=\sum_i \frac{\left(O_i-E_i\right)^2}{E_i}\nonumber\]
Each outcome corresponds to one term in the sum above. \(E_i\) stands for the \(i^{th}\) expected frequency and \(O_i\) stands for the \(i^{th}\) observed frequency.
Example
To understand the terms in this test statistic, let's apply it to a basic example.
Robin is throwing a party for her daughter’s 16th birthday. She has party favors for all the guests to leave with.
Scenario 1. The party is a small gathering and five people attend. Robin only has four party favors.
Scenario 2. The party is huge and 51 people attend. Robin only has 50 party favors.
In which scenario above is Robin’s error more noticeable?
We can compute the relative error in each scenario:
Scenario 1. \(O=5, E=4 \text {, so } \frac{(O-E)^2}{E}=\frac{(5-4)^2}{4}=\frac{1}{4}=0.25\)
Scenario 2. \(O=51, E=50 \text {, so } \frac{(O-E)^2}{E}=\frac{(51-50)^2}{50}=\frac{1}{50}=0.02\)
When there are fewer people expected to attend, the impact of the error is significantly larger than if the same error is made when many people are expected to attend. The sum of these relative errors make up the chi-square test statistic.
The Normal Distribution vs the Chi-Square Distribution
We return to our original problem: Research on college completion has shown that about 60% of students who begin college eventually graduate. A publication of higher education claims that the proportion for STEM (science, technology, engineering, math) majors is different. Researchers randomly select 102 STEM majors and determine that 51 eventually graduate.
- What is the observed number of STEM majors who eventually graduate? (These are successes in the experiment).
\(O_1=\) ________________
- How many STEM majors are expected to graduate based on the null hypothesis?
\(E_1=\) ________________
- Compute the contribution of this outcome to the \(\chi^2\) test statistic.
\(\frac{\left(O_1-E_1\right)^2}{E_1}=\) ________________
- What is the observed number of STEM majors who do not eventually graduate? (These are failures in this experiment).
\(O_2=\) ________________
- How many STEM majors are not expected to graduate based on the null hypothesis?
\(E_2=\) ________________
- Compute the contribution of this outcome to the \(\chi^2\) test statistic.
\(\frac{\left(O_2-E_2\right)^2}{E_2}=\) ________________
- Think about the test statistic, where expected frequencies are based on p from the null hypothesis. If the null hypothesis is false, would we expect this statistic to be small or large?
- The number of STEM majors who did eventually graduate was observed from a random sample, and varies from sample to sample. Once this value is known, is the number of STEM majors who did not eventually graduate random?
- If degrees of freedom represent the number of observed frequencies that vary freely (randomly), how many degrees of freedom are present among the two observed frequencies (of those who did graduate and those that did not)?
- Add the values from numbers 3 and 6 to find the test statistic (round to three decimal places).
\[\chi^2=\sum_i \frac{\left(o_i-E_i\right)^2}{E_i}=\underline{\ \ \ \ \ \ \ \ \ \ }\nonumber\]
- Compute the square of the Z-statistic (round to three decimal places):
\[z^2=(-2.06155)^2=\underline{\ \ \ \ \ \ \ \ \ \ }\nonumber\]
- How is the \(\chi^2\) statistic, with one degree of freedom, related to the Z statistic?
- Go to this desmos graph, https://www.desmos.com/calculator/bjohldwaym, and enter the degrees of freedom and the test statistic from number 10 to calculate the P-value.
Images are created with the graphing calculator, used with permission from Desmos Studio PBC.
In summary, because the Z test for a population proportion yields the same P-value as the corresponding \(\chi^2\) test (with one degree of freedom), the tests are equivalent. We will use this distribution to compare three or more proportions in the next section.