RE: st: prediction after y-logged regression

You could try it and see. Or look at the code to see what it does.
In fact, this won't work. -predlog- is self-contained and carries out a
regression and then does the necessary extra calculations. Only by
rewriting the program could you extend it to other methods.
I found this in my files. Without absolutely no promises about its
scope, it may nevertheless show by example that you don't much need an
extra program, as only a few lines are required after something like a
regression.
*! NJC 1.1.0 8 January 2005
* NJC 1.0.0 13 September 2002
program smear, rclass
version 8.0
syntax [if] [in] [, Generate(str) OUTofsample ]
if "`generate'" != "" {
capture confirm new variable `generate'
if _rc {
di as err "option syntax is generate(newvar)"
exit _rc
}
}
marksample touse
qui count if `touse'
if r(N) == 0 error 2000
tempvar resid yhatraw
tempname rmse cf
qui {
* will exit with error message if no estimates
scalar `rmse' = e(rmse)
if "`outofsample'" != "" predict double `yhatraw'
else predict double `yhatraw' if e(sample)
predict double `resid', res
replace `resid' = exp(`resid')
su `resid', meanonly
scalar `cf' = `r(mean)'
if "`generate'" != "" {
gen double `generate' = exp(`yhatraw') * `cf' if
`touse'
la var `generate' "smeared retransformation"
}
}
di as res scalar(`cf')
return scalar smearcf = `cf'
end
Shehzad Ali
Thanks, Richard. I understand that - predlog - is useful for OLS
regression.
What if you are using models like treatreg or heckman or other two-part
models? Would - predlog - still work?
Richard Goldstein
type -findit predlog-
Shehzad Ali wrote:
> I am running a regression in which y variable is logged
> (semi-logarithmic). The literature suggests that in order to get an
> anti-logged prediction of yhat, one should proceed like this:
>
> 1. Run the regression and predict yhat,
>
> 2. Then exponentiate the predicted yhat, and finally
>
> 3. Mutiply the exponentiated predicted yhat by the mean value of
> residuals from the regression (otherwise known as smearing).
>
> I was wondering if there is a direct way to do it in stata or if there
> is any other method that experts would suggest to get anti-logged
> prediction.
*
* 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/