85
$\begingroup$

Can somebody explain how the properties of logs make it so you can do log linear regressions where the coefficients are interpreted as percentage changes?

$\endgroup$
2
  • 15
    $\begingroup$ $log(y_t) -log(y_{t-1})=log(y_t/y_{t-1})$, and $y_t/y_{t-1}$ is 1 plus the percentage change. $\endgroup$
    – user83346
    Nov 4, 2016 at 15:22
  • $\begingroup$ Differentiating the equation relative to X1 I think puts us on track in answering the question better than does considering series expressions. $\endgroup$
    – Charles
    Mar 1, 2018 at 20:35

6 Answers 6

91
$\begingroup$

For $x_2$ and $x_1$ close to each other, the percent change $\frac{x_2-x_1}{x_1}$ approximates the log difference $\log x_2 - \log x_1$.

Why does the percent change approximate the log difference?

An idea from calculus is that you can approximate a smooth function with a line. The linear approximation is simply the first two terms of a Taylor Series. The first order Taylor Expansion of $\log(x)$ around $x=1$ is given by:

$$ \log(x) \approx \log(1) + \frac{d}{dx} \left. \log (x) \right|_{x=1} \left( x - 1 \right)$$ The right hand side simplifies to $0 + \frac{1}{1}\left( x - 1\right)$ hence: $$ \log(x) \approx x-1$$

So for $x$ in the neighborhood of 1, we can approximate $\log(x)$ with the line $y = x - 1$ Below is a graph of $y = \log(x)$ and $y = x - 1$.

Example: $\log(1.02) = .0198 \approx 1.02 - 1$.

Now consider two variables $x_2$ and $x_1$ such that $\frac{x_2}{x_1} \approx 1$. Then the log difference is approximately the percent change $\frac{x_2}{x_1} - 1 = \frac{x_2 - x_1}{x_1}$:

$$ \log x_2 - \log x_1 = \log\left( \frac{x_2}{x_1} \right) \approx \frac{x_2}{x_1} - 1 $$

The percent change is a linear approximation of the log difference!

Why log differences?

Often times when you're thinking in terms of compounding percent changes, the mathematically cleaner concept is to think in terms of log differences. When you're repeatedly multiplying terms together, it's often more convenient to work in logs and instead add terms together.

Let's say our wealth at time $T$ is given by: $$ W_T = \prod_{t=1}^T (1 + R_t)$$ Then it might be more convenient to write: $$ \log W_T = \sum_{t=1}^T r_t $$ where $r_t = \log (1 + R_t) = \log W_t - \log W_{t-1}$.

Where are percent changes and the log difference NOT the same?

For big percent changes, the log difference is not the same thing as the percent change because approximating the curve $y = \log(x)$ with the line $y = x - 1$ gets worse and worse the further you get from $x=1$. For example:

$$ \log\left(1.6 \right) - \log(1) = .47 \neq 1.6 - 1$$

What's the log difference in this case?

One way to think about it is that a difference in logs of .47 is equivalent to an accumulation of 47 different .01 log differences, which is approximately 47 1% changes all compounded together.

\begin{align*} \log(1.6) - \log(1) &= 47 \left( .01 \right) \\ & \approx 47 \left( \log(1.01) \right) \end{align*}

Then exponentiate both sides to get: $$ 1.6 \approx 1.01 ^{47}$$

A log difference of .47 is approximately equivalent to 47 different 1% increases compounded, or even better, 470 different .1% increases all compounded etc...

Several of the answers here make this idea more explicit.

$\endgroup$
3
  • 1
    $\begingroup$ +1, in the hopes the planned continuation of this answer will discuss conditions where the approximation breaks down. $\endgroup$
    – whuber
    Nov 4, 2016 at 17:43
  • 7
    $\begingroup$ +1. To add a minor point, 1.6 to 1 is a 37.5% decrease, 1 to 1.6 is a 60% increase, the log difference 0.47 is independent of the direction of change, and always in between of 0.375 and 0.6. When we don't know or don't care about the direction of change, log difference could be an alternative of taking averages of the two percent changes, even when the percent change is large. $\endgroup$
    – Paul
    Nov 4, 2016 at 18:35
  • $\begingroup$ In percentage change, what if $x_1$ is 0 ? $\endgroup$ Mar 3, 2020 at 0:26
