Docsity

Logarithmic Transformations in Linear Regression Models - Prof. Rufat, Apuntes de Literatura

Toggle sidebar
bg1
Linear Regression Models with Logarithmic Transformations
Kenneth Benoit∗
Methodology Institute
London School of Economics
March 17, 2011
1 Logarithmic transformations of variables
Considering the simple bivariate linear model Yi=α+βXi+εi,1there are four possible com-
binations of transformations involving logarithms: the linear case with no transformations, the
linear-log model, the log-linear model2, and the log-log model.
X
Y X logX
Y linear linear-log
ˆ
Yi=α+βXiˆ
Yi=α+βlogXi
logY log-linear log-log
log ˆ
Yi=α+βXilog ˆ
Yi=α+βlogXi
Table 1: Four varieties of logarithmic transformations
Remember that we are using natural logarithms, where the base is e≈2.71828. Logarithms may
have other bases, for instance the decimal logarithm of base 10. (The base 10 logarithm is used in
the definition of the Richter scale, for instance, measuring the intensity of earthquakes as Richter
=log(intensity). This is why an earthquake of magnitude 9 is 100 times more powerful than an
earthquake of magnitude 7: because 109/107=102and log10 (102) = 2.)
Some properties of logarithms and exponential functions that you may find useful include:
1. log(e) = 1
2. log(1) = 0
3. log(xr) = rlog(x)
4. logeA=A
∗With valuable input and edits from Jouni Kuha.
1The bivariate case is used here for simplicity only, as the results generalize directly to models involving more than
one Xvariable, although we would need to add the caveat that all other variables are held constant.
2Note that the term “log-linear model” is also used in other contexts, to refer to some types of models for other kinds
of response variables Y. These are different from the log-linear models discussed here.
1
pf3
pf4
pf5
pf8

Vista previa parcial del texto

¡Descarga Logarithmic Transformations in Linear Regression Models - Prof. Rufat y más Apuntes en PDF de Literatura solo en Docsity!

Linear Regression Models with Logarithmic Transformations

Kenneth Benoit∗

Methodology Institute

London School of Economics

[email protected]

March 17, 2011

1 Logarithmic transformations of variables

Considering the simple bivariate linear model Yi = α + β Xi + εi ,^1 there are four possible com- binations of transformations involving logarithms: the linear case with no transformations, the linear-log model, the log-linear model^2 , and the log-log model.

X Y X log X Y linear linear-log Y^ ˆ i = α + β Xi Y ˆ i = α + β log Xi log Y log-linear log-log log Y ˆ i = α + β Xi log Y ˆ i = α + β log Xi

Table 1: Four varieties of logarithmic transformations

Remember that we are using natural logarithms, where the base is e ≈ 2.71828. Logarithms may have other bases, for instance the decimal logarithm of base 10. (The base 10 logarithm is used in the definition of the Richter scale, for instance, measuring the intensity of earthquakes as Richter = log(intensity). This is why an earthquake of magnitude 9 is 100 times more powerful than an earthquake of magnitude 7: because 10^9 / 107 = 102 and log 10 ( 102 ) = 2.)

Some properties of logarithms and exponential functions that you may find useful include:

  1. log( e ) = 1
  2. log(1) = 0
  3. log( x r^ ) = r log( x )
  4. log eA^ = A ∗With valuable input and edits from Jouni Kuha. (^1) The bivariate case is used here for simplicity only, as the results generalize directly to models involving more than one X variable, although we would need to add the caveat that all other variables are held constant. (^2) Note that the term “log-linear model” is also used in other contexts, to refer to some types of models for other kinds of response variables Y. These are different from the log-linear models discussed here.
  1. e log A^ = A
  2. log( AB ) = log A + log B
  3. log( A/B ) = log A − log B
  4. eAB^ =

Ä

eA

ä B

  1. eA + B^ = eAeB
  2. eA − B^ = eA/eB

2 Why use logarithmic transformations of variables

Logarithmically transforming variables in a regression model is a very common way to handle sit- uations where a non-linear relationship exists between the independent and dependent variables.^3 Using the logarithm of one or more variables instead of the un-logged form makes the effective relationship non-linear, while still preserving the linear model.

Logarithmic transformations are also a convenient means of transforming a highly skewed variable into one that is more approximately normal. (In fact, there is a distribution called the log-normal distribution defined as a distribution whose logarithm is normally distributed – but whose untrans- formed scale is skewed.)

