Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)?

share|improve this question
Alternatively, you could use a GLM with a log-link and gaussian errors. Relevant posts include this and this one and this. – COOLSerdash Jul 10 '14 at 21:13
I answered this question in the first half of my answer here:… – Bill Jul 10 '14 at 21:39
@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? – whuber Jul 10 '14 at 22:20
@whuber Thanks, made the correction – Bill Jul 10 '14 at 23:18
up vote 5 down vote accepted

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.


x   = c(2, 3, 1, 9, 3, 5, 9, 3)
lx  = log(x)
mlx = mean(lx)
# [1] 1.249109
# [1] 3.487234
# [1] 4.375
share|improve this answer
If you really do need the mean after back transformation, there are methods for this. See a post on Rob Hyndman's blog – Tony Ladson Jul 17 '14 at 22:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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