0
$\begingroup$

I have to get a regression model for a dataset, and it seems that the best fit is obtained by log transforming the outcome, so that I simply applied the least squares on the trasformed response vector.

$ \hat{log}({Y}) = \hat{f}(\bf{X}) = \hat\beta_0 + \bf{\hat\beta}^TX$

A prediction with this model estimates $E[log(Y)|X]$, which is NOT the same as a generalized linear model (log-linear), that estimates $log(E[Y|X])$.

In the latter case, if I wanted to get the vector of the estimated outcomes, I would simply compute $\hat{Y} = exp(\hat{f}(X)) = exp(log(E[Y|X])$.

Is there a way to retrieve $\hat{Y}$ in my case?

SOLVED: The difference between the two cases is that in the latter you get $E(Y|X)$ simply by exponentiating the mean of the normal distribution, while in the former you need to consider the mean of the associated lognormal. Multipling $exp(\hat{f}(X))$ by $exp(\frac12\hat{\sigma}^2) = exp(\frac12MSE) $ corrects the bias.

$\endgroup$
3
$\begingroup$

If your residuals look reasonable after the log transformation (i.e. they are approx. zero-mean normal), the least-squares estimate is the same as the maximum-likelihood estimate.

In other words, your probability model is:

\begin{equation} \log(Y_i) \sim \mathcal{N}(\beta_0 + \beta^\top X_i,\sigma^2). \end{equation}

This means that your $Y_i$ are log-normally distributed, and the mean of a log-normal distribution is $\exp\left(\mu + \frac{\sigma^2}{2}\right)$, where $\mu,\sigma$ are the mean and SD of the underlying normal distribution.

Then we can just plug in our estimates for the mean and SD of the normal distribution, $$\widehat\mu_i = \widehat{\beta_0} + \widehat{\beta}^\top X_i$$ and $$\widehat{\sigma^2} = \frac{\sum_{i = 1}^{n}(y_i - \widehat{\mu}_i)^2}{n - p - 1}$$

to get the expected value of $Y_i$, i.e. $\mathbb{E}(Y_i|X_i)$.

$\endgroup$

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