Supervised ML · Chapter 2 · 18 min read

Log-Linear Regression: When Percentages Matter More Than Units

Sometimes the relationship between two variables isn't about absolute changes at all — it's about proportional ones. Does a 10% increase in advertising lead to a 5% increase in sales? Does doubling city size double a city's economic output? These are questions about elasticities, and the log-linear model is built to answer them. This page explains why and how.

Why Log-Transform? The Intuition

Standard OLS assumes that a one-unit change in $X$ always gives the same change in $Y$ — whether $X$ goes from 1 to 2 or from 1,000 to 1,001. But many real relationships don't work that way. Income grows exponentially. Company revenues span orders of magnitude. A doubling of firm size tends to produce more output regardless of whether you start at 10 or 1,000 employees.

The fix is elegant: take the natural logarithm of both variables. The key logarithm rule that makes this work:

$$\ln(a \cdot b) = \ln(a) + \ln(b) \qquad \ln(a^r) = r\cdot\ln(a)$$ $$\ln(a/b) = \ln(a) - \ln(b) \qquad \ln(e) = 1$$

And the most important fact for econometrics: for small changes, the difference in log values approximates the percentage change. Formally, if $Y$ changes by a small amount $\Delta Y$ (where $\Delta$ is the Greek letter "delta" and always means change in):

$$\Delta\ln(Y) = \ln(Y + \Delta Y) - \ln(Y) \approx \frac{\Delta Y}{Y}$$

This means $d\ln(Y) = \frac{dY}{Y}$ — where $d$ (the differential operator) represents an infinitesimally small change, the limiting version of $\Delta$ as the change becomes tiny. In other words, the differential of $\ln(Y)$ equals the relative change in $Y$, i.e. a percentage change (without needing to multiply by 100). This is the key insight that drives everything below.

Intuition: When you log-transform a curved, exponential-looking relationship, it straightens out into a line. Then you can apply OLS to that line.

Interactive — Log Transformation Straightens Curves

Left panel: the raw curved relationship — a straight OLS line would fit poorly. Right panel: after taking ln(Y) the curve straightens into a line that OLS can estimate cleanly. The log transformation is the key step.

The Log-Linear (Log-Log) Model

Starting from a non-linear relationship $Y = e^{\beta_0} \cdot X^{\beta_1} \cdot e^u$ (a power-law or multiplicative relationship), taking the natural log of both sides:

$$\ln(Y_i) = \beta_0 + \beta_1 \ln(X_i) + u_i$$

This is the log-log model (also called log-linear). It looks exactly like OLS — because it is OLS, just applied to the log-transformed variables. So we estimate it exactly the same way, using the transformed data $\ln(Y_i)$ and $\ln(X_i)$.

The crucial interpretive difference from standard OLS: $\hat{\beta}_1$ is now an elasticity. To see why, note that:

$$\hat{\beta}_1 = \frac{\partial \ln(Y)}{\partial \ln(X)} = \frac{\partial Y / Y}{\partial X / X} = \frac{\%\Delta Y}{\%\Delta X}$$

Here, $\partial$ (the "curly d") is the partial derivative symbol — it means "the rate of change of the numerator with respect to the denominator, holding everything else fixed." The middle term $\frac{\partial Y/Y}{\partial X/X}$ is a ratio of relative changes, which is the definition of elasticity. So $\hat{\beta}_1$ tells you: if $X$ increases by 1%, $Y$ changes by $\hat{\beta}_1$ percent, ceteris paribus (Latin for "all else equal"). This interpretation holds regardless of the units of $X$ or $Y$ — which is a major advantage when comparing across datasets or countries.

Interpretation rule: In a log-log model, $\hat{\beta}_1$ is an elasticity. If $\hat{\beta}_1 = 0.94$, then a 1% increase in $X$ leads to a 0.94% increase in $Y$.

Predicting Percentage Change in Y

Using the log-log model to predict how $Y$ responds to a percentage change in $X$ is straightforward:

$$\%\Delta Y \approx \hat{\beta}_1 \cdot \%\Delta X$$

Example: if $\hat{\beta}_1 = 0.94$ and $X$ increases by 5% ($\Delta X / X = 5\%$), then $Y$ is expected to increase by $0.94 \times 5 = 4.7\%$.

Interactive — Elasticity Calculator

β₁ is the elasticity — a 1% change in X shifts Y by β₁%. The bar shows the predicted % change in Y for your chosen % change in X. Slide β₁ between negative (X and Y move inversely) and positive (they move together) to see how the magnitude and direction change.

Predicting the Absolute Value of Y

