PROC FORECAST uses extrapolative forecasting methods where the forecasts for a series are functions only of time and past values of the series, not of other variables.. Getting Started:
Trang 1812 F Chapter 14: The EXPAND Procedure
data samples;
input date : date9 defects @@;
label defects = "Defects per 1000 Units";
format date date9.;
datalines;
more lines
title "Sampled Defect Rates";
proc print data=samples;
run;
Output 14.3.1 Measured Defect Rates
Sampled Defect Rates
To compute the monthly estimates, use PROC EXPAND with the TO=MONTH option and spec-ify OBSERVED=(BEGINNING,AVERAGE) The following statements interpolate the monthly estimates
proc expand data=samples
out=monthly to=month plots=(input output);
id date;
convert defects / observed=(beginning,average);
run;
The following PROC PRINT step prints the results, as shown inOutput 14.3.2
title "Estimated Monthly Average Defect Rates";
proc print data=monthly;
run;
Trang 2Output 14.3.2 Monthly Average Estimates
Estimated Monthly Average Defect Rates
The plots produced by PROC EXPAND are shown inOutput 14.3.3
Output 14.3.3 Interpolated Defects Rate Curve
Trang 3814 F Chapter 14: The EXPAND Procedure
Output 14.3.3 continued
Example 14.4: Using Transformations
This example shows the use of PROC EXPAND to perform various transformations of time series The following statements read in monthly values for a variable X
data test;
input year qtr x;
date = yyq( year, qtr );
format date yyqc.;
datalines;
1989 3 5238
1989 4 5289
1990 1 5375
1990 2 5443
1990 3 5514
1990 4 5527
1991 1 5557
1991 2 5615
;
Trang 4The following statements use PROC EXPAND to compute lags and leads and a 3-period moving average of the X series
proc expand data=test out=out method=none;
id date;
convert x;
convert x = x_lead1 / transformout=(lead 1);
convert x = x_lead2 / transformout=(lead 2);
convert x = x_movave / transformout=(movave 3);
run;
title "Transformed Series";
proc print data=out;
run;
Because there are no missing values to interpolate and no frequency conversion, the METHOD=NONE option is used to prevent PROC EXPAND from performing unnecessary computations Because no frequency conversion is done, all variables in the input data set are copied
to the output data set The CONVERT X; statement is included to control the position of X in the output data set This statement can be omitted, in which case X is copied to the output data set following the new variables computed by PROC EXPAND
The results are shown inOutput 14.4.1
Output 14.4.1 Output Data Set with Transformed Variables
Transformed Series
Obs date x_lag2 x_lag1 x x_lead1 x_lead2 x_movave year qtr
References
DeBoor, Carl (1981), A Practical Guide to Splines, New York: Springer-Verlag
Hodrick, R J., and Prescott, E C (1980) “Post-war U.S business cycles: An empirical investigation.” Discussion paper 451, Carnegie-Mellon University
Trang 5816 F Chapter 14: The EXPAND Procedure
Levenbach, H and Cleary, J.P (1984), The Modern Forecaster, Belmont, CA: Lifetime Learning Publications (a division of Wadsworth, Inc.), 129-133
Makridakis, S and Wheelwright, S.C (1978), Interactive Forecasting: Univariate and Multivariate Methods, Second Edition, San Francisco: Holden-Day, 198-201
Wheelwright, S.C and Makridakis, S (1973), Forecasting Methods for Management, Third Edition, New York: Wiley-Interscience, 123-133
Trang 6The FORECAST Procedure
Contents
Overview: FORECAST Procedure 818
Getting Started: FORECAST Procedure 819
Giving Dates to Forecast Values 820
Computing Confidence Limits 820
Form of the OUT= Data Set 821
Plotting Forecasts 822
Plotting Residuals 823
Model Parameters and Goodness-of-Fit Statistics 824
Controlling the Forecasting Method 826
Introduction to Forecasting Methods 827
Time Trend Models 828
Time Series Methods 830
Combining Time Trend with Autoregressive Models 831
Syntax: FORECAST Procedure 832
Functional Summary 832
PROC FORECAST Statement 834
BY Statement 838
ID Statement 839
VAR Statement 839
Details: FORECAST Procedure 839
Missing Values 839
Data Periodicity and Time Intervals 839
Forecasting Methods 840
Specifying Seasonality 848
Data Requirements 850
OUT= Data Set 850
OUTEST= Data Set 852
Examples: FORECAST Procedure 855
Example 15.1: Forecasting Auto Sales 855
Example 15.2: Forecasting Retail Sales 860
Example 15.3: Forecasting Petroleum Sales 865
References 868
Trang 7818 F Chapter 15: The FORECAST Procedure
Overview: FORECAST Procedure
The FORECAST procedure provides a quick and automatic way to generate forecasts for many time series in one step The procedure can forecast hundreds of series at a time, with the series organized into separate variables or across BY groups PROC FORECAST uses extrapolative forecasting methods where the forecasts for a series are functions only of time and past values of the series, not
of other variables
You can use the following forecasting methods For each of these methods, you can specify linear, quadratic, or no trend
The stepwise autoregressive method is used by default This method combines time trend regression with an autoregressive model and uses a stepwise method to select the lags to use for the autoregressive process
The exponential smoothing method produces a time trend forecast However, in fitting the trend, the parameters are allowed to change gradually over time, and earlier observations are given exponentially declining weights Single, double, and triple exponential smoothing are supported, depending on whether no trend, linear trend, or quadratic trend, respectively, is specified Holt two-parameter linear exponential smoothing is supported as a special case of the Holt-Winters method without seasons
The Winters method (also called Holt-Winters) combines a time trend with multiplicative seasonal factors to account for regular seasonal fluctuations in a series Like the exponential smoothing method, the Winters method allows the parameters to change gradually over time, with earlier observations given exponentially declining weights You can also specify the additive version of the Winters method, which uses additive instead of multiplicative seasonal factors When seasonal factors are omitted, the Winters method reduces to the Holt two-parameter version of double exponential smoothing
The FORECAST procedure writes the forecasts and confidence limits to an output data set It can also write parameter estimates and fit statistics to an output data set The FORECAST procedure does not produce printed output
PROC FORECAST is an extrapolation procedure useful for producing practical results efficiently However, in the interest of speed, PROC FORECAST uses some shortcuts that cause some statistical results (such as confidence limits) to be only approximate For many time series, the FORECAST procedure, with appropriately chosen methods and weights, can yield satisfactory results Other SAS/ETS procedures can produce better forecasts but at greater computational expense
You can perform the stepwise autoregressive forecasting method with theAUTOREGprocedure You can perform forecasting by exponential smoothing with statistically optimal weights with the
ESMprocedure SeasonalARIMAmodels can be used for forecasting seasonal series for which the Winters and additive Winters methods might be used
Additionally, the Time Series Forecasting System can be used to develop forecasting models, estimate the model parameters, evaluate the models’ ability to forecast and display the results graphically See Chapter 39, “Getting Started with Time Series Forecasting,” for more details
Trang 8Getting Started: FORECAST Procedure
To use PROC FORECAST, specify the input and output data sets and the number of periods to forecast in the PROC FORECAST statement, and then list the variables to forecast in a VAR statement
For example, suppose you have monthly data on the sales of some product in a data set named PAST,
as shown inFigure 15.1, and you want to forecast sales for the next 10 months
Figure 15.1 Example Data Set PAST
The following statements forecast 10 observations for the variable SALES by using the default STEPAR method and write the results to the output data set PRED:
proc forecast data=past lead=10 out=pred;
var sales;
run;
The following statements use the PRINT procedure to print the data set PRED:
proc print data=pred;
run;
The PROC PRINT listing of the forecast data set PRED is shown inFigure 15.2
Trang 9820 F Chapter 15: The FORECAST Procedure
Figure 15.2 Forecast Data Set PRED
Giving Dates to Forecast Values
Normally, your input data set has an ID variable that gives dates to the observations, and you want the forecast observations to have dates also Usually, the ID variable has SAS date values (See Chapter 3, “Working with Time Series Data,” for information about using SAS date and datetime values.) The ID statement specifies the identifying variable
If the ID variable contains SAS date or datetime values, the INTERVAL= option should be used
on the PROC FORECAST statement to specify the time interval between observations (See Chapter 4, “Date Intervals, Formats, and Functions,” for more information about time intervals.) The FORECAST procedure uses the INTERVAL= option to generate correct dates for forecast observations
The data set PAST, shown inFigure 15.1, has monthly observations and contains an ID variable DATE with SAS date values identifying each observation The following statements produce the same forecast as the preceding example and also include the ID variable DATE in the output data set Monthly SAS date values are extrapolated for the forecast observations
proc forecast data=past interval=month lead=10 out=pred;
var sales;
id date;
run;
Computing Confidence Limits
Depending on the output options specified, multiple observations are written to the OUT= data set for each time period The different parts of the results are contained in the VAR statement variables
in observations identified by the character variable _TYPE_ and by the ID variable For example, the following statements use the OUTLIMIT option to write forecasts and 95% confidence limits for the variable SALES to the output data set PRED This data set is printed with the PRINT procedure
Trang 10proc forecast data=past interval=month lead=10
out=pred outlimit;
var sales;
id date;
run;
proc print data=pred;
run;
The output data set PRED is shown inFigure 15.3
Figure 15.3 Output Data Set
Form of the OUT= Data Set
The OUT= data set PRED, shown inFigure 15.3, contains three observations for each of the 10 forecast periods Each of these three observations has the same value of the ID variable DATE, the SAS date value for the month and year of the forecast