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.
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 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.
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 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/