stamp logo
  • About STAMP
    • Changelog
    • Documentation
    • History
    • Literature
    • Order STAMP
  • Authors
  • Time Series Lab

STAMP Batch Language

STAMP is mostly menu-driven for ease of use. To add flexibility, certain functions can be accessed through entering commands. The syntax of these commands is described in this chapter. They can be added to the general list of Batch commands provided by OxMetrics.

STAMP allows models to be formulated, estimated and evaluated through batch commands. Such commands are entered in OxMetrics. Certain commands are intercepted by OxMetrics, such as those for loading and saving data, as well as blocks of algebra code. The remaining commands are then passed on to the active module, which is STAMP in this case. This section gives an alphabetical list of the STAMP batch language statements. There are two types of batch commands: function calls (with or without arguments) terminated by a semicolon, and commands, which are followed by statements between curly brackets.

Anything between /* and */ is considered comment. Note that this comment cannot be nested. Everything following // up to the end of the line is also comment.

OxMetrics allows you to save the current model as a batch file, and to rerun saved batch files. If a model has been created interactively, it can be saved as a batch file for further editing or easy recall in a later session. This is also the most convenient way to create a batch file.

If an error occurs during processing, the batch run will be aborted and control returned to OxMetrics. A warning or out of memory message will have to be accepted by the user (press Enter), upon which the batch run will resume.

Batch is activated in OxMetrics via Model/Batch or just by pressing Alt+b. The batch dialog appears with default code displayed. The code reflects the current model in STAMP.

In the following list, function arguments are indicated by words, whereas the areas where statement blocks are expected are indicated by .... Examples follow the list of descriptions. For terms in double quotes, the desired term must be substituted and provided together with the quotes.

♦ estimate();

Starts the estimation process.

♦ forecast(nrfor, incr, option);

Prints nrfor ahead forecasts of dependent variables. When explanatory variables are included in the model, the incr value is the increment value for all exogenous variables. Otherwise, no value for incr should be given. When the data is in logs and the forecasts need to be anti-logged, the option variable must be set to "logs". Otherwise, no value is required for option. This function automatically creates a copy of the dependent variable in the database with its forecasts attached to it at the end of the estimation sample. When necessary, the sample of the database is extended. Furthermore it prints a forecasting report in the Results window.

♦ intervention(component, year, period);

The component argument specifies the type of intervention to be included in the model:

  • include outlier: "outlier";

  • include structural break: "level";

  • include slope change: "slope";

  • no intervention in the model: "off".

The year and period indicates the start of the intervention. When year and period refer to a non-existing date within the sample, the intervention will not enter the model.

♦ system {Y=...; X=...; } Formulate the model, consisting of the following components:

  • [Y] dependent variables;

  • [X] explanatory variables;

The variables listed are separated by commas, the base names (that is, name excluding lag length) for Y and X must be in the database. If the variable names are not a valid token, the name must be enclosed in double quotes.

♦ store(type, variable, option);

Use this command to store prediction residuals, smoothed components and smoothed auxiliary residuals into the database, the default name is used.

The type must be one of: "residuals", "components", "auxresiduals".

When type is residuals, no variable and option need to be specified.

When type is "components", the variable can also be one of: "trend", "slope", "seasonal", "cycle", "ar", "irregular", "detrend", "seasadj" and "tvpar". The variable "cycle" refers to the sum of smoothed components associated with autoregressive and the three cycles. The variable "trend" is the same as the smoothed level and "tvpar" refers to the time-varying regression coefficients. When type is "components", the option variable can be one of: "pred" for predictive filtered estimate, "fil" for filtered estimate and "smo" the smoothed (default) estimate.

When type is "auxresiduals", no variable need to be specified. The variable must be one of: "irregular", "level", "slope". No option need to be specified.

♦ setcmp(cmp, order, variance, par1, par2);

Introduces an unobserved component in the model. The possibilities are:

  • setcmp("level", -, 1.0, -, -); where - refers to "not a relevant number" and 1.0 is the variance.

  • setcmp("slope", 2, 1.0, -, -); where 2 is the order of the trend.

  • setcmp("seasonal", 4, 1.0, -, -); where 4 is the length of the seasonal.

  • setcmp("irregular", -, 1.0, -, -);

  • setcmp("cycle", 2, 1.0, 5, 0.9); where 2 is the order of the cycle, 5 is the period and 0.9 is the discounting factor of the cycle.

  • setcmp("ar", 1, 1.0, 0.8, -); where 1 is the order of the autoregressive process, AR(1) and 0.8 is the autoregressive coefficient.

  • setcmp("ar", 2, 1.0, 0.8, 0.2); where 2 is the order of the autoregressive process, AR(2), 0.8 is the first autoregressive coefficient and 0.2 is the second autoregressive coefficient.

