8
$\begingroup$

As per gung's advice in Getting the equation from R's lm when using a product, I am starting a new thread for this question.

I have a model $\widehat{\log z} = a + bx + cy + dxy$ for random variables $x,y,z$ and coefficients $a,b,c,d$.

I now want a model for $z$ instead of $\log z$. I was going to simply do $\hat{z} = \exp(a + bx + cy + dxy)$ but I have been cautioned against this. Why is this incorrect, and what is the correct way to proceed (if there is one)?

$\endgroup$
3
  • 4
    $\begingroup$ Alternatively, you could use a GLM with a log-link and gaussian errors. Relevant posts include this and this one and this. $\endgroup$ Commented Jul 10, 2014 at 21:13
  • 5
    $\begingroup$ I answered this question in the first half of my answer here: stats.stackexchange.com/questions/55692/… $\endgroup$
    – Bill
    Commented Jul 10, 2014 at 21:39
  • 1
    $\begingroup$ @Bill, the crucial equation in your answer, $\hat{Y}_i = \exp(\widehat{\ln{Y}}_i) \cdot \frac{1}{N}\sum \exp(e_i)$, is confusing because of the double appearance of "$i$" and the ambiguous summation shorthand (in which no index is explicitly named). Could you edit that answer to clarify this? $\endgroup$
    – whuber
    Commented Jul 10, 2014 at 22:20

1 Answer 1

6
$\begingroup$

I don't necessarily have a problem with you exponentiating your predicted values. You just need to realize that if the former was an expectation, the result is no longer an expectiation. Specifically, a regression model is intended to give the expected value of $Y$ at each point in $X$ ($E(Y|X=x_i)$). An expected value is the weighted average of all possible $Y$ values, where the weights are the likelihoods. In simpler terms, it is the conditional mean. Because the logarithm / exponentiation of a variable is a non-linear transformation, if you input a mean you don't get a mean as your output.

Often, people use the log transform to normalize the residual distribution and/or stabilize the variance. That is perfectly fine. But if the resulting distribution is normal(ish) with (sufficiently) constant variance, the original distribution necessarily wasn't. When you back transform, you get the conditional median instead of the conditional mean. If you understand that (and what it implies), and you want that, you will be fine.

Consider:

x   = c(2, 3, 1, 9, 3, 5, 9, 3)
lx  = log(x)
mlx = mean(lx)
mlx
# [1] 1.249109
exp(mlx)
# [1] 3.487234
mean(x)
# [1] 4.375
$\endgroup$
1
  • $\begingroup$ If you really do need the mean after back transformation, there are methods for this. See a post on Rob Hyndman's blog $\endgroup$ Commented Jul 17, 2014 at 22:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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