01 / 20

Simple Linear
Regression

Learn to fit the best-fit line to biological data, interpret the slope and intercept, and assess model quality with \( r^2 \).

Biostatistics

What Is Regression?

In biology and health sciences, we often want to understand how one variable predicts another. For example: does increasing a drug dosage predict a larger reduction in blood pressure?

Simple linear regression fits a straight line through a scatterplot of data to model the relationship between an explanatory variable \( x \) and a response variable \( y \).

Key Vocabulary

Explanatory Variable
The independent variable \( x \): the predictor you control or observe first.
Response Variable
The dependent variable \( y \): the outcome you want to predict.
Residual
The difference \( e_i = y_i - \hat{y}_i \) between an observed value and the predicted value.

Visualizing Data with a Scatterplot

Dosage (mg) Response (mmHg drop) 10 20 30 40 50 5 10 15 20 best-fit

Each dot is one observation. The dashed line is the regression line: it captures the overall linear trend from low dosage to high dosage.

The Regression Equation

\( \hat{y} \)
The predicted value of the response variable for a given \( x \).
\( b_0 \) : Intercept
The predicted \( y \) when \( x = 0 \). Often has limited biological meaning.
\( b_1 \) : Slope
The change in \( \hat{y} \) for each one-unit increase in \( x \).

The Least Squares Method

The best-fit line minimizes the sum of squared residuals: the total squared vertical distance between each data point and the line.

x y regression line residuals

The dashed red segments are residuals. Squaring them penalizes large errors more than small ones, producing a line that balances all predictions.

Computing \( b_1 \) and \( b_0 \)

1
\( r \) is the correlation coefficient between \( x \) and \( y \).
2
\( s_x \) and \( s_y \) are the standard deviations of \( x \) and \( y \).
3
\( \bar{x} \) and \( \bar{y} \) are the means. The regression line always passes through the point \( (\bar{x}, \bar{y}) \).

Correlation vs Regression

Correlation \( r \) Regression
Purpose Measures strength and direction of linear association Models the relationship to make predictions
Output A single number: \( -1 \leq r \leq 1 \) An equation: \( \hat{y} = b_0 + b_1 x \)
Symmetry \( r_{xy} = r_{yx} \) Regressing \( y \) on \( x \) differs from \( x \) on \( y \)
Units Unitless Slope has units: \( \text{units of } y / \text{units of } x \)

Interpreting \( r^2 \)

\( r^2 \) is the coefficient of determination. It tells you the proportion of the variability in \( y \) that is accounted for by the linear relationship with \( x \).

\( r^2 = 0.85 \)
85% of the variation in blood pressure reduction is explained by dosage.
\( r^2 = 0.30 \)
Only 30% of variability is explained: the model is weak. Other factors matter.

Step-by-Step: Fitting a Regression

1
Plot your data. Create a scatterplot of \( y \) vs \( x \). Check for a linear pattern.
2
Compute \( r \). Calculate the correlation coefficient to confirm linearity.
3
Find \( b_1 \) and \( b_0 \). Use the formulas: \( b_1 = r \cdot \frac{s_y}{s_x} \) and \( b_0 = \bar{y} - b_1 \bar{x} \).
4
Write the equation. Express it in context: \( \widehat{\text{response}} = b_0 + b_1 \cdot \text{predictor} \).
5
Interpret. State the slope and \( r^2 \) in the context of the problem.
6
Check residuals. Plot residuals vs \( x \): look for patterns indicating nonlinearity.

Example 1: Plant Growth

A botanist records sunlight hours (\( x \)) and stem height in cm (\( y \)) for 8 plants. Summary statistics:

1
Slope: \( b_1 = 0.90 \times \frac{5}{2} = 2.25 \)
2
Intercept: \( b_0 = 14 - 2.25(6) = 14 - 13.5 = 0.5 \)
3
Equation: \( \widehat{\text{height}} = 0.5 + 2.25 \cdot \text{sunlight} \)

Example 2: Predicting a Value

Using the plant growth model \( \widehat{\text{height}} = 0.5 + 2.25x \), predict the height for a plant receiving 8 hours of sunlight.

Now suppose you want to predict height for a plant receiving 15 hours. Is that reasonable?

Example 3: Reading a Residual Plot

Predicted value Residual 0 Good: random scatter around zero

A good residual plot shows points scattered randomly around the zero line with no pattern. If you see a curve or fan shape, the linear model is not appropriate.

Common Mistakes

✕ Correlation = Causation
A strong \( r \) does not mean \( x \) causes \( y \). Lurking variables may drive both.
✕ Extrapolating Wildly
Predicting far beyond the observed \( x \)-range assumes the linear trend continues indefinitely.
✕ Ignoring Residual Plots
A high \( r^2 \) with a curved residual pattern still means the model is wrong.

Regression Cheat Sheet

Concept Symbol Interpretation
Slope \( b_1 \) Change in \( \hat{y} \) per unit increase in \( x \)
Intercept \( b_0 \) Predicted \( y \) when \( x = 0 \)
Correlation \( r \) Strength and direction of linear association (\( -1 \) to \( 1 \))
Coefficient of determination \( r^2 \) Proportion of variance in \( y \) explained by the model
Residual \( e_i = y_i - \hat{y}_i \) Observed minus predicted: positive = underestimate
Least squares criterion \( \min \sum e_i^2 \) The line minimizes total squared error

Question 1 of 5

A regression equation is \( \hat{y} = 12 + 3.5x \). What does the slope of \( 3.5 \) mean?

Question 2 of 5

If \( r = -0.80 \), what is \( r^2 \) and what does it tell us?

Question 3 of 5

A study finds \( \bar{x} = 50 \), \( s_x = 10 \), \( \bar{y} = 200 \), \( s_y = 40 \), and \( r = 0.75 \). What is the slope \( b_1 \)?

Question 4 of 5

A patient's observed cholesterol is 220 mg/dL and the regression model predicts 205 mg/dL. What is the residual?

Question 5 of 5

A residual plot shows a clear U-shaped curve. What should you conclude?