Page 1 of 1

Forecast from a NLLS regression

Posted: Sat Dec 28, 2019 8:24 pm
by timduy
I run this code:

Code: Select all

nonlin b0 b1
frml etrend = b0*exp(b1*trend)
nlls(frml=etrend) ces7072200001 startdate enddate resids3
and I would like to forecast ces7072200001. How do I convert the results of NLLS to an equation that I can use with FORECAST?

I know I can redefine the regression as:

Code: Select all

linreg log(ces7072200001) startdate enddate resids3
#constant trend
and then convert back to the level, but I am trying to illustrate the forecast bias created by that conversion as in:

https://davegiles.blogspot.com/2013/08/ ... sions.html

Re: Forecast from a NLLS regression

Posted: Sun Dec 29, 2019 11:17 pm
by TomDoan
Actually, the NLLS FRML would (theoretically) give the correct minimum mean square forecasts for the level IF (and that's a big if) the errors were assumed to be homoscedastic in that model. The bias discussed in the blog comes about because if you assume instead that the residuals are homoscedastic in

(*) log(y) = a+bx+u

then forecasting y by exp(a+bx) does not give the minimum mean square error forecasts for y as a positive u will have a larger effect on y then an equally negative u. The bias correction can be done by scaling up by exp(%seesq/2):

set logy = log(ces7072200001)
linreg(frml=logfrml) y startdate enddate resids3
#constant trend
set yhat = exp(logfrml)*exp(%seesq/2)

Note, by the way, that if (*) with homoscedastic u is the correct model, you would expect that if you estimate it in the exponential form y=exp(a+bx), the a in that would be roughly a in the log-linear regression + log(%seesq/2)---it should give a consistent, but not efficient estimate of the same function.

Re: Forecast from a NLLS regression

Posted: Mon Dec 30, 2019 10:13 am
by timduy
Yes, that is easier way to illustrate. Thank you.