Page 1 of 1
Forecasting using a LSTAR model
Posted: Wed Oct 21, 2009 4:18 pm
by sousoubo085
Hello,
I am wondering if it possible to use the forecast or step function in RATS to make one-step forecasts on a serie. The LSTAR model coefficients were estimated using this code :
com c3 = ip(155)
com gama = 1
frml g = (1+exp(-gama*(ip{1}-c3)))**-1
nonlin a0 a1 a2 b1 b2
com a0=0, a1=0, a2=0, b1=0, b2=0
frml set ip = a0+g*(a1*ip(t-1)+a2*IP(t-2))+(1-g)*(b1*ip(t-1)+b2*IP(t-2))
nlls(print,frml=set) ip nbeg nend80 r_lstar
Now, my intuition would be to use:
forecast (model=set, result=forecast_lstar) * 1 nend80+1
This, however does not work. Anyone has an idea?
I appreciate all insights! Thanks in advance
Re: Forecasting using a LSTAR model
Posted: Mon Oct 26, 2009 1:24 pm
by TomDoan
The first question is whether you even have to do anything other than
Your formula gives the one-step forecasts directly.
If you're trying to do dynamic forecasts, you need to define a model with
GROUP, even if that has just the one formula:
Code: Select all
group lstarmodel set
forecast(model=lstartmodel,...)
Don't include the "G" formula in the model. It's just a convenient way to do organize the calculation of the LSTAR model.
Re: Forecasting using a LSTAR model
Posted: Thu Sep 19, 2019 6:27 pm
by PedroClavijo
Dear Tom,
I want to forecast using the following code:
Code: Select all
group starmodel star>>sforecast
*
* Computes forecasts for 40 steps beginning in 2001 by taking
* the mean of simulated values over 10000 replications.
*
set meanf 2001:1 2040:1 = 0.0
compute nreps=10000
do reps=1,nreps
simulate(model=starmodel,from=2001:1,to=2040:1)
set meanf 2001:1 2040:1 = meanf+sforecast
end do reps
set meanf 2001:1 2040:1 = meanf/nreps
*
forecast(model=starmodel,from=2001:1,to=2040:1)
*
graph(key=loright,klabels=||"Eventual Forecast","Mean Forecast","Actual"||) 3
# sforecast
# meanf
# LM 2000:1 2010:1
but I am getting:
The Error Occurred At Location 103, Line 2 of loop/block
## FO19. Forecast for LM solves to NA at 2011:01, on iteration 1.
My series goes from 1870:1 to 2010:1. Any idea about what is going on?
Thanks
PC
Re: Forecasting using a LSTAR model
Posted: Thu Sep 19, 2019 7:24 pm
by TomDoan
Offhand, it sounds like the your model depends upon a series which ends in 2010:1 (i.e. isn't fully self-contained). However, there is no way to tell without the complete program.
Re: Forecasting using a LSTAR model
Posted: Thu Sep 19, 2019 8:31 pm
by PedroClavijo
This is my code:
Code: Select all
cal 1870
open data lm.xls
data(org=col, format=xls) 1870:1 2010:1 LM ZV
*
linreg(NOPRINT,define=basemodel) LM
# constant LM{1 5}
nonlin(parmset=starparms) delta c
frml flstar = (1+exp(-((delta)/(1-delta))*(ZV-c)))**-1
*
set trend = t
*
stats(noprint) ZV
compute c=%mean
compute delta=0.5
*
equation standard LM
# constant trend LM{1 to 5}
equation transit LM
# LM{1 to 5}
*
frml(equation=standard,vector=phi1) phi1f
frml(equation=transit ,vector=phi2) phi2f
frml star LM = f=flstar,phi1f+f*phi2f
*
nonlin(parmset=regparms) phi1 phi2
nonlin(parmset=starparms) delta c
*
compute phi1=%const(0.0),phi2=%const(0.0)
*
nlls(ROBUSTERRORS,parmset=regparms,frml=star) LM
equation standard LM
# constant trend LM{1 2 4}
equation transit LM
# LM{2 4}
*
frml(equation=standard,vector=phi1) phi1f
frml(equation=transit ,vector=phi2) phi2f
compute phi1=%const(0.0),phi2=%const(0.0)
nlls(ROBUSTERRORS,parmset=regparms+starparms,derives=dd,frml=star) LM
Thanks.
Re: Forecasting using a LSTAR model
Posted: Thu Sep 19, 2019 9:34 pm
by TomDoan
Right. Your transition depends upon the exogenous ZV. ZV doesn't exist beyond 2010:1 so you can't forecast beyond that.
Re: Forecasting using a LSTAR model
Posted: Thu Sep 19, 2019 10:29 pm
by PedroClavijo
In fact, ZV is the absolute value of (LM-LM{5}). Should I modify this in my code in order to forecast? Would this work?
Thanks
PC
Re: Forecasting using a LSTAR model
Posted: Fri Sep 20, 2019 7:35 am
by TomDoan
You have to add a definition FRML to your model which defines ZV as a function of LM.
By the way, what is this?
frml flstar = (1+exp(-((delta)/(1-delta))*(ZV-c)))**-1
The delta/(1-delta) parameterization makes no sense and the (1+exp(zz))**-1 calculation is subject to overflow problems. (That's why we have the %LOGISTIC function, as described in the User's Guide).
Re: Forecasting using a LSTAR model
Posted: Fri Sep 20, 2019 10:54 am
by PedroClavijo
Thanks for the suggestion of the FRML function.
By the way, what is this?
frml flstar = (1+exp(-((delta)/(1-delta))*(ZV-c)))**-1
This expression is a parameterization which tries to nest a TAR model. I define δ∈ (0,1], such that δ=γ/(1+γ) with δ→0 as γ→0 and δ→1 as γ→∞. In the case of δ→1 it will be suggesting that a TAR model would be more appropriate. What do you think about this approach?
I'll try the %logistic function.
Best,
PC
Re: Forecasting using a LSTAR model
Posted: Fri Sep 20, 2019 1:02 pm
by TomDoan
The problem with the STAR turning into a TAR is that the function becomes non-differentiable (in fact, not continuous) with respect to C. How you parameterize the scale on the logistic has no effect on that and your method just makes interpreting that scale more difficult.