♦ setmodel();

This call is required to activate all specified unobserved components in the model. This call must always come after the last setcmp statement.

♦ teststate();

Prints the estimated final state and the estimated regression and intervention vector together with the corresponding test statistics. The output depends on the specified model.

♦ testsummary();

Prints the estimation and diagnostic summary reports.

We finish with an annotated example using most commands. To run this file, we assume that OxMetrics is loaded with ENERGY.IN7, and that STAMP has been started.

// Batch code for UC( 1)
module("STAMP");
package("UCstamp");
usedata("ENERGY.IN7");
system
{
    Y = ofuELl;
}
setcmp("level", 1, 0.000327959, 0, 0);
setcmp("slope", 1, 1.27393e-006, 0, 0);
setcmp("seasonal", 4, 0.000120803, 0, 0);
setcmp("irregular", 0, 0.000244399, 0, 0);
intervention("outlier", 1968, 4);
intervention("outlier", 1974, 1);
setmodel();
estimate("ML", 1960, 1, 1986, 4);
forecast(8);
store("residuals");
store("components", "seasadj", "fil");

This Batch code produces the output:

 Estimating..
 Very strong convergence relative to 1e-007
 - likelihood cvg 9.89599e-015
 - gradient cvg 7.35869e-008
 - parameter cvg 7.61594e-008
 - number of bad iterations 0
 Estimation process completed.

UC( 2) Estimation done by Maximum Likelihood (exact score)
    The database used is C:\Users\s.j.koopman\Documents\OxMetrics6\data\ENERGY.IN7
    The selection sample is: 1960(1) - 1986(4) (T = 108, N = 1)
    The dependent variable Y is: ofuELl
    The model is:  Y = Trend + Seasonal + Irregular + Interventions
    Steady state. found

Log-Likelihood is 295.641 (-2 LogL = -591.282).
Prediction error variance is 0.0024297

Summary statistics
                   ofuELl
 T                 108.00
 p                 3.0000
 std.error       0.049292
 Normality         17.120
 H(33)            0.72117
 DW                1.8406
 r(1)            0.061773
 q                 12.000
 r(q)          -0.0092300
 Q(q,q-p)          9.3476
 Rs^2             0.76665

 Variances of disturbances:
                    Value    (q-ratio)
Level         0.000327959  (    1.000)
Slope        1.27393e-006  ( 0.003884)
Seasonal      0.000120803  (   0.3683)
Irregular     0.000244399  (   0.7452)


State vector analysis at period 1986(4)
                             Value      Prob
Level                      6.35343 [0.00000]
Slope                      0.01126 [0.01921]
Seasonal chi2 test        50.24905 [0.00000]
Seasonal effects:
                Period       Value      Prob
                     1     0.16215 [0.00000]
                     2    -0.06904 [0.02530]
                     3    -0.13451 [0.00000]
                     4     0.04140 [0.10536]

Regression effects in final state at time 1986(4)

                Coefficient        RMSE     t-value      Prob
Outlier 1968(4)     0.11156     0.03657     3.05048 [0.00292]
Outlier 1974(1)    -0.23316     0.03657    -6.37579 [0.00000]

ofuELlForc [1960(1) - 1988(4)] saved to ENERGY.IN7
Standardised Residuals [1960(1) - 1986(4)] saved to ENERGY.IN7
ofuELlSeasAdj(Fil) [1960(1) - 1986(4)] saved to ENERGY.IN7

Forecasts with 68% confidence interval from period 1986(4) forwards:
          Forecast   stand.err   leftbound  rightbound
1          6.52684     0.05097     6.47587     6.57781
2          6.30690     0.05247     6.25443     6.35938
3          6.25270     0.05539     6.19730     6.30809
4          6.43987     0.05625     6.38363     6.49612
5          6.57188     0.07572     6.49616     6.64760
6          6.35195     0.07760     6.27435     6.42954
7          6.29774     0.08073     6.21701     6.37847
8          6.48492     0.08198     6.40294     6.56690

Copyright © 1995-2021 | STAMP | All rights reserved
Privacy policy