18
$\begingroup$

Here's a version for dummies...

We have the model $Y= \beta_o+\beta_1X+\varepsilon$ - a simple straight line through the data cloud - and we know that once we estimate the coefficients, a $1\text{-unit}$ increase in the prior value of $X=x_1$ will result in a increase of $\hat \beta_1$ in the value of $Y$, from $Y=y_1$, as $\hat\beta_1(x_1+1) -\hat\beta_1x_1= \hat\beta_1$. But the units can actually be meaningless in absolute values.

So we can, instead change the model to $\ln(Y)= \delta_o+\delta_1X+\varepsilon$ (brand new coefficients). Now for the same unit increase in $\hat\delta_1$, we have a change

$$\ln(y_2)-\ln(y_1)=\ln\left(\frac{y_2}{y_1}\right)=\hat\delta_1(x_1+1) -\hat\delta_1x_1= \hat\delta_1 \tag{*}$$

To see the implications for the change in percentage, we can exponentiate $(*)$:

$$\exp(\hat\delta_1)=\frac{y_2}{y_1}=\frac{\color{blue}{y_1}+y_2\color{blue}{-y_1}}{y_1}= 1+\frac{y_2-y_1}{y_1}\tag{**}$$

$\frac{y_2-y_1}{y_1}$ is the relative change, and from $(**)$, $\small 100\,\frac{y_2-y_1}{y_1}=100(\exp(\hat\delta_1)-1)$ the percentage change.

The key to answer the question is to see that $\exp(\hat\delta_1)-1\approx \hat\delta_1$ for small values of $\hat\delta_1$, which amounts to the same use of the first two terms of the Taylor expansion that Matthew used, but this time of $e^x$ (Maclaurin series) evaluated at zero because we are working with exponents, as opposed to logarithms:

$$e^x=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots$$

or with $\delta_1$ as the $x$ variable:

$$\exp(\hat\delta_1)=1+\hat\delta_1$$

so $\hat\delta_1=\exp(\hat\delta_1)-1$ around zero (we evaluated the polynomial expansion at zero when we did the Taylor series). Visually,

enter image description here

$\endgroup$
2
  • $\begingroup$ your answer is quite clear: we need small coefficients to be able to interpret the log-difference as percentage change, but @aksakal 's answer shows that we only need small changes (i.e. lim Δx --> 0). Can you please explain how the two are equivalent? $\endgroup$ Oct 20, 2019 at 0:23
  • $\begingroup$ Is it important to include the error terms and expecation when examining the model coefficients? $\endgroup$ Dec 9, 2021 at 3:41
10
$\begingroup$

Say you have a model $$\ln y = A+B x$$ Take a derivative of a log: $$\frac{d}{dx}\ln y\equiv\frac{1}{y}\frac{dy}{dx}=B$$

Now you can see that the slope $b$ is now a slope of the relative change of $y$: $$\frac{dy}{y}=B dx$$

If you didn't have the log transform then you'd get a slope of absolute change of $y$: $$dy=B dx$$

I didn't replace $dx,dy$ with $\Delta x,\Delta y$ to emphasize that this works for small changes.

$\endgroup$
4
$\begingroup$

There are many great explanations in the present answers, but here is another one framed in terms of financial analysis of the accrual of interest on an initial investment. Suppose you have an initial amount of one unit that accrues interest at (nominal) rate $r$ per annum, with interest "compounded" over $n$ periods in the year. At the end of one year, the value of that initial investment of one unit is:

$$I(n) = \Big( 1+\frac{r}{n} \Big)^n.$$

The more often this interest is "compounded" the more money you get on your initial investment (since compounding means you are getting interest on your interest). Taking the limit as $n \rightarrow \infty$ we get "continuously compounding interest", which gives:

