#set document(title: "14.5 Inferential Statistics for b and r", 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")) == 14.5#h(0.6em)Inferential Statistics for b and r #notebox("Note", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ #emph[Prerequisites] Sampling Distribution of r, Confidence Interval for r #linebreak() #linebreak() ] #notebox("Note", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ #emph[Learning Objectives] + State the assumptions that inferential statistics in regression are based upon + Identify heteroscedasticity in a scatter plot + Compute the standard error of a slope + Test a slope for significance + Construct a confidence interval on a slope + Test a correlation for significance ] This section shows how to conduct significance tests and compute confidence intervals for the regression slope and Pearson's correlation. As you will see, if the regression slope is significantly different from zero, then the correlation coefficient is also significantly different from zero. === Assumptions Although no assumptions were needed to determine the best-fitting straight line, assumptions are made in the calculation of inferential statistics. Naturally, these assumptions refer to the population, not the sample. + Linearity: The relationship between the two variables is linear. + Homoscedasticity: The variance around the regression line is the same for all values of X. A clear violation of this assumption is shown in Figure 1. Notice that the predictions for students with high high-school GPAs are very good, whereas the predictions for students with low high-school GPAs are not very good. In other words, the points for students with high high-school GPAs are close to the regression line, whereas the points for low high-school GPA students are not. #figure(figph[Scatter plot of University GPA (y-axis 2 to 4) against High School GPA (x-axis 2 to 4) for the SAT case study, with a red regression line rising across the plot (University GPA' = 0.675 x High School GPA + 1.097, correlation 0.78). The points hug the line closely at the high-GPA end but scatter widely at the low end, where a cluster sits near a university GPA of 2.2-2.5 far below the line — the fan shape that makes this the book's example of a violation of homoscedasticity.], alt: "Scatter plot of University GPA (y-axis 2 to 4) against High School GPA (x-axis 2 to 4) for the SAT case study, with a red regression line rising across the plot (University GPA' = 0.675 x High School GPA + 1.097, correlation 0.78). The points hug the line closely at the high-GPA end but scatter widely at the low end, where a cluster sits near a university GPA of 2.2-2.5 far below the line — the fan shape that makes this the book's example of a violation of homoscedasticity.", caption: [Figure 1. University GPA as a function of High School GPA.]) + The errors of prediction are distributed normally. This means that the deviations from the regression line are normally distributed. It does not mean that X or Y is normally distributed. #linebreak() Significance Test for the Slope (b) Recall the general formula for a t test: #math.equation(block: true, alt: "t equals the fraction statistic minus hypothesized value over estimated standard error of the statistic")[$t = frac("statistic" − "hypothesized value", "estimated standard error of the statistic")$] As applied here, the statistic is the sample value of the slope (b) and the hypothesized value is 0. The number of degrees of freedom for this test is: df = N-2 where N is the number of pairs of scores. The estimated standard error of b is computed using the following formula: #math.equation(block: true, alt: "s sub b equals the fraction s sub est over the square root of S S X")[$s_(b) = frac(s_("est"), sqrt(S S X))$] where s#sub[b] is the estimated standard error of b, s#sub[est] is the standard error of the estimate, and SSX is the sum of squared deviations of X from the mean of X. SSX is calculated as #math.equation(block: true, alt: "S S X equals ∑ open parenthesis X minus M sub X close parenthesis squared")[$S S X = ∑ ( X − M_(X) )^(2)$] where M#sub[x] is the mean of X. As shown previously, the standard error of the estimate can be calculated as #math.equation(block: true, alt: "s sub est equals the square root of the fraction open parenthesis 1 minus r squared close parenthesis S S Y over N minus 2")[$s_("est") = sqrt(frac(( 1 − r^(2) ) S S Y, N − 2))$] These formulas are illustrated with the data shown in Table 1. These data are reproduced from the introductory section. The column X has the values of the #strong[predictor variable] and the column Y has the values of the #strong[criterion variable]. The third column, x, contains the differences between the values of column X and the mean of X. The fourth column, x#super[2], is the square of the x column. The fifth column, y, contains the differences between the values of column Y and the mean of Y. The last column, y#super[2], is simply square of the y column. #linebreak() Table 1. Example data. #figure(table( columns: 7, align: left, inset: 6pt, table.header([], [X], [Y], [x], [x#super[2]], [y], [y#super[2]]), [], [1.00], [1.00], [-2.00], [4], [-1.06], [1.1236], [], [2.00], [2.00], [-1.00], [1], [-0.06], [0.0036], [], [3.00], [1.30], [0.00], [0], [-0.76], [0.5776], [], [4.00], [3.75], [1.00], [1], [1.69], [2.8561], [], [5.00], [2.25], [2.00], [4], [0.19], [0.0361], [Sum], [15.00], [10.30], [0.00], [10.00], [0.00], [4.5970], )) The computation of the standard error of the estimate (s#sub[est]) for these data is shown in the section on the standard error of the estimate. It is equal to 0.964. s#sub[est] = 0.964 SSX is the sum of squared deviations from the mean of X. It is, therefore, equal to the sum of the x#super[2] column and is equal to 10. SSX = 10.00 We now have all the information to compute the standard error of b: #math.equation(block: true, alt: "s sub b equals the fraction 0.964 over the square root of 10 equals 0.305")[$s_(b) = frac(0.964, sqrt(10)) = 0.305$] As shown previously, the slope (b) is 0.425. Therefore, #math.equation(block: true, alt: "t equals the fraction 0.425 over 0.305 equals 1.39")[$t = frac(0.425, 0.305) = 1.39$] #linebreak() df = N-2 = 5-2 = 3. The p value for a two-tailed t test is 0.26. Therefore, the slope is not significantly different from 0. === Confidence Interval for the Slope The method for computing a confidence interval for the population slope is very similar to methods for computing other confidence intervals. For the 95% confidence interval, the formula is: lower limit: b - (t#sub[.95)(]s#sub[b]) #linebreak() upper limit: b + (t#sub[.95)(]s#sub[b]) where t#sub[.95] is the value of t to use for the 95% confidence interval. The values of t to be used in a confidence interval can be looked up in a table of the t distribution. A small version of such a table is shown in Table 2. The first column, df, stands for degrees of freedom. Table 2. Abbreviated t table. #figure(table( columns: 3, align: left, inset: 6pt, table.header([df], [0.95], [0.99]), [2], [4.303], [9.925], [3], [3.182], [5.841], [4], [2.776], [4.604], [5], [2.571], [4.032], [8], [2.306], [3.355], [10], [2.228], [3.169], [20], [2.086], [2.845], [50], [2.009], [2.678], [100], [1.984], [2.626], )) You can also use the "inverse t distribution" calculator to find the t values to use in a confidence interval. Applying these formulas to the example data, lower limit: 0.425 - (3.182)(0.305) = -0.55 #linebreak() upper limit: 0.425 + (3.182)(0.305) = 1.40 === Significance Test for the Correlation The formula for a significance test of Pearson's correlation is shown below: #math.equation(block: true, alt: "t equals the fraction r the square root of N minus 2 over the square root of 1 minus r squared")[$t = frac(r sqrt(N − 2), sqrt(1 − r^(2)))$] where N is the number of pairs of scores. For the example data, #math.equation(block: true, alt: "t equals the fraction 0.627 the square root of 5 minus 2 over the square root of 1 minus 0.627 squared equals 1.39")[$t = frac(0.627 sqrt(5 − 2), sqrt(1 − 0.627^(2))) = 1.39$] Notice that this is the same t value obtained in the t test of b. As in that test, the degrees of freedom is N - 2 = 5 -2 = 3.