What if you want to predict an actual value of $Y$ (not just a percentage change) for a given value of $X$? You need two steps:

$$\text{Step 1: } \widehat{\ln(Y)} = \hat{\beta}_0 + \hat{\beta}_1 \cdot \ln(X_{\text{new}})$$ $$\text{Step 2: } \hat{Y} = e^{\,\widehat{\ln(Y)}}$$

Remember: the model gives you $\widehat{\ln(Y)}$ — you must exponentiate it to get back to the original scale. Forgetting this step is the most common mistake with log models. Also recall that $e^{\ln(Y)} = Y$, i.e., the exponential and logarithm are inverses of each other.

The Differential and Elasticity — A Deeper Look

In calculus, the differential $df(x)$ of a function $f(x)$ represents how the function changes in response to an infinitesimally small change $dx$ in the input (think of $dx$ as $\Delta x$ shrunk to be infinitely tiny):

$$df = f'(x) \cdot dx \qquad \text{where } f'(x) = \frac{df}{dx} \text{ is the derivative (= slope of the function at } x\text{)}$$

For the logarithm specifically: $\frac{d\ln(Y)}{dY} = \frac{1}{Y}$, so $d\ln(Y) = \frac{dY}{Y}$ — the differential of the log equals the relative (percentage) change in $Y$. This is exactly why the elasticity interpretation works.

In the log-log model, $\hat{\beta}_1 = \frac{d\ln(Y)}{d\ln(X)} = \frac{dY/Y}{dX/X}$ is the ratio of relative changes — the elasticity. No multiplication by 100 needed because the differential of the log already gives you the percentage change directly.

OLS Assumptions in the Log-Log Model

Since the log-log model is OLS on transformed data, the same four assumptions apply (see the OLS Regression page for details): homoskedasticity, no autocorrelation, normality of residuals, and no multicollinearity. These now apply to the log-scale residuals $\hat{u}_i = \ln(Y_i) - \widehat{\ln(Y_i)}$.

An important implication: the log transformation often fixes heteroskedasticity that exists in the raw data. If the raw residuals fan out (bigger values have larger errors), the log-scale residuals are often much more uniform — because taking logs compresses large values relative to small ones.

Practical tip: If your raw OLS residuals show a funnel shape (heteroskedasticity), try the log-log model. It often produces much better-behaved residuals.
Worked Example — Company Size and IT Budget

An analyst studies how company size (number of employees) relates to annual IT budget (in thousands of euros). The data spans 8 companies of very different sizes, making a log-log model natural.

Employees: 10, 25, 50, 100, 250, 500, 1000, 2500
IT Budget: 20, 45, 85, 160, 380, 750, 1450, 3500

Step 1 — Log-Transform Both Variables

Compute $\ln(\text{Employees})$ and $\ln(\text{IT Budget})$ for each company:

ln(Employees): 2.30, 3.22, 3.91, 4.61, 5.52, 6.21, 6.91, 7.82
ln(IT Budget): 3.00, 3.81, 4.44, 5.08, 5.94, 6.62, 7.28, 8.16

Step 2 — Run OLS on the Transformed Data

Applying the OLS formulas to the log-transformed variables:

$$\widehat{\ln(\text{IT Budget})} = 0.789 + 0.938 \cdot \ln(\text{Employees})$$

R² in log space = 0.9998 — an almost perfect fit, confirming the power-law relationship.

Step 3 — Interpret the Elasticity

$$\hat{\beta}_1 = 0.938$$

Interpretation: A 1% increase in the number of employees is associated with a 0.938% increase in IT budget. Since this elasticity is close to 1 (but slightly below), IT spending grows nearly proportionally with company size — but slightly slower.

Step 4 — Predict for 200 Employees

Step 4a — compute the predicted log value:

$$\widehat{\ln(\text{IT})} = 0.789 + 0.938 \times \ln(200) = 0.789 + 0.938 \times 5.298 = 5.760$$

Step 4b — back-transform to original units:

$$\widehat{\text{IT Budget}} = e^{5.760} \approx 317.5 \;\text{k€}$$

Step 5 — Predict a Percentage Change

If a company grows by 20% (in headcount), how much should its IT budget increase?

$$\%\Delta \text{IT} \approx 0.938 \times 20\% = 18.76\%$$

So roughly a 19% increase in IT budget — useful for budgeting decisions without needing to know the exact starting size.

Step 6 — Compare to Raw OLS

If we ran standard OLS on the raw (non-log) data, the residuals would fan out badly (larger companies have far more variable IT budgets in absolute terms). The log-log model's residuals are much more uniform — homoskedasticity is better satisfied. This is the practical reason to prefer the log-log model here.