The HPF Procedure
Example 2.4 Extending the Independent Variables for Multivariate Forecasts
(View the complete code for this example.)
In the previous example, the HPF procedure was used to forecast several transactional series variables by using univariate models. This example illustrates how the HPF procedure can be used to extend the independent variables associated with a multiple regression forecasting problem. Specifically, PROC HPF is used to extend the independent variables for use in forecasting a regression model.
This example accumulates and forecasts the BOATS, CARS, and PLANES variables as illustrated in the previous example. In addition, it accumulates the ENGINES variable to form a time series that is then extended with missing values within the forecast horizon with the specification of MODEL=NONE.
proc hpf data=websites out=nextweek lead=7;
id time interval=dtday accumulate=total;
forecast engines / model=none;
forecast boats / model=bests criterion=mape;
forecast cars / model=bestn criterion=mse holdout=5;
forecast planes / model=winters transform=log;
run;
The following AUTOREG procedure statements are used to forecast the ENGINES variable by regressing on the independent variables (BOATS, CARS, and PLANES).
proc autoreg data=nextweek;
model engines = boats cars planes / noprint;
output out=enginehits p=predicted;
run;
The output data set (NEXTWEEK) of the PROC HPF statement is used as an input data set for the PROC AUTOREG statement. The output data set of PROC AUTOREG contains the forecast of the variable ENGINES based on the regression model with the variables BOATS, CARS, and PLANES as regressors. For more information about autoregression models, see Chapter 8, AUTOREG Procedure (SAS/ETS User's Guide).
The following SGPLOT procedure statements plot the forecasts related to the ENGINES variable:
proc sgplot data=enginehits noautolegend;
series x=time y=boats / markers
markerattrs=(symbol=plus) lineattrs=(pattern=1);
series x=time y=cars / markers
markerattrs=(symbol=plus) lineattrs=(pattern=1);
series x=time y=planes / markers
markerattrs=(symbol=plus) lineattrs=(pattern=1);
series x=time y=predicted / markers
markerattrs=(symbol=plus) lineattrs=(pattern=1);
xaxis values=('13MAR2000:00:00:00'dt to '18APR2000:00:00:00'dt by dtweek);
yaxis label='Webhits';
refline '11APR2000:00:00:00'dt / axis=x;
run;
The SGPLOT procedure results are shown in Output 2.4.1. The historical data is shown to the left of the vertical reference line, and the forecasts for the next four weekly periods is shown to the right.
Output 2.4.1: Internet Data Forecast Plots