For instance, if we plot the histogram of expenses (from the MI452 course pack example), we see a significant right skew in this data, meaning the mass of cases are bunched at lower values:

0 500 1000 1500 2000 2500 3000

0

200

400

600

Expenses

If we plot the histogram of the logarithm of expenses, however, we see a distribution that looks much more like a normal distribution: (^3) The other transformation we have learned is the quadratic form involving adding the term X (^2) to the model. This produces curvature that unlike the logarithmic transformation that can reverse the direction of the relationship, some- thing that the logarithmic transformation cannot do. The logarithmic transformation is what as known as a monotone transformation: it preserves the ordering between x and f ( x ).

  • β ˆ is the expected change in Y when X is multiplied by e.
  • β ˆ is the expected change in Y when X increases by 172%
  • For other percentage changes in X we can use the following result: The expected change in Y associated with a p % increase in X can be calculated as β ˆ · log([ 100 + p ] / 100 ). So to work out the expected change associated with a 10% increase in X , therefore, multiply β ˆ by log( 110 / 100 ) = log(1.1) = .095. In other words, 0.095 β ˆ is the expected change in Y when X is multiplied by 1.1, i.e. increases by 10%.
  • For small p , approximately log([ 100 + p ] / 100 ) ≈ p/ 100. For p = 1, this means that β/ ˆ 100 can be interpreted approximately as the expected increase in Y from a 1% increase in X

3.3 Log-linear model: log Yi = α + β Xi + εi

In the log-linear model, the literal interpretation of the estimated coefficient β ˆ is that a one-unit increase in X will produce an expected increase in log Y of β ˆ units. In terms of Y itself, this means that the expected value of Y is multiplied by e β ˆ^. So in terms of effects of changes in X on Y (unlogged):

  • Each 1-unit increase in X multiplies the expected value of Y by e β ˆ^.
  • To compute the effects on Y of another change in X than an increase of one unit, call this change c , we need to include c in the exponent. The effect of a c -unit increase in X is to multiply the expected value of Y by ec^ β ˆ^. So the effect for a 5-unit increase in X would be e^5 β ˆ^.
  • For small values of β ˆ, approximately e β ˆ^ ≈ 1 + β ˆ. We can use this for the following approxima- tion for a quick interpretation of the coefficients: 100 · β ˆ is the expected percentage change in Y for a unit increase in X. For instance for β ˆ = .06, e .06^ ≈ 1.06, so a 1-unit change in X corresponds to (approximately) an expected increase in Y of 6%.

3.4 Log-log model: log Yi = α + β log Xi + εi

In instances where both the dependent variable and independent variable(s) are log-transformed variables, the interpretation is a combination of the linear-log and log-linear cases above. In other words, the interpretation is given as an expected percentage change in Y when X increases by some percentage. Such relationships, where both Y and X are log-transformed, are commonly referred to as elastic in econometrics, and the coefficient of log X is referred to as an elasticity.

So in terms of effects of changes in X on Y (both unlogged):

  • multiplying X by e will multiply expected value of Y by e β ˆ
  • To get the proportional change in Y associated with a p percent increase in X , calculate a = log([ 100 + p ] / 100 ) and take ea^ β ˆ

4 Examples

Linear-log. Consider the regression of % urban population (1995) on per capita GNP:

% urban 95 (World Bank)

(^77) United Nations per capita GDP 42416

8

100

% urban 95 (World Bank)

lPcGDP 4.34381 10.

8

100

me examples

Let's consider the relationship between the percentage

urban and per capita GNP:

This doesn't look too good. Let's try transforming the per

capita GNP by logging it:

The distribution of per capita GDP is badly skewed, creating a non-linear relationship between X and Y. To control the skew and counter problems in heteroskedasticity, we transform GNP/capita by taking its logarithm. This produces the following plot:

% urban 95 (World Bank)

(^77) United Nations per capita GDP 42416

8

100

% urban 95 (World Bank)

lPcGDP 4.34381 10.

8

100

me examples

Let's consider the relationship between the percentage

urban and per capita GNP:

This doesn't look too good. Let's try transforming the per

capita GNP by logging it:

and the regression with the following results:

(^8) % urban 95 (World Bank) 100

