Forecast with NLLS

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
yelena
Posts: 31
Joined: Wed Sep 09, 2015 8:49 pm

Forecast with NLLS

Unread post by yelena »

Dear Tom,
I have written the code for the NLLS with the restrictions on the parameters but now need to use it to forecast the dependent variable. But my code does not work? Could you please help me again?
Thank you.

nonlin(parmset=fullset) a0 a1 a2 a3 a3>=0
frml dpndfrml DEPENDENT = a0 + a1 * YOY%_SP500 + a2 * BAA{2} + a3 * YOY%_OIL{2}
compute a0 = 1.0
compute a1 = 1.0
compute a2 = 1.0
compute a3 = 1.0
nlls(frml=dpndfrml, parmset=fullset,cvcrit=0.0001, iterations=1000, method=gauss) DEPENDENT sambeg samend residModXLG8_11 coefModXLG8_11

group dpndfrml_f dpndfrml
forecast(model=dpndfrml_f, from=2015:02, steps=9, print) forecast
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Forecast with NLLS

Unread post by TomDoan »

What does "not work" mean? Offhand, looking at this, I'm wondering where the out-of-sample values for the three explanatory variables are supposed to come from.
yelena
Posts: 31
Joined: Wed Sep 09, 2015 8:49 pm

Re: Forecast with NLLS

Unread post by yelena »

The out-of-sample variables come from the Excel file open data "U:\SSSI\Severity_Index_NV_Yelena\DFAST_BHC_2015\Data_Macro_DFAST.xlsx"

I have found another way to program the forecast. Is it correct?

nonlin(parmset=fullset) a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a3=beta3 a5=beta5 a7=beta7
frml dpndfrml_d DEPENDENT = a0 + a1 * YOY%_SP500+a2 * BAA{2} + a3 * YOY%_OIL{2} + a4 * YOY%_CPI + a5 * TR10Y{1} + a6 * YOY%_HPI{1} + a7 * TR3M + a8 * YOY%_CRE + a9 * UR + a10 * DEPENDENT{1}
compute a0 = 1.0
compute a1 = 1.0
compute a2 = 1.0
compute a3 = 1.0
compute a4 = 1.0
compute a5 = 1.0
compute a6 = 1.0
compute a7 = 1.0
compute a8 = 1.0
compute a9 = 1.0
compute a10 = 1.0
nlls(frml=dpndfrml_d, parmset=fullset,cvcrit=.00001, iterations=1000, method=gauss) DEPENDENT sambeg samend residModXLG9_11 coefModXLG9_11

set DEPENDENT_EST_8 sambeg samend = %beta(1) + %beta(2) * YOY%_SP500{1} + %beta(3) * BAA{2} + %beta(4) * YOY%_OIL{2} $
+ %beta(5) * YOY%_CPI + %beta(6) * TR10Y{1} + %beta(7) * YOY%_HPI{1} + %beta(8)*TR3M + %beta(9)* YOY%_CRE + %beta(10) * UR + %beta(11) * DEPENDENT{1}

compute alpha0_nlls_d = %beta(1)
dis 'alpha0_nlls_d = ' alpha0_nlls_d

compute alpha1_nlls_d = %beta(2)
dis 'alpha1_nlls_d = ' alpha1_nlls_d

compute alpha2_nlls_d = %beta(3)
dis 'alpha2_nlls_d = ' alpha2_nlls_d

compute alpha3_nlls_d = %beta(4)
dis 'alpha3_nlls_d = ' alpha3_nlls_d

compute alpha4_nlls_d = %beta(5)
dis 'alpha4_nlls_d = ' alpha4_nlls_d

compute alpha5_nlls_d = %beta(6)
dis 'alpha5_nlls_d = ' alpha5_nlls_d

compute alpha6_nlls_d = %beta(7)
dis 'alpha6_nlls_d = ' alpha6_nlls_d

compute alpha7_nlls_d = %beta(8)
dis 'alpha7_nlls_d = ' alpha7_nlls_d

compute alpha8_nlls_d = %beta(9)
dis 'alpha8_nlls_d = ' alpha8_nlls_d

compute alpha9_nlls_d = %beta(10)
dis 'alpha9_nlls_d = ' alpha9_nlls_d

compute alpha10_nlls_d = %beta(11)
dis 'alpha10_nlls_d = ' alpha10_nlls_d

equation(coeffs=||alpha0_nlls_d,alpha1_nlls_d,alpha2_nlls_d,alpha3_nlls_d,alpha4_nlls_d,alpha5_nlls_d,alpha6_nlls_d, alpha7_nlls_d, $
alpha8_nlls_d, alpha9_nlls_d, alpha10_nlls_d||) dpndfrmleq_d DEPENDENT
# constant YOY%_SP500{1} BAA{2} YOY%_OIL{2} YOY%_CPI TR10Y{1} YOY%_HPI{1} TR3M YOY%_CRE UR DEPENDENT{1}

uforecast(equation=dpndfrmleq_d, from=2015:02, steps=9, print) forecast_nlls_d

Also, Tom, I need to run rubosterrors with NLLS. How to add this option?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Forecast with NLLS

Unread post by TomDoan »

The original idea should work---you never explained what you meant by it not working. Yes, given that it's linear, you can create an EQUATION and use UFORECAST. You could have simplified that considerably by just using EQUATION(COEFFS=%BETA,...) rather than copying the %BETA information into a bunch of separate variables.

Just add the ROBUSTERRORS option to the NLLS.
yelena
Posts: 31
Joined: Wed Sep 09, 2015 8:49 pm

Re: Forecast with NLLS

Unread post by yelena »

Oh, great! Thank you, Tom! It worked!
Post Reply