Log Transformations and Polynomial Terms
Interpret log-level, level-log and log-log models as percentage changes and elasticities, and fit curves with quadratic terms without extrapolating them.
Welcome back!
Step 1 of 12Learn
When a straight line is the wrong shape
A labor economist plots hourly wages against years of education for 5,000 workers. The cloud bends upward: each extra year of schooling seems to add more dollars at higher education levels than at lower ones. The residuals from a straight line show a clear curve, and their spread fans out as wages rise.
Then she plots the logarithm of wages instead. The bend disappears, the spread evens out, and a straight line fits well. The slope now has a natural meaning: each extra year of education is associated with wages about 8% higher, whatever the starting level.
Many relationships in economics, biology and business are multiplicative rather than additive. Prices, incomes, populations and sales tend to grow by percentages, not fixed amounts. Errors tend to be proportional to the level, so a forecast for a $2 million company is off by more dollars than one for a $200,000 company. Logarithms turn multiplicative patterns into additive ones that linear regression handles well.
Other relationships genuinely curve: crop yield rises with fertilizer and then falls when there is too much; fuel economy peaks at moderate speeds. Polynomial terms such as x² let a regression bend.
The model is still called linear regression in both cases, because it is linear in the coefficients, even though the relationship between the original variables is curved. This lesson shows how to fit and, more importantly, how to interpret these models.
Step 2 of 12Learn
Interpreting log models
Logs here are natural logs (ln). Three common forms, each with its own interpretation:
Log-level: ln(y) = b₀ + b₁x. A one-unit increase in x is associated with y changing by about 100 × b₁ percent. If b₁ = 0.08 for education, each year goes with wages about 8% higher. The approximation is good for small b₁; the exact change is (eb₁ − 1) × 100%, which for 0.08 is 8.3%, and for b₁ = 0.30 is 35%, noticeably more than 30%.
Level-log: y = b₀ + b₁ ln(x). A 1% increase in x is associated with y changing by about b₁ / 100 units. If monthly sales = 200 + 500 × ln(ad spend), a 1% increase in ad spend goes with about 5 more sales. This form captures diminishing returns: each doubling of spending adds the same amount, so each extra dollar adds less.
Log-log: ln(y) = b₀ + b₁ ln(x). A 1% increase in x is associated with about a b₁ percent change in y. Economists call b₁ an elasticity. If ln(quantity sold) = 6 − 1.2 × ln(price), a 1% price increase goes with about 1.2% fewer units sold: demand is elastic.
Logs require positive values. For variables containing zeros, analysts sometimes use ln(x + 1), which changes the interpretation for small values, so use it with care.
Step 3 of 12Compare
Three log models at a glance
| Aspect | Log-level | Level-log | Log-log |
|---|---|---|---|
| Form | ln(y) = b₀ + b₁x | y = b₀ + b₁ ln(x) | ln(y) = b₀ + b₁ ln(x) |
| One step in x | +1 unit | +1% | +1% |
| Change in y | ≈ 100 × b₁ % | ≈ b₁ / 100 units | ≈ b₁ % |
| Typical use | Wages vs. years of school | Output vs. spending | Demand vs. price (elasticity) |
Step 4 of 12Practice · Match the pairs
Match each model to the correct interpretation of its slope b₁.
Tap an answer, then tap the place where it belongs (or drag it there).
- ln(y) = b₀ + b₁x
- y = b₀ + b₁ ln(x)
- ln(y) = b₀ + b₁ ln(x)
- y = b₀ + b₁x
Step 5 of 12Practice · Work it out
A model has ln(salary) = 10.2 + 0.30 × (has a graduate degree), where the predictor is 1 or 0. Using the exact formula, by what percentage is predicted salary higher for people with a graduate degree? Round to one decimal place.
Step 6 of 12Explore
A quadratic curve
A quadratic model ŷ = c₀ + c₁x + c₂x² bends up when c₂ is positive and down when c₂ is negative. The readouts show where the curve turns.
- Turning point at x =
- 6
- Predicted y at the turning point
- 38
Step 7 of 12Learn
Polynomial terms and turning points
To let a regression curve, add powers of x as extra predictors: ŷ = b₀ + b₁x + b₂x². The fitting is ordinary least squares, since x² is simply another column.
The sign of b₂ sets the shape. Negative b₂ gives an upside-down U (rise, peak, fall), as for crop yield against fertilizer or productivity against hours worked. Positive b₂ gives a U shape, as for average cost per unit against production volume.
The turning point is at x = −b₁ / (2b₂). For a yield model ŷ = 20 + 6x − 0.5x², where x is fertilizer in units per acre, the peak is at x = −6 / (2 × −0.5) = 6 units, with predicted yield 20 + 36 − 18 = 38.
With a squared term, the individual coefficients no longer have the simple "per unit" meaning. The effect of one more unit of x depends on where you start: the slope at any point is b₁ + 2b₂x. At x = 2 the yield model rises by about 6 − 2 = 4 per unit; at x = 6 it is flat; beyond 6 it falls.
Two cautions. First, polynomials behave wildly outside the range of the data; a quadratic fit to ages 20 to 60 may predict negative values at age 90. Second, higher powers (x³, x⁴…) can fit almost anything, which is a fast road to overfitting. Use them only when theory or clear residual patterns call for them, and validate on new data.
Step 8 of 12Practice · Chart
A curved fit: ŷ = 12 + 1.2x − 0.03x²
Tap where predicted wage peaks.
Tap the point that answers the question, then press Check.
| Years of experience | Predicted hourly wage |
|---|---|
| 0 | $12 |
| 5 | $17.25 |
| 10 | $21 |
| 15 | $23.25 |
| 20 | $24 |
| 25 | $23.25 |
| 30 | $21 |
| 35 | $17.25 |
| 40 | $12 |
Step 9 of 12Practice · Work it out
A model of crop yield on fertilizer is ŷ = 20 + 6x − 0.5x². At what amount of fertilizer x is predicted yield highest?
Step 10 of 12Note
Step 11 of 12Practice · True or false
In the log-level model ln(y) = b₀ + b₁x, the coefficient b₁ = 0.02 means that a one-unit increase in x is associated with y about 2% higher.
Step 12 of 12Practice · Choose one
A log-log demand model for a product gives ln(units sold) = 7.5 − 0.4 × ln(price). Which interpretation is correct?
Lesson complete!