|
|
|
|
|
|
時系列分析ソフトウェア
RATS |
|
3-7. RATS Basics: Forecasting
Another common task is forecasting data. RATS can can forecast linear and non-linear equations, systems of interdependent equations, and full simultaneous systems of equations. Most forecasting is done using the FORECAST instruction. We'll quickly cover a couple of examples here.
Our Example Program
Suppose we have data for AVGPRICES for the years 1942 through 1945, and we want to see if we can use this data to accurately forecast food production over that period. We'll try a model which regresses food production on a constant, lagged food production, and current average prices.
First, we estimate our regression, using the DEFINE option to create an equation called PRODEQ. The equation stores the names of the variables and the estimated coefficients, which FORECAST will use to compute the forecasts. Here's our regression:
LINREG(DEFINE=PRODEQ) FOODPROD
# CONSTANT FOODPROD{1} AVGPRICES
Now we need to input our average prices data for 1942 through 1945. Rather than reading the data from a file, we'll use the UNIT=INPUT option on DATA, which allows us to type in the data directly:
DATA(UNIT=INPUT) 1942:1 1945:1 AVGPRICES
112.3 112.8 113.9 119.3
Now we're ready to compute forecasts. The following instruction forecasts one equation (PRODEQ) for four time periods, starting with 1942:1. The forecasts are stored in a series called FOODPROD_FORCST:
FORECAST 1 4 1942:1
# PRODEQ FOODPROD_FORCST
Now we'll use PRINT to display the actual and forecasted values, along with AVGPRICES. The NA's in the output indicate data that is Not Available. For example FOODPROD_FORCST has only been defined from 1942 on, so earlier entries are shown as NA:
PRINT / AVGPRICES FOODPROD FOODPROD_FORCST
ENTRY |
AVGPRICES |
FOODPROD |
FOODPROD_FORCST |
1922:01 |
NA |
108.50000000000 |
NA |
1923:01 |
99.10000000000 |
110.10000000000 |
NA |
1924:01 |
99.00000000000 |
110.40000000000 |
NA |
1925:01 |
104.85000000000 |
104.30000000000 |
NA |
1926:01 |
109.50000000000 |
107.20000000000 |
NA |
1927:01 |
106.90000000000 |
105.80000000000 |
NA |
1928:01 |
107.70000000000 |
107.80000000000 |
NA |
1929:01 |
109.25000000000 |
103.40000000000 |
NA |
1930:01 |
104.65000000000 |
102.70000000000 |
NA |
1931:01 |
90.80000000000 |
104.10000000000 |
NA |
1932:01 |
74.80000000000 |
99.20000000000 |
NA |
1933:01 |
69.75000000000 |
99.70000000000 |
NA |
1934:01 |
76.15000000000 |
102.00000000000 |
NA |
1935:01 |
91.85000000000 |
94.30000000000 |
NA |
1936:01 |
103.65000000000 |
97.70000000000 |
NA |
1937:01 |
107.75000000000 |
101.10000000000 |
NA |
1938:01 |
101.50000000000 |
102.30000000000 |
NA |
1939:01 |
90.90000000000 |
104.40000000000 |
NA |
1940:01 |
91.15000000000 |
108.50000000000 |
NA |
1941:01 |
99.80000000000 |
111.30000000000 |
NA |
1942:01 |
112.30000000000 |
NA |
109.93406376720 |
1943:01 |
112.80000000000 |
NA |
109.02869257276 |
1944:01 |
113.90000000000 |
NA |
108.47044077353 |
1945:01 |
119.30000000000 |
NA |
108.38330631039 |
Estimating and Forecasting ARIMA and VAR Models
This estimates an ARIMA model using BOXJENK, and computes forecasts from 1991:5 through 1993:4 (two years of monthly data):
BOXJENK(DEFINE=BJEQ,SDIFFS=1,AR=2,SMA=1) LDEUIP / RESIDS
FORECAST 1 24 1991:5
# BJEQ IPFORE
The following code estimates a four-variable, 13 lag, vector autoregression (VAR) model and forecasts twelve months of data. Here, equations are referenced by number, rather than by name. Notice that RATS includes several instructions which simplify the estimation of VAR models. We use the PRINT option on FORECAST to have RATS display the forecasts as they are generated.
SYSTEM 1 TO 4
VARIABLES CPR M1 PPI IP
LAGS 1 TO 13
DETERMINISTIC CONSTANT
END(SYSTEM)
ESTIMATE
FORECAST(PRINT) 4 12 92:1
# 1 F_CPR
# 2 F_M1
# 3 F_PPI
# 4 F_IP
Forecasting Diagnostics
RATS provides a number of tools for examining the performance of forecasting models. For example, you can use the SET instruction for simple mean squared error calculations, or the THEIL instruction to compute a variety of statistics, including root mean square errors and Theil U statistics. There are also two ways to calculate the standard errors of forecasts.
|
|
|
←RATSのTopページに戻る |
|
|