Sub topic 18
Functional forms and log transformations
This chapter assumes you can estimate a simple regression by ordinary least squares and interpret its slope, R-squared, and residuals. It also assumes you know that the linearity assumption requires the relationship between the variables to be a straight line in the parameters. Here you learn what to do when it is not, and how to read the coefficients of the common log forms.
Why the form of the model matters
Simple linear regression fits y = b0 + b1·x + error. If the true relationship curves, the fitted line is misspecified. The residuals then show a systematic pattern instead of random scatter, the slope is a poor summary, and forecasts drift.
Many financial series grow at a roughly constant percentage rate: sales, earnings, and index levels. Their level grows exponentially, so a straight line fits badly. Taking natural logarithms often turns the curve into a line and lets you estimate OLS as usual.
Linear regression needs the model to be linear in the coefficients. It does not need it to be linear in the original variables. That is why transforming y or x is still "linear regression."
The four common forms
| Form | Model | Interpretation of b1 |
|---|---|---|
| Linear (lin-lin) | `y = b0 + b1·x` | One unit more x changes y by b1 units |
| Log-lin | `ln y = b0 + b1·x` | One unit more x changes y by about 100·b1 percent |
| Lin-log | `y = b0 + b1·ln x` | A 1% change in x changes y by about b1/100 units |
| Log-log | `ln y = b0 + b1·ln x` | A 1% change in x changes y by about b1 percent |
The log-log slope is an elasticity: the percentage change in y per percentage change in x. For example, a slope of 1.5 means a 1% rise in x goes with a 1.5% rise in y.
In a log-lin model the exact growth rate per unit of x is e^b1 − 1. The approximation 100·b1 is close only when b1 is small.
Worked example: constant growth
Suppose you estimate ln(sales) = 4.0 + 0.08·t, where t counts periods.
- The growth rate per period is
e^0.08 − 1 = 0.0833, or about 8.33%. The shortcut of 8% is close but not exact. - The forecast for t = 10 starts with
ln(sales) = 4.0 + 0.08 × 10 = 4.8. - You must convert back to the original units:
sales = e^4.8 ≈ 121.5.
Forgetting step 3 is a common exam error. The regression predicts ln y, not y.
Now two interpretation checks for the other forms:
- Lin-log:
y = 2 + 3·ln x. A 1% rise in x raises y by about3 / 100 = 0.03units. - Log-log:
ln y = 1 + 1.5·ln x. A 1% rise in x raises y by about 1.5%.
Choosing a form
Use economic reasoning alongside the plots. Constant-growth series suggest log-lin. Relationships framed as "percent response to percent change," such as demand elasticity, suggest log-log.
Seeing it in code
The script below fits a straight line and a log-lin model to the same growing series. It then compares the residual patterns and produces a forecast. Notice that the forecast is exponentiated back to the sales scale.
import numpy as np
from scipy import stats
t = np.arange(1, 9)
sales = np.array([100.0, 105.3, 110.1, 116.0, 121.2, 127.9, 133.6, 140.9])
lin = stats.linregress(t, sales)
log = stats.linregress(t, np.log(sales))
resid_lin = sales - (lin.intercept + lin.slope * t)
resid_log = np.log(sales) - (log.intercept + log.slope * t)
growth = np.exp(log.slope) - 1
forecast_t9 = np.exp(log.intercept + log.slope * 9)
print("Linear slope (units per period):", lin.slope)
print("Log-lin slope:", log.slope, "-> growth per period:", growth)
print("Linear residuals:", np.round(resid_lin, 2))
print("Log-lin residuals:", np.round(resid_log, 4))
print("Forecast for t = 9 (sales scale):", forecast_t9)For data like this, the linear residuals tend to be positive at both ends and negative in the middle, which is the signature of a curve fitted with a line. The log-lin residuals are smaller and less patterned. The log-lin slope is close to 0.05, so growth is roughly 5% per period.
Comparing models fairly
Two checks decide between forms, and one comparison is not valid.
- Residual plots: choose the form whose residuals look like random noise with constant spread.
- Economic sense: the form should match how the variables are believed to relate.
- R-squared and SEE are comparable only when the dependent variable is identical. A model for
ln yand a model foryexplain different quantities, so their R-squared values and standard errors of estimate are not on the same scale. Compare their residual patterns, or convert predictions back to y and compare errors there.
Limitations and gotchas
- Logs need positive values. You cannot take the log of zero or a negative number. Returns, which can be negative, are usually used as they are or converted to
ln(1 + r). - Back-transformation bias. Exponentiating a prediction of
ln ygives roughly the median of y, not the mean, so it tends to understate the average. CFA Level I questions normally ignore this adjustment. - The intercept changes meaning. In a log-lin model, b0 is the predicted
ln ywhen x = 0. Its level counterpart ise^b0. - Percentage language is approximate for large coefficients. Use
e^b1 − 1when b1 is not small. - A transformation is not a cure-all. It addresses curvature and, often, spread that grows with the level of y. It does not fix omitted variables or serial correlation. Always check the residuals again after transforming.
- A good fit inside the sample range does not justify extrapolating far outside it. A log-lin model projects growth at the same percentage rate forever, which is rarely realistic.
Summary of the working rules
- A model must be linear in its coefficients, not necessarily in its variables.
- Logging
ysuits constant percentage growth. Logging both variables gives an elasticity. - Read the slope in units that match the form.
- Convert forecasts back from logs.
- Judge fit by residual patterns and reasoning, not by comparing R-squared across different dependent variables.
Exercise
A regression gives ln(revenue) = 3.2 + 0.06·t, where t is the year number. (a) What is the exact annual growth rate? (b) What revenue does the model predict for t = 5, given that e^3.5 ≈ 33.1? (c) Can you compare this model's R-squared with that of a model of revenue (not its log) on t?
Show answer
(a) Growth is e^0.06 − 1 ≈ 0.0618, or about 6.18% per year. The approximation 100·b1 gives 6%. (b) ln(revenue) = 3.2 + 0.06 × 5 = 3.5, so revenue = e^3.5 ≈ 33.1. The prediction must be exponentiated. (c) No. The two models have different dependent variables (ln revenue and revenue), so their R-squared values measure explained variation of different quantities. Compare residual patterns, or compare errors after converting predictions to the same scale.
Exercise
In the model ln(quantity) = 5.0 − 1.2·ln(price), how do you interpret the slope, and what happens to quantity when price rises 2%?
Show answer
This is a log-log model, so the slope is an elasticity: a 1% rise in price goes with a 1.2% fall in quantity. A 2% price rise goes with a decline of about 1.2 × 2 = 2.4% in quantity.