. regress lPcGDP95 urb Source | SS df MS Number of obs = 132 ---------+------------------------------ F( 1, 130) = 158. Model | 196.362646 1 196.362646 Prob > F = 0. Residual | 160.818406 130 1.23706466 R-squared = 0. ---------+------------------------------ Adj R-squared = 0. Total | 357.181052 131 2.72657291 Root MSE = 1.


lPcGDP95 | Coef. Std. Err. t P>|t| [95% Conf. Interval] ---------+-------------------------------------------------------------------- urb95 | .052709 .0041836 12.599 0.000 .0444322. _cons | 4.630287 .2420303 19.131 0.000 4.151459 5.


! Every one point increase in the percentage urban multiplies per capita income by e 0.052709 = 1.054. In other words, it increases per capita income by 5.4%.

To interpret the coefficient of .052709 on the urb95 variable, we can make the following state- ments:

Directly from the coefficient, transformed Y : Each one unit increase urb95 in increases lPcGDP by .052709. (Once again, this is not particularly useful as we still have trouble thinking in terms of the natural logarithm of GDP/capita.) Directly from the coefficient, un transformed Y : Each one unit increase of urb95 increases the untransformed GDP/capita by a multiple of e 0.52709^ = 1.054 – or a 5.4% increase. (This is very close to the 5.3% increase that we get using our quick approximate rule described above for interpreting the .053 as yielding a 5.3% increase for a one-unit change in X .)

Log-log. Here we consider a regression of the logarithm of the infant mortality rate on the log of GDP/capita. The plot and the regression results look like this:

lIMR

lPcGDP 3.58352 10.

gged independent and dependent variables

Let's look at infant mortality and per capita income:

regress lIMR lPcGDP

Source | SS df MS Number of obs = 1

-------+------------------------------ F( 1, 192) = 404.

Model | 131.035233 1 131.035233 Prob > F = 0.

sidual | 62.1945021 192 .323929698 R-squared = 0.

-------+------------------------------ Adj R-squared = 0.

Total | 193.229735 193 1.00119034 Root MSE =.

lIMR | Coef. Std. Err. t P>|t| [95% Conf. Interva

cGDP95 | -.4984531 .0247831 -20.113 0.000 -.5473352 -.

_cons | 7.088676 .1908519 37.142 0.000 6.71224 7.

lIMR

3.58352 (^) lPcGDP95 10.

Logged independent and dependent variables

! Let's look at infant mortality and per capita income:

. regress lIMR lPcGDP Source | SS df MS Number of obs = 194 ---------+------------------------------ F( 1, 192) = 404. Model | 131.035233 1 131.035233 Prob > F = 0. Residual | 62.1945021 192 .323929698 R-squared = 0. ---------+------------------------------ Adj R-squared = 0. Total | 193.229735 193 1.00119034 Root MSE =.


lIMR | Coef. Std. Err. t P>|t| [95% Conf. Interval] 

---------+-------------------------------------------------------------------- lPcGDP95 | -.4984531 .0247831 -20.113 0.000 -.5473352 -. _cons | 7.088676 .1908519 37.142 0.000 6.71224 7.


! Thus multiplying per capita income by 2.718 multiplies the infant mortality rate by e -0.4984531 = 0. ! A 10% increase in per capita income multiplies the infant mortality rate e -0.4984531*ln(1.1) = 0.954. ! In other words, a 10% increase in per capita income reduces the infant mortality rate by 4.6%.

To interpret the coefficient of -.4984531 on the lPcGDP95 variable, we can make the following statements:

Directly from the coefficient, transformed Y : Each one unit increase lPcGDP95 in increases lIMR by -.4984531. (Since we cannot think directly in natural log units, then once again, this is not particularly useful.)

Multiplicative changes in both X and Y : Multiplying X (GNP/cap) by e ≈ 2.72 multiplies Y by e −.4984531^ = 0.607, i.e. reduces the expected IMR by about 39.3%.

A 1% increase in X : A 1% increase in GNP/cap multiplies IMR by e −.4984531∗log(1.01)^ = .0.9950525. So a 1% increase in GNP/cap reduces IMR by 0.5%.

A 10% increase in X : A 10% increase in GNP/cap multiplies IMR by e −.4984531∗log(1.1)^ ≈ .954. So a 10% increase in GNP/cap reduces IMR by 4.6%.