Lesson 4.2: Testing Goodness of Fit in One-way Tables
Software Lab 4.2
Chi-Square Goodness-of-Fit Test
As you work through the lab, answer the ungraded exercises in the shaded boxes. Check your answers by consulting the Software Lab 4.2 Solutions.
Remember to complete the graded Software Lab Questions for this section in Moodle.
Is a Die Fair?
Consider the example in Supplementary Notes 4.2. A fair six-sided die was rolled 600 times. Download the data frame dice600 [CSV file], and open the data in jamovi. The variable outcome
records which of the outcomes one to six occurred in each roll.
Visualize the distribution of the variable outcome
using a frequency table and a bar plot by selecting Analyses > Exploration > Descriptives
and then selecting Frequency tables
and Plots > Bar plot
. Confirm that the observed cell frequencies match those in Supplementary Notes 4.2, i.e., 96 for “1,” 94 for “2,” etc.
![Rendered by QuickLaTeX.com \chi^2 = \sum \dfrac{(Obs-Exp)^2}{Exp}](https://introprobabilityandstatistics.pressbooks.tru.ca/wp-content/ql-cache/quicklatex.com-eb837f3765b460886cfe3c490f2d0e8b_l3.png)
Analyses > R > Rj Editor
and use the R function pchisq
to calculate the p-value. Then evaluate the hypothesis test based on a significance level ![Rendered by QuickLaTeX.com \alpha = 0.05](https://introprobabilityandstatistics.pressbooks.tru.ca/wp-content/ql-cache/quicklatex.com-ad6ce5c9ea5f3e49e839c4b3d5273902_l3.png)
Analyses > Frequencies > One Sample Proportion Tests > N Outcomes χ2 Goodness of fit
and move outcome
to the Variable
box. Confirm the value of the test statistic from question 2 and the p-value from question 3.Are Trading Days Independent?
Consider the stock market example in Section 6.3.5 of the textbook. Download the data from sp500seq [CSV file] (OpenIntro, n.d.) and open it in jamovi. The variable days
records the number of waiting days for a positive trading day during 10 years for the Standard and Poor’s 500 (S&P 500) stock market index.
Visualize the distribution of the variable days
using a frequency table and a bar plot by selecting Analyses > Exploration > Descriptives
and then selecting Frequency tables
and Plots > Bar plot
. Confirm that the observed cell frequencies match those in the textbook; i.e., 717 for “1,” 369 for “2,” etc.
![Rendered by QuickLaTeX.com = 1362 \times (1-0.545)^{D-1}(0.545)](https://introprobabilityandstatistics.pressbooks.tru.ca/wp-content/ql-cache/quicklatex.com-2fe2abaf59ef034daef6bb9415518ed9_l3.png)
![Rendered by QuickLaTeX.com D \in \{1, 2, 3, 4, 5, 6\}](https://introprobabilityandstatistics.pressbooks.tru.ca/wp-content/ql-cache/quicklatex.com-1896ebfb576d212fc64fb0348853f400_l3.png)
![Rendered by QuickLaTeX.com \chi^2 = \sum \dfrac{(Obs-Exp)^2}{Exp}](https://introprobabilityandstatistics.pressbooks.tru.ca/wp-content/ql-cache/quicklatex.com-eb837f3765b460886cfe3c490f2d0e8b_l3.png)
Analyses > R > Rj Editor
and use the R function pchisq
to calculate the p-value. Then evaluate the hypothesis test based on a significance level ![Rendered by QuickLaTeX.com \alpha = 0.05](https://introprobabilityandstatistics.pressbooks.tru.ca/wp-content/ql-cache/quicklatex.com-ad6ce5c9ea5f3e49e839c4b3d5273902_l3.png)
Analyses > Frequencies > N Outcomes χ2 Goodness of fit
and move days
to the Variable
box. Then click Expected Proportions
and type-in the expected cell frequencies you calculated in questions 5 and 6 in the “Ratio” boxes. Confirm the value of the test statistic from question 8 and the p-value from question 9.References
OpenIntro. (n.d.). Data sets [Data sets]. https://openintro.org/data/