# multiplying an outcome and predictor values by ten flips the sign of an effect size when log transformed. WHY?

I have a model, y~ x1 + x2 + x1*x2, where y and x1 are strongly correlated and x2 modifies the correlation between y and x1. y and x1 span ~2-3 orders of magnitude and errors are heteroscedastic, so I log transform both y and x1. The model is now specified as

log(y) ~ log(x1) + x2 + log(x1)*x2


Now the assumptions of OLS are satisfied, and I detect a significant interaction between log(x1) and x2, and the parameter value is positive. HOWEVER. If I multiply both y and x1 by a factor of ten (merely doing a unit conversion), the interaction between log(x1) and x2 stays significant, but the parameter value is now negative. Scaling through to the effect size its clear that while x2 had a positive effect on both log(y) and y before the unit conversion, it now has a negative effect.

Is this something super obvious that I am missing? Because its driving me crazy.

• Multiplying $x_1$ by $10$ does not rescale $\log(x_1)$: it adds $\log(10)$ to $\log(x_1)$. – whuber Aug 19 '15 at 19:14
• @whuber to clarify: I multiplied x1 by 10, and then performed the log transform. I did not multiply log(x1) by 10. – colin Aug 19 '15 at 19:17
• Precisely--and therein lies the source of your problem. – whuber Aug 19 '15 at 21:26
• @whuber so I'm still confused. If I run a model without log transforming, it doesn't matter if I run it with the dependent variable being in units grams, kilograms, or milligrams. The answer is always the same, the parameter magnitude is just shifted. However, when I run log transformed models, the parameter value size and sign are dependent on the unit my dependent variable is expressed in (kg, g, or mg). Back transforming the final model to generate effect size leads to qualitatively different results depending on unit size. This seems wrong, as the underlying data are exactly the same. – colin Aug 21 '15 at 13:01

## 1 Answer

Let's compare the models before and after changing the units of measurement.

The first model is

$$\mathbb{E}(Y) = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \beta_3 (x_1x_2).$$

Changing how $x_1$, $x_2$, and $Y$ are measured (but without changing their origins--that is, the meaning of any zero value) divides them by known constant factors $\lambda_1$, $\lambda_2$, and $\lambda$, respectively, giving

$$\lambda_1 x^\prime_1 = x_1,\ \lambda_2 x^\prime_2 = x_2,\ \lambda Y^\prime = Y.\tag{1}$$

Substituting these into the original model gives

$$\mathbb{E}(\lambda Y^\prime) = \beta_0 + \beta_1 (\lambda_1 x_1^\prime) + \beta_2 (\lambda_2 x_2^\prime) + \beta_3 (\lambda_1 x_1^\prime \lambda_2 x_2^\prime).$$

Elementary algebra lets us rewrite this in terms of the new variables as

\eqalign{ \mathbb{E}(Y^\prime) &= \frac{\beta_0}{\lambda} + \frac{\beta_1 \lambda_1}{\lambda} x_1^\prime + \frac{\beta_2 \lambda_2}{\lambda} x_2^\prime + \frac{\beta_3 \lambda_1 \lambda_2}{\lambda} (x_1^\prime x_2^\prime) \\ &= \beta_0^\prime + \beta_1^\prime x_1^\prime + \beta_2^\prime x_2^\prime + \beta_3^\prime (x_1^\prime x_2^\prime). }

The relationships all multiply the coefficients by constants that are known, because they depend only on the lambdas. It should be clear that the same relationships must hold among the coefficient estimates (at least when fitting with least squares). "The parameter magnitude is just shifted."

The second model is

$$\mathbb{E}(\log Y) = \beta_0 + \beta_1 \log x_1 + \beta_2 x_2 + \beta_3 ( x_2 \log x_1).\tag{2}$$

Because for any positive numbers $a$ and $b$ the relationship $\log(ab) = \log(a) + \log(b)$ holds, the changes of units in the original variables $(1)$ become

$$\log \lambda_1 + \log x^\prime_1 = \log x_1,\ \log \lambda + \log Y^\prime = \log Y.\tag{3}$$

Taking the same course as before, substitute these into the model $(2)$, obtaining

$$\mathbb{E}(\log\lambda + \log Y^\prime) = \beta_0 + \beta_1 (\log \lambda_1 + \log x^\prime_1) + \beta_2 (\lambda_2 x^\prime_2 ) + \beta_3 (\lambda_2 x^\prime_2 ) (\log\lambda_1 + \log x_1^\prime).$$

Once again, straightforward algebra will exhibit this as a model for the expectation of $\log Y^\prime$:

\eqalign{ &\mathbb{E}(\log Y^\prime)\\ &= (\beta_0 - \log\lambda + \beta_1 \log \lambda_1) + \beta_1 \log x_1^\prime + (\beta_2 \lambda_2 + \beta_3 \lambda_2 \log\lambda_1) x^\prime_2 + (\beta_3\lambda_2) ( x^\prime_2 \log x_1^\prime)\\ &= \gamma_0 +\gamma_1 \log x_1^\prime + \gamma_2 x_2^\prime + \gamma_3 x_2^\prime \log x_1^\prime. }

Because of the additive shifts $(3)$ in $\log(Y)$ and $\log(x_1)$, there is a mixing up of several of the coefficients. No longer is it the case that the coefficients are simply multiplied by (predictable) constants. Although the coefficients of $\log x_1$ and $\log x_1^\prime$ will be the same, and the coefficients of $x_2 \log x_1$ and $x_2^\prime \log x_1^\prime$ will just be rescaled, the other two coefficients could even change sign (because in general $\log\lambda$ and $\lambda_2 \log\lambda_1$ could be any numbers at all, positive or negative).