# st: RE: transforming predictions from loglinear models

 From "Nick Cox" To Subject st: RE: transforming predictions from loglinear models Date Fri, 26 Aug 2005 12:14:58 +0100

```An excellent solution to this has been
available for 33 years, namely generalised
linear models with log link. So, switch to -glm-.

glm y ln_x1 ln_x2, link(log)

That way, you can also think about other error
families that might be better for your problem.

Alternatively, Duan's technique of smearing
often works well. Rich Goldstein published
a program some while back, and I have
a more modern variant somewhere.

W. Manning, who I think is a Stata user but
possibly not a member of Statalist, has
published lots in this territory, especially
I think in (health) economics.

Nick
n.j.cox@durham.ac.uk

Colin.Vance@dlr.de

> I want to estimate a simple log-linear OLS regression in
> Stata and then
> use the model to generate predictions. Say the model looks like this:
>
> regress ln_y ln_x1 ln_x2
>
> where all the variables are in logs. After running the model, I'd like
> to predict values of y over different values of x1, holding
> x2 fixed at
> the mean. The problem is that my predicted y is in log form, which I
> want to transform to y. One solution is to simply take
> exp(prediction of
> ln_y), but this has been shown to result in a biased predictor. The
> following article discusses various techniques for dealing with this,
> focusing specifically on a Laplace conversion:
>
> van Garderen, Kees Jan, 2001.
> "Optimal prediction in loglinear models," Journal of Econometrics,
> Elsevier, vol. 104(1), pages 119-140
>
> Does anyone know if any such techniques have been implemented
> in Stata?
> Would predictnl do the trick, as in:
>
> predictnl yhat = exp(_b[cons] + _b[ln_x1]*ln_x1 + _b[ln_x2]*ln_x2],
> se(yhat_se)
>

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```