If fitting a linear model to a untransformed and log-transformed y variable, can anyone explain why the coefficients are different from the log-transformed model even after exponentiating the coefficients?

Here's a simple R example


# Set seed

# Make data
x <- rnorm(100, 5, 1)
y <- x + rnorm(100, 5, 1)
data <- cbind.data.frame(y, x) 

# Fit on original scale
summary(lm(y ~ x))

# Fit on log scale
summary(lm(log(y) ~ x))

I was expecting the exponentiated coefficients from the second model to exactly align with the coefficients from the first model and this isn't the case.

  • 3
    $\begingroup$ Why? Your first model is of the form $\hat y=a+bx$ while your second is closer to $\hat y=c x^d$ if you exponentiate the coefficients. These are very different models $\endgroup$ – Henry 2 days ago
  • $\begingroup$ Shouldn't it be easy to transform the parameters between models? I'm confused about why I can't log transform a variable and then use an exponent to get results back on the original scale. $\endgroup$ – andy_d 2 days ago
  • 1
    $\begingroup$ Are you presuming that if $y = a + bx$ is fitted by your first lm() call, then $\ln y = \ln a + (\ln b) x$ is fitted by second call? Logarithms don't work like that. In addition, your first simulation makes negative or zero y$ unlikely but not impossible, which is not compatible with taking logarithms, and if errors are normal on the original scale, the second call applies an inappropriate estimation method. $\endgroup$ – Nick Cox 2 days ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.