library(palmerpenguins)
library(tidyverse)
penguins_clean <- penguins |> drop_na(bill_length_mm, flipper_length_mm)
lm(flipper_length_mm ~ bill_length_mm, data = penguins_clean) |> summary()10 Regression
10.1 Key Concepts
- Simple Linear Regression
- Multiple Regression
- Slope and Intercept
- Predicted Values (Ŷ)
10.2 Key Formulas
\[\hat{Y} = bX + a\]
\[b = r \cdot \frac{s_Y}{s_X}, \qquad a = \bar{Y} - b\bar{X}\]
10.3 Code Examples
penguins_clean <- penguins |> drop_na(bill_length_mm, flipper_length_mm, body_mass_g)
lm(flipper_length_mm ~ bill_length_mm + body_mass_g, data = penguins_clean) |> summary()10.4 Exercises
10.4.1 Conceptual Questions
Simple regression provides additional information above and beyond correlation, namely estimates for:
A. Strength and direction
B. Slope and intercept
C. Relationship and distance
D. Non-linear dynamics
The slope estimate in a regression formula is the:
A. Alpha
B. Beta ratio
C. “X” term in the formula
D. Beta coefficient
Regression determines the characteristics of a line that best fits through the data. Specifically, this line:
A. Intersects the x-axis when data values are positive
B. Intersects as many data points as possible
C. Maximizes the sum of the vertical distances between the data and the line
D. Minimizes the sum of the squared vertical distances between the data and the line
Ŷ (Y-hat) is:
A. The predicted Y value based on the regression formula
B. The observed Y value based on the regression formula
C. Inversely correlated with observed Y values
D. Not a value related to regression at all
TRUE or FALSE: Multiple regression can accommodate predictor variables of various types, including categorical predictors.
A. True
B. False
Consider the formula Ŷ = bX. What is missing, if anything?
A. The slope
B. The intercept
C. The predictor variable
D. Nothing is missing
Under the null hypothesis, the expected value of a beta coefficient is approximately:
A. 0
B. 0.5
C. −1
D. 0.1
Regression is BLUE. What does that mean?
A. Best Non-Linear Unbiased Estimate
B. Best Line Under Expected Value
C. Big Line Unsure Equivalence
D. Best Linear Unbiased Estimate
TRUE or FALSE: Multiple regression can accommodate two categorical predictors and no continuous predictors.
A. True
B. False
Dr. B conducts a regression predicting conference attendance (number of days) from attendee age (in years). Assuming age is not normalized into z-scores, the intercept will be:
A. Not computable, but would be sensical
B. Computable, but non-sensical
C. Not computable, but sensical
D. None of the above
10.4.2 Computational Questions
Note: show all steps. For each sub-part, plug the given values into the formula and compute Ŷ.
Problem 11 — Simple Regression
\[\hat{Y} = 3.5X + 13\]
| Sub-part | X | Ŷ |
|---|---|---|
| a | 1 | |
| b | 9 | |
| c | 24 |
- Plot the regression line for X = [1, 3, 9]. Label both axes, include the regression equation, and mark each point.
(First compute Ŷ for X = 3 below, then use all three points to draw the line.)
Ŷ at X = 3:
(plotting space)
Problem 12 — Multiple Regression
\[\hat{Y} = 3.5X + 1W + 13 \quad \text{(no plot required)}\]
| Sub-part | X | W | Ŷ |
|---|---|---|---|
| a | 1 | 1 | |
| b | 9 | 5 | |
| c | 24 | 30 | |
| d | 3 | 0 | |
| e | 0 | 0 |
Problem 13 — Multiple Regression with Negative Coefficient
\[\hat{Y} = 3X + (-0.6)W + 11 \quad \text{(no plot required; note the negative coefficient on } W \text{)}\]
| Sub-part | X | W | Ŷ |
|---|---|---|---|
| a | 1 | 1 | |
| b | 9 | 5 | |
| c | 24 | 30 | |
| d | 3 | 0 | |
| e | 0 | 0 |