#set document(title: "17.2 One-Way Tables", author: "OpenStax") #set page(width: 8.5in, height: auto, margin: 1in) #import "@preview/cetz:0.5.2" #set text(font: ("STIX Two Text", "Libertinus Serif", "New Computer Modern"), size: 10.5pt, lang: "en") #show math.equation: set text(font: ("STIX Two Math", "New Computer Modern Math")) #set par(justify: true, leading: 0.62em, spacing: 0.9em) #set enum(spacing: 1.1em) // room between list items so tall inline fractions don't collide #set list(spacing: 1.1em) #set table(stroke: 0.5pt + rgb("#c7ccd3")) #let BLUE = rgb("#183B6F") // brand navy — section bars + example/solution labels (white on navy 11.09:1) #let ORANGE = rgb("#A94509") // brand primary-700 — AA-safe deep orange for TEXT (5.93:1 on white; raw brand #F37021 is 2.94:1 and must never carry text) #let RED = rgb("#DC2626") // brand error-600 #let GREEN = rgb("#059669") // brand success-600 (decoration only; small green text uses green-text #007942) #show heading.where(level: 1): it => block(width: 100%, above: 0pt, below: 16pt, fill: gradient.linear(BLUE, rgb("#2C5AA0")), inset: (x: 14pt, y: 12pt), radius: 3pt, text(fill: white, weight: "bold", size: 19pt, it.body)) #show heading.where(level: 2): it => block(width: 100%, above: 18pt, below: 10pt, fill: BLUE, inset: (x: 10pt, y: 6pt), radius: 2pt, text(fill: white, weight: "bold", size: 12pt, it.body)) #show heading.where(level: 3): it => text(fill: ORANGE, weight: "bold", size: 12.5pt, it.body) #show heading.where(level: 4): it => text(fill: BLUE, weight: "bold", size: 10.5pt, it.body) #let examplebox(label, title, body) = block(width: 100%, breakable: true, fill: rgb("#EFF1F5"), stroke: 0.5pt + rgb("#CFDDF0"), radius: 4pt, inset: 10pt, above: 12pt, below: 12pt)[ #block(below: 6pt)[#box(fill: BLUE, inset: (x: 6pt, y: 2pt), radius: 2pt, text(fill: white, weight: "bold", size: 8.5pt, label)) #h(0.4em) #strong[#title]] #body] // rail = decorative left rule (raw brand token); labelcolor = AA-safe label text shade #let notebox(label, rail, labelcolor, tint, body) = block(width: 100%, breakable: true, fill: tint, stroke: (left: 3pt + rail), inset: (left: 10pt, rest: 8pt), radius: (right: 4pt), above: 11pt, below: 11pt)[ #text(fill: labelcolor, weight: "bold", size: 7.5pt, tracking: 0.5pt)[#upper(label)] #linebreak() #body] #let solutionbox(body) = block(above: 4pt, below: 8pt)[ #text(fill: BLUE, weight: "bold", size: 8.5pt)[Solution] #linebreak() #body] #let figph(msg) = block(width: 100%, height: 60pt, fill: rgb("#f6f7f9"), stroke: (paint: rgb("#c7ccd3"), dash: "dashed"), radius: 4pt, inset: 10pt)[ #align(center + horizon, text(fill: rgb("#889"), style: "italic", size: 9pt, msg))] // Standardize inlined figure sizes: measure the natural CeTZ canvas, then scale to a // consistent envelope (aspect-aware; see build_typst.py FIG_* constants). Unlike the // print preamble, dimensions are FLOORED: in an editor a user can trim a figure to a // degenerate 1-D shape (a bare line), and w/h or tw/w would then divide by zero. #let _STD_W = 3.5 #let _WIDE_W = 5.6 #let _MAX_H = 3.4 #let _ASPECT_WIDE = 2.2 #let _UPSCALE_MAX = 1.15 #let stdfig(body) = context { let m = measure(body) let w = calc.max(m.width / 1in, 0.01) let h = calc.max(m.height / 1in, 0.01) let tw = if w / h > _ASPECT_WIDE { _WIDE_W } else { _STD_W } let s = calc.min(tw / w, _MAX_H / h, _UPSCALE_MAX) align(center, box(scale(x: s * 100%, y: s * 100%, reflow: true, body))) } #show figure: set block(breakable: false) #set figure(gap: 8pt) #show figure.caption: set text(size: 8.5pt, fill: rgb("#555")) == 17.2#h(0.6em)One-Way Tables #notebox("Note", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ #emph[Prerequisites] Chi Square Distribution, Basic Concepts of Probability, Significance Testing #linebreak() #linebreak() ] #notebox("Note", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ #emph[Learning Objectives] + Describe what it means for there to be theoretically-expected frequencies + Compute expected frequencies + Compute Chi Square + Determine the degrees of freedom ] The Chi Square distribution can be used to test whether observed data differ significantly from theoretical expectations. For example, for a fair six-sided die, the probability of any given outcome on a single roll would be 1/6. The data in Table 1 were obtained by rolling a six-sided die 36 times. However, as can be seen in Table 1, some outcomes occurred more frequently than others. For example, a "3" came up nine times, whereas a "4" came up only two times. Are these data consistent with the hypothesis that the die is a fair die? Naturally, we do not expect the sample frequencies of the six possible outcomes to be the same since chance differences will occur. So, the finding that the frequencies differ does not mean that the die is not fair. One way to test whether the die is fair is to conduct a significance test. The null hypothesis is that the die is fair. This hypothesis is tested by computing the probability of obtaining frequencies as discrepant or more discrepant from a uniform distribution of frequencies as obtained in the sample. If this probability is sufficiently low, then the null hypothesis that the die is fair can be rejected. Table 1. Outcome Frequencies from a Six-Sided Die. #figure(table( columns: 2, align: left, inset: 6pt, table.header([Outcome], [Frequency]), [1], [8], [2], [5], [3], [9], [4], [2], [5], [7], [6], [5], )) The first step in conducting the significance test is to compute the expected frequency for each outcome given that the null hypothesis is true. For example, the expected frequency of a "1" is 6 since the probability of a "1" coming up is 1/6 and there were a total of 36 rolls of the die. Expected frequency = (1/6)(36) = 6 Note that the expected frequencies are expected only in a theoretical sense. We do not really "expect" the observed frequencies to match the "expected frequencies" exactly. The calculation continues as follows. Letting E be the expected frequency of an outcome and O be the observed frequency of that outcome, compute #math.equation(block: true, alt: "the fraction open parenthesis E minus O close parenthesis squared over E")[$frac(( E − O )^(2), E)$] for each outcome. Table 2 shows these calculations. Table 2. Outcome Frequencies from a Six-Sided Die. #figure(table( columns: 4, align: left, inset: 6pt, table.header([Outcome], [E], [O], [#math.equation(block: false, alt: "the fraction open parenthesis E minus O close parenthesis squared over E")[$frac(( E − O )^(2), E)$]]), [1], [6], [8], [0.667], [2], [6], [5], [0.167], [3], [6], [9], [1.500], [4], [6], [2], [2.667], [5], [6], [7], [0.167], [6], [6], [5], [0.167], )) Next we add up all the values in Column 4 of Table 2. #math.equation(block: true, alt: "∑ the fraction open parenthesis E minus O close parenthesis squared over E equals 5.333")[$∑ frac(( E − O )^(2), E) = 5.333$] This sampling distribution of #math.equation(block: false, alt: "∑ the fraction open parenthesis E minus O close parenthesis squared over E")[$∑ frac(( E − O )^(2), E)$] is approximately distributed as Chi Square with k-1 degrees of freedom, where k is the number of categories. Therefore, for this problem the test statistic is #math.equation(block: true, alt: "χ sub 5 squared equals 5.333")[$χ_(5)^(2) = 5.333$] which means the value of Chi Square with 5 degrees of freedom is 5.333. From a Chi Square calculator it can be determined that the probability of a Chi Square of 5.333 or larger is 0.377. Therefore, the null hypothesis that the die is fair cannot be rejected. This Chi Square test can also be used to test other deviations between expected and observed frequencies. The following example shows a test of whether the variable "University GPA" in the SAT and College GPA case study is normally distributed. The first column in Table 3 shows the normal distribution divided into five ranges. The second column shows the proportions of a normal distribution falling in the ranges specified in the first column. The expected frequencies (E) are calculated by multiplying the number of scores (105) by the proportion. The final column shows the observed number of scores in each range. It is clear that the observed frequencies vary greatly from the expected frequencies. Note that if the distribution were normal, then there would have been only about 35 scores between 0 and 1, whereas 60 were observed. Table 3. Expected and Observed Scores for 105 University GPA Scores. #figure(table( columns: 4, align: left, inset: 6pt, table.header([Range], [Proportion], [E], [O]), [Above 1], [0.159], [16.695], [9], [0 to 1], [0.341], [35.805], [60], [-1 to 0], [0.341], [35.805], [17], [Below -1], [0.159], [16.695], [19], )) The test of whether the observed scores deviate significantly from the expected scores is computed using the familiar calculation. #math.equation(block: true, alt: "χ sub 3 squared equals ∑ the fraction open parenthesis E minus O close parenthesis squared over E equals 30.09")[$χ_(3)^(2) = ∑ frac(( E − O )^(2), E) = 30.09$] The subscript "3" means there are three degrees of freedom. As before, the degrees of freedom is the number of outcomes minus 1, which is 4 - 1 = 3 in this example. The Chi Square distribution calculator shows that p \< 0.001 for this Chi Square. Therefore, the null hypothesis that the scores are normally distributed can be rejected. #link("https://onlinestatbook.com/2/calculators/chi_square_prob.html")[Chi Square Calculator]