I want to predict $y$, but I can only predict $\log_{10} y$. So in R I do

fit <- lm(log10(y) ~ x)

Now I want to know how well I've done with respect to my original variable. So naively I plot

y_hat <- 10**fitted(fit)
plot(y-y_hat ~ y)

but I recall that logging and then anti-logging (exponentiating) the variable isn't quite so straightforward, that I have to apply some correction to y_hat. How do I do it?

  • $\begingroup$ Did you mean y_hat <- 10**fitted(fit)? Or do you really intend to look at residuals this way? $\endgroup$
    – EdM
    Sep 30, 2015 at 14:34
  • $\begingroup$ You're right, fixed $\endgroup$ Sep 30, 2015 at 14:39
  • 1
    $\begingroup$ If the residuals with respect to y are what matter to you, then you should not be using least squares to fit log10(y). You might prefer something like the Duan smearing estimator. $\endgroup$
    – whuber
    Sep 30, 2015 at 15:28

1 Answer 1


Doing a regression with $log_{10}(y)$ as the outcome variable suggests that you (at least implicitly) expected your residual errors to be more or less proportional to the values of $y$. Under that assumption about the error distribution, that's the scale in which any statistical tests you wish to perform will be most correctly interpreted.

For checking the quality of your fit, you should do your follow-up work in that scale, calling plot(fit) to examine the relation of residuals agenst fitted values, etc. If you want to compare predicted and fitted, try it first in that log scale. There's nothing wrong with working directly in a log scale; for example, chemists who use pH values are working directly in a scale related to log hydrogen-ion activity.

If out of curiosity you want to compare fitted and measured values in the original scale, the problem you probably have in mind is related to the difference between geometric means and arithmetic means. When you take the logs of several values, add them, and take the anti-log, you get their geometric mean. This is different from the mean value you would have calculated directly in the original scale.

Taking 10**fitted(fit) returns the equivalent of the predicted geometric mean of $y$ as a function of $x$. As a result your usual visual intuition about quality of fits will be wrong, as that intuition is working in the arithmetic scale after back-transformation. You will probably have some observed values that look extremely high compared to fitted values, with no obviously offsetting similarly extreme low values. That would seem wrong for a standard linear regression, but is to be expected when the fit was done on a log scale of the outcome variable.

So if the desired analysis was done on $log_{10}(y)$ (versus something like the Duan smearing estimator linked in a comment by @whuber), it isn't so much that you need to correct your estimates of y_hat to plot in the original scale. You need to correct your visual intuition. That's hard, so I try to stay in the log scale for plots after transformation.


Your Answer

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

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