Add predictors and watch coefficient estimates shift. Understand why controlling for confounders reveals true effects.
Sign in to track progress
The Dataset
Daily ice cream sales at a beach café (50 observations). Two predictors: Temperature (°C) and whether the day is a Weekend. Goal: understand how each factor drives sales, accounting for the other.
Scatter Plot: Ice Cream Sales vs Temperature
Hover over any point to see its values.
Simple Regression Equation
R²
0.9516
RMSE
4.16
Temperature coefficient: 3.331
For every +1°C increase in temperature, sales increase by $3.33k (according to this simple model).
Note
This model ignores whether it's a weekend. In this dataset, weekend days are both hotter AND more sales-prone, so the temperature slope absorbs part of the weekend effect and comes out inflated.
Key Concepts
Confounding Variable
A variable correlated with both the predictor and outcome, creating spurious associations.
Omitted Variable Bias
Excluding a relevant predictor causes its effect to leak into other coefficients.
Parallel Lines
In an additive model, lines for different groups are parallel: same slope, different intercept.
Interaction Effect
When the effect of X₁ on Y changes depending on the value of X₂.
Adjusted R²
Penalizes adding predictors that don't meaningfully improve fit.
R² Comparison
Coefficient Comparison Table
Temperature coefficient shifts across models: confounding effect!| Coefficient | Simple | + Weekend | + Interaction |
|---|---|---|---|
| Intercept | -30.125 | -20.793 | -21.290 |
| Temperature | 3.331 | 2.835 | 2.857 |
| Weekend | — | 9.993 | 13.367 |
| Temp × Weekend | — | — | -0.117 |
| R² | 0.9516 | 0.9913 | 0.9914 |
| Adj. R² | — | 0.9909 | 0.9908 |
Temperature coefficient highlighted: compare values across models to see confounding effect.