I am trying to implement a forecasting model from SAS Viya in SAS code. Below is the screenshot of the Viya model:
here is what I put in sas code
PROC ARIMA DATA=AP.GR_DEG_FORECAST;
IDENTIFY VAR=Graduate_Count(1);
ESTIMATE p=1 METHOD=ML; /*forecast input series*/
IDENTIFY VAR=Doctoral_degrees(1) CROSSCORR=Graduate_Count(1) NOPRINT;
ESTIMATE NOINT INPUT=(1 $ (1)Graduate_Count/(2)Graduate_Count) METHOD=ML;
FORECAST ID=AY INTERVAL=YEAR LEAD=6 ALPHA=0.05 OUT=PREJ_DOC_DEG_FORECAST PRINTALL /* print the FORECAST computation throughout the whole data set*/;
RUN;
Title "Forecast: PRE#J: Doctoral Degrees Awarded Annually";
PROC SGPLOT DATA=PREJ_DOC_DEG_Forecast;
BAND Upper=u95 Lower=l95 x=AY / Legendlabel="95% Confidence Limits";
scatter x=AY y=Doctoral_degrees;
series x=AY y=forecast;
refline "01JAN2022"d / axis=x lineattrs=(thickness=1 color=BLUE pattern=dash);
RUN;
Title;
However, I got very different results by running the sas code. And the model does not seem to catch the data series as it would in Viya. I am not sure which step of the code is wrong. Can anyone help me? Here is a screenshot of the forecast from sas code:
Hello @xliu1 ,
I looked at :
Forecasting is a Snap in SAS Visual Analytics 8.2 on SAS Viya 3.3
Posted 04-25-2018 09:42 PM | by @BethEbersole
... and I do not think you can see the forecasting-code used in the back-end.
It will not be PROC ARIMA. I am sure about that! It will rather be the HPF-procedures from Forecast Server (HPF = High-Performance Forecasting) or PROC TSMODEL as used in Visual Forecasting.
But anyway, it's not because PROC ARIMA was not used that you are not able to reproduce the forecasts in PROC ARIMA of course.
You can try a different estimation method (METHOD=CLS | ML | ULS)
, but that should not make a super-big difference.
I don not see the "error" in your PROC ARIMA at this moment.
Kind regards,
Koen
Hello,
That seems a very weird result to me (and a very bad fit).
Are you sure you are specifying the exact same model as given by Visual Forecasting?
Also, the syntax in your input= may be wrong.
You specify Graduate_Count for the numerator and again for the denominator of the transfer function.
Specifying it once should be enough, like in :
input=(1 $ (1)/(2)x)
Cheers,
Koen
@sbxkoenk Thanks for your response! I also realized that typo, and removed Graduate_Count from the numerator. However, I still get very strange results. I am learning forecasting with input variables, and Viya model can help me better understand how to set up parameters. Here is the graph I get from running the sas code. I am not sure which part of the code does not match with Viya model or if the Viya forecasting uses different calculation methods?
PROC ARIMA DATA=AP.GR_DEG_FORECAST;
IDENTIFY VAR=Graduate_Count(1);
ESTIMATE p=1 METHOD=ML; /*forecast input series*/
IDENTIFY VAR=Doctoral_degrees(1) CROSSCORR=Graduate_Count(1) NOPRINT;
ESTIMATE NOINT INPUT=(1 $ (1)/(2)Graduate_Count) METHOD=ML;
FORECAST ID=AY INTERVAL=YEAR LEAD=6 ALPHA=0.05 OUT=PREJ_DOC_DEG_FORECAST PRINTALL /* print the FORECAST computation throughout the whole data set*/;
RUN;
/* Plot forecast for PRE#J: Doctoral Degrees Awarded Annually */
Title "Forecast: PRE#J: Doctoral Degrees Awarded Annually";
PROC SGPLOT DATA=PREJ_DOC_DEG_Forecast;
BAND Upper=u95 Lower=l95 x=AY / Legendlabel="95% Confidence Limits";
scatter x=AY y=Doctoral_degrees;
series x=AY y=forecast;
refline "01JAN2022"d / axis=x lineattrs=(thickness=1 color=BLUE pattern=dash);
RUN;
Title;
Hello @xliu1 ,
I am not sure what you mean with "VIYA Forecasting".
Are you talking about Visual Forecasting in Model Studio?
Or are you talking about SAS Tasks in SAS Studio V?
Or are you talking about SAS snippets in SAS Studio V?
I think you use Visual Forecasting (VF).
VF uses PROC TSMODEL to do the forecasting.
Have a look at the generated TSMODEL code to exactly know which model was fit. Right-Mouse-Button (RMB) click on Forecasting node and then select View code (bottom option).
Also : which version of SAS VIYA are you using?
Submit :
%PUT &=sysvlong4;
to find out (see log-screen).
Thanks,
Koen
Thanks for your reply @sbxkoenk. I am using the Forecasting template under SAS Visual Analytics - Explore and Visualize Data. I try to right click the mouse button within the Forecasting template, and did not see any option for viewing code. The model algorithm is displayed when I maximize the forecasting template. But when I implement the same algorithm in SAS base, I see the calculation is different as it is shown in the base output graph. Is the algorithm implemented in SAS base different from it is in Visual Analytics? Here is what I found out about version
Hello @xliu1 ,
I looked at :
Forecasting is a Snap in SAS Visual Analytics 8.2 on SAS Viya 3.3
Posted 04-25-2018 09:42 PM | by @BethEbersole
... and I do not think you can see the forecasting-code used in the back-end.
It will not be PROC ARIMA. I am sure about that! It will rather be the HPF-procedures from Forecast Server (HPF = High-Performance Forecasting) or PROC TSMODEL as used in Visual Forecasting.
But anyway, it's not because PROC ARIMA was not used that you are not able to reproduce the forecasts in PROC ARIMA of course.
You can try a different estimation method (METHOD=CLS | ML | ULS)
, but that should not make a super-big difference.
I don not see the "error" in your PROC ARIMA at this moment.
Kind regards,
Koen
Thank you @sbxkoenk for your post. It helps me better understand forecasting done in SAS Visual & Analytics.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.