$$I(\infty) = \lim_{n \rightarrow \infty} \Big( 1+\frac{r}{n} \Big)^n = \exp(r).$$

Taking logarithms of both sides gives $r = \ln I(\infty)$, which means that the logarithm of the ratio of the final investment to the initial investment is the continuously compounding interest rate. From this result, we see that logarithmic differences in time-series outcomes can be interpreted as continuously compounding rates of change. (This interpretation is also justified by the answer by aksakal, but the present working gives you another way to look at it.)


$\endgroup$
1
$\begingroup$

These posts all focus on the difference between two values as a proportion of the the first: $\frac{y-x}{x}$ or $\frac{y}{x} - 1$. They explain why $$\frac{y}{x} - 1 \approx \ln(\frac{y}{x}) = \ln(y) - \ln(x).$$ You might be interested in the difference as a proportion of the average rather than as a proportion of the first value, $\frac{y-x}{\frac{y+x}{2}}$ rather than $\frac{y-x}{x}$. The difference as a proportion of the average is relevant when comparing methods of measurement, e.g. when doing a Bland-Altman plot with differences proportional to the mean. In this case, approximating the proportionate difference with the difference in the logarithms is even better:

$$\frac{y-x}{\frac{y+x}{2}} \approx \ln(\frac{y}{x}) .$$

Here is why:

Let $z = \frac{y}{x}$. $$\frac{y-x}{\frac{y+x}{2}} = \frac{2(z-1)}{z+1}$$ Compare the Taylor series about $z =1$ for $\frac{2(z-1)}{z+1}$ and $\ln(z)$. $$\frac{2(z-1)}{z+1} = (z-1) - \frac{1}{2}(z-1)^2 + \frac{1}{4}(z-1)^3 + ... + (-1)^{k+1}\frac{1}{2^{k-1}}(z-1)^k + ....$$ $$\ln(z) = (z-1) - \frac{1}{2}(z-1)^2 + \frac{1}{3}(z-1)^3 + ... + (-1)^{k+1}\frac{1}{k}(z-1)^k + ....$$ The series are the same out to the $(z-1)^2$ term. The approximation works quite well from $z=0.5$ to $z=2$ , i.e., when one of the values is up to twice as large as the other, as shown by this figure. Compare ln(z) to 2(z-1)/(z+1) A value of $z=0.5$ or $z=2$ corresponds to a difference that is 2/3 of the average. $$\frac{y-x}{\frac{y+x}{2}} = \frac{2x-x}{\frac{2x+x}{2}} = \frac{x}{\frac{3x}{2}} = \frac{2}{3}$$

$\endgroup$
0
$\begingroup$

This answer does not assume a linear regression framework, nor does it rely on any approximations.

First, let's define some terms: $$ Old=the\ original\ value\ (or\ variable) $$ $$ New=the\ new\ value\ (or\ variable) $$ $$ PC = Proportion\ Change $$ PC also equals PercentChange/100, and has the domain of [-1,inf]. I find it easier to work with proportions rather than percentages. Also, the New and Old data are not transformed.

Now, let's calculate PC: $$ New=Old*(1+PC) $$ $$ \frac{New}{Old}=1+PC $$ $$ PC=\frac{New}{Old}-1 $$

Now, let's define and calculate the difference of the log-transformed data: $$ \Delta=logNew-logOld $$ $$ \Delta=log\left(\frac{New}{Old}\right) $$ $$ \Delta=log(1+PC) $$

Now, let's rearrange and solve for PC:

$$ e^\Delta=1+PC $$ $$ PC=e^\Delta-1 $$ $$ PC=e^\left(log\left(\frac{New}{Old}\right)\right)-1 $$

This answer outlines a similar derivation.

$\endgroup$
1
  • $\begingroup$ This doesn't seem to answer the question. Indeed, the claim in the question isn't fully correct: it's only an approximation. Please read some of the (excellent) answers already posted in this thread. $\endgroup$
    – whuber
    Apr 12, 2022 at 22:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.