SDS 291
September 10, 2025
\[ \text{Observed data} = \text{mathematical model} + \text{random error} \]
\[ \underbrace{y}_{\text{response}} = \underbrace{f}_{\text{model}}( \underbrace{x}_{\text{explanatory}}) + \underbrace{\epsilon}_{\text{error}} \]
Note
Today: summarizing linear patterns in the data! 🎉


# A tibble: 6 × 6
month day min_year max_year day_rank draft_number
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 1 1944 1950 1 305
2 1 2 1944 1950 2 159
3 1 3 1944 1950 3 251
4 1 4 1944 1950 4 215
5 1 5 1944 1950 5 101
6 1 6 1944 1950 6 224
Tip
Assumption: average value of the response is the same for all observations, regardless of the value of the explanatory variable
For each ball in the glass jar (\(i = 1, \ldots, n\)),
\[ \underbrace{\ y_{i}\ }_{\substack{\text{actual} \\ \text{draft no.}}} = \underbrace{\ \mu\ }_{\substack{\text{mean} \\ \text{draft no.}}} + \underbrace{\ \epsilon_{i}\ }_{\substack{\text{random} \\ \text{error}}} \]
Tip
“Fitting a model” refers to estimating the parameters in the model (in this case, \(\mu\))
\[\begin{align*} \widehat{\mu} &= \frac{1}{n}\sum_{i=1}^{n}y_i \\ &= \frac{1}{n}(y_1 + y_2 + \cdots + y_n) \\ &= \bar{y} \end{align*}\]
The Data:

The Fitted Model:
\[\begin{align*} \widehat{\mu} &= \frac{1}{n}\sum_{i=1}^{n}y_i \\ &= \frac{1}{n}(y_1 + y_2 + \cdots + y_n) \\ &= \frac{1}{n}(1 + 2 + \cdots + 366) \\ &= 183.5 \end{align*}\]
Call:
lm(formula = draft_number ~ 1, data = draft_data)
Coefficients:
(Intercept)
183.5
\[\begin{align*} e_i &= \text{observed} - \text{fitted}\\ &= y_i - \hat{y}_i \end{align*}\]
Tip
# A tibble: 366 × 7
draft_number .fitted .resid .hat .sigma .cooksd .std.resid
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 305 183. 122. 0.00273 106. 0.00362 1.15
2 159 183. -24.5 0.00273 106. 0.000147 -0.232
3 251 183. 67.5 0.00273 106. 0.00112 0.639
4 215 183. 31.5 0.00273 106. 0.000244 0.298
5 101 183. -82.5 0.00273 106. 0.00167 -0.781
6 224 183. 40.5 0.00273 106. 0.000403 0.383
7 306 183. 123. 0.00273 106. 0.00368 1.16
8 199 183. 15.5 0.00273 106. 0.0000590 0.147
9 194 183. 10.5 0.00273 106. 0.0000271 0.0994
10 325 183. 142. 0.00273 106. 0.00491 1.34
# ℹ 356 more rows
Tip
Assumption: average value of the response depends on the explanatory variable in a linear fashion
\[ \underbrace{\ y_{i}\ }_{\substack{\text{actual} \\ \text{draft no.}}} = \underbrace{\ \beta_0 + \beta_1 \cdot x_i \ }_{\substack{\text{mean} \\ \text{draft no.}\\ \text{for that day}}} + \underbrace{\ \epsilon_{i}\ }_{\substack{\text{random} \\ \text{error}}} \]
\[\begin{align*} Y &= \underbrace{\beta_0 + \beta_1 \cdot X}_{signal} + \underbrace{\epsilon}_{noise} \, (\text{random variables}) \\ \mathbb{E}[Y | X] &= \underbrace{\beta_0 + \beta_1 \cdot X}_{signal} + \underbrace{\epsilon}_{noise} \, (\text{expected value}) \\ y_i &= \underbrace{\beta_0 + \beta_1 \cdot x_i}_{signal} + \underbrace{\epsilon_i}_{noise} \, (\text{individual observation}) \end{align*}\]
\[\begin{align*} \widehat{Y} &= \hat{\beta}_0 + \hat{\beta}_1 \cdot X \, (\text{random variables}) \\ \widehat{y}_i &= \hat{\beta}_0 + \hat{\beta}_1 \cdot x_i \, (\text{individual observation}) \end{align*}\]
Note
Find the values \(\hat{\beta}_0\) and \(\hat{\beta}_1\) that will minimize the squared discrepancy between the data and the fitted model for the mean
\[ SSE = \sum_{i=1}^{n}e_i^2 = \sum_{i=1}^{n} \left( y_i - \underbrace{\left( \hat{\beta}_0 + \hat{\beta}_1 x_i \right)}_{\hat{y}_i} \right)^2 \]
\[\begin{align*} \hat{\beta}_1 &= \frac{\sum_{i=1}^{n}(y_i - \bar{y})(x_i - \bar{x})}{\sum_{i=1}^{n}(x_i - \bar{x})^2} \\ &= \left( \frac{\sum_{i=1}^{n}(y_i - \bar{y})(x_i - \bar{x})}{\left( \sqrt{\sum_{i=1}^{n}(x_i - \bar{x})^2} \right)^2} \right) \cdot \left( \frac{\sqrt{\sum_{i=1}^{n}(y_i - \bar{y})^2}}{\sqrt{\sum_{i=1}^{n}(y_i - \bar{y})^2}} \right) \\ &= r_{xy} \cdot \frac{s_y}{s_x} \end{align*}\]

SDS 291