Time Series Model Package
TSM Methods
TSM.AddExternal Method
rc=obj.AddExternal (Series <,Role>);
Adds a time series array, Series, for use in external model computations when the TSM object is initialized from an external model specification (EXMSPEC) object. Calling this method when the TSM object is not configured with an EXMSPEC results in a nonzero return code and no further action. However, the specified parameters are saved so that you can configure the TSM object with an EXMSPEC by using the TSM.Replay method. In that case, the parameters that you specify in this TSM.AddExternal call are processed when you call the Run method. For more information about external model support, see the section EXMSPEC Object.
No default role mapping is implied by the name of the Series variable that you specify in the method. Each call to the AddExternal method adds the specified series to the TSM object according to its role in the external model. That role association happens in one of the following ways:
You specify the Role argument in the method call. This takes precedence over any role mapping that is defined in the EXMSPEC that was used in the TSM.Initialize method. If you specify an invalid Role value, an error occurs.
You specify a Series variable that matches a role mapping in the EXMSPEC object that was used in the TSM.Initialize method. If you specify a Series variable that fails to match a role mapping in the EXMSPEC, an error occurs.
This method can be called as many times as needed to specify all of the external series that are required to run the external model. In all cases, if the series that you specify to add fails to resolve to a role in the EXMSPEC object, an error occurs without the series being included in the TSM object. Such failures do not cause subsequent TSM.AddExternal method calls to fail.
Input Arguments
You must specify the following input arguments:
- Series
specifies a numeric array that contains an external forecast series for the TSM object.
- Role
-
is a case-sensitive character string that specifies the role of the external forecast series in the external model. You can specify one of the following values:
- ERROR
returns prediction errors.
- LOWER
returns a lower confidence limit series.
- STDERR
returns a prediction standard error series.
- PREDICT
returns a prediction series.
- UPPER
returns an upper confidence limit series.
TSM.AddX Method
rc=obj.AddX (XSeries <,Required,NoDiff,ModelSymbol>);
Adds an independent time series array (XSeries) for the TSM object. Each call of the TSM.AddX method adds the specified XSeries array variable to the TSM object. This method can be called as many times as needed to specify all the independent variables. By default, the name of the XSeries variable must match the name of an input symbol in the model specification that is used to configure the TSM object. You can specify a symbol name, ModelSymbol, to associate an XSeries array with an input symbol in the model specification. ARIMA, RNN, and UCM models support XSeries predictors, but RNN models ignore the optional arguments.
Input Arguments
You must specify the following input argument:
- XSeries
specifies a numeric array that contains an independent series for the TSM object.
You can also specify the following input arguments:
- Required
takes a Boolean value (0 or 1) that, when set to 1, specifies that the XSeries variable is required to be in the model. This might cause the model estimation to fail if the XSeries array variable is deemed inadmissible for inclusion in the underlying model. The default value is 0.
- NoDiff
takes a Boolean value (0 or 1) that, when set to 1, specifies that the XSeries variable does not automatically follow the XSeries variable differencing. The default value is 0.
- ModelSymbol
takes a character variable that specifies the name of an input symbol in the model specification to be associated with the XSeries variable when the model is run. By default, the TSM.AddX method adds XSeries variables to a model specification if they are not already referenced as an input symbol. Specification of ModelSymbol defines a way to include the XSeries variable if the model specification object includes a symbol that matches the ModelSymbol argument.
TSM.criterion Method
criterion=obj.criterion (Region );
Returns the fit statistic value over the specified forecast Region for the TSM object. The criterion is set via the 'CRITERION' argument in the TSM.SetOption method. A missing value indicates that the TSM object instance has not produced a successful forecast.
Input Arguments
You must specify the following input argument:
- Region
-
is a case-insensitive character string that specifies the forecast region over which the fit statistic is computed. You can specify one of the following values:
- BACK
returns the fit statistic over the time region that is subsequent to the FIT region and that did not contribute any data for estimating model parameters (that is, the model forecast region).
- FIT
returns the fit statistic over the time region that supplied observations for estimating model parameters (that is, the model fit region).
TSM.GetForecast Method
rc=obj.GetForecast (Which, Result);
Gets the specified forecast series (Which) from the TSM object and stores it in the specified numeric array (Result).
Input Arguments
You must specify the following input argument:
- Which
-
is a case-insensitive character string that specifies the type of forecast series to return. You can specify one of the following values:
- ERROR
returns prediction errors.
- LOWER
returns a lower confidence limit series.
- STDERR
returns a prediction standard error series.
- PREDICT
returns a prediction series.
- UPPER
returns an upper confidence limit series.
Output Arguments
You must specify the following output argument:
- Result
specifies a numeric array to receive the forecast series.
TSM.Initialize Method
rc=obj.Initialize (<ModelSpec>);
Initializes a TSM object to use the specified ModelSpec. This method must be called before the time series arrays (XSeries and YSeries) and other attributes for the TSM object are specified. If no ModelSpec object is specified, the TSM object is initialized to use the default ESM specification. This is equivalent to initializing the TSM object with an ESMSPEC object that has default option values.
Input Arguments
You can specify the following input argument:
- ModelSpec
specifies an optional name for a TSM model specification object that is used to configure the TSM object.
TSM.nfor Method
nfor=obj.nfor ();
Returns the length (observation count) of the forecast series for the TSM object. A missing value indicates that the TSM object has not produced a successful forecast.
Arguments
There are no arguments associated with this method.
TSM.Replay Method
rc=obj.Replay (TSMINSPECObj <,TSMINESTObj>);
Uses a previously saved model specification from a TSMINSPECObj as input to another TSM object. Optionally, restored parameter estimates from TSMINESTObj are applied to the model specification.
Input Arguments
You must specify the following input argument:
- TSMINSPECObj
specifies the TSMINSPEC object to supply the model specification.
You can also specify the following input argument:
- TSMINESTObj
specifies the TSMINEST object to supply the model’s parameter estimates.
TSM.Run Method
rc=obj.Run ();
Runs the TSM object to estimate and forecast the time series model by using the specified dependent (YSeries) and independent (XSeries) series. Upon successful completion, various results can be extracted from the TSM object. The Run method also attempts to process any TSM.AddExternal calls that were deferred because of the TSM object not being configured with an EXMSPEC. An error occurs at this point if the TSM object is still not configured with an EXMSPEC but you had specified TSM.AddExternal method calls.
Arguments
There are no arguments associated with this method.
TSM.SetOption Method
rc=obj.SetOption ('Name', Value <,'Name',Value,…>);
Specifies the named options for the TSM object. When you invoke this method, the previous forecast produced by the TSM.Run method is discarded. You must then rerun the TSM.Run method in order to produce a new forecast using the updated configuration options.
Input Arguments
You must specify at least one of the following 'Names' and its associated Value:
- 'ALPHA'
takes a numeric Value between 0 and 1, exclusive, that specifies the significance level for forecast confidence bands. The default value is 0.05.
- 'BACK'
takes a nonnegative integer Value that specifies the back region for model performance. If 'BACK'=n and the number of observations is T, then the first
observations are used to diagnose a series. The default is value 0.
- 'CRITERION'
takes a string Value that specifies the model selection criterion (statistic of fit) to be used to select from several candidate models. For a list of valid values, see the CRITERION= option in the HPFDIAGNOSE procedure in SAS Forecast Server Procedures: User's Guide. The default is RMSE.
- 'HOLDOUT'
takes a nonnegative integer Value that specifies the holdout region for model selection. The holdout sample is a subset of dependent series (which you specify by using the TSM.SetY method) that ends at the last nonmissing observation. This option is relevant only when a TSM instance has been initialized via the Initialize method by using a model specification that requires model selection. Currently, this applies only to a model specification that is created by an ESMSPEC object and whose 'METHOD' option is set to either 'BEST', 'BESTN', or 'BESTS' via the ESMSPEC.SetOption method. The default value is 0.
- 'HORIZON'
takes a numeric Value that specifies the forecast horizon reference time. When set to a missing value, the forecast horizon reference time is automatically set as the first time period that follows the last nonmissing observation of the dependent series. The default value is a missing value. Currently, this option does not apply to a model specification that is created by an RNNSPEC object.
- 'LEAD'
takes a nonnegative integer Value that specifies the forecast lead. The default value is the value specified in the PROC TSMODEL statement (LEAD= option). If LEAD= is not specified in the PROC TSMODEL statement, the default value of LEAD=0.