1. Home
  2. TKEEP directive

TKEEP directive

Saves results after an analysis by TFIT.

Option

SAVE = identifier Save structure to supply fitted model; default * i.e. that from last model fitted

Parameters

OUTPUTSERIES = variate Output series to which model was fitted
RESIDUALS = variate Residual series
ESTIMATES = variate Estimates of parameters
SE = variate Standard errors of estimates
INVERSE = symmetric matrix Inverse matrix
VCOVARIANCE = symmetric matrix Variance-covariance matrix of parameters
DEVIANCE = scalar Residual deviance
DF = scalar Residual degrees of freedom
MVESTIMATES = variate Estimates of missing values in series
SEMV = variate Standard errors of estimates of missing values
COMPONENTS = pointer Variates to save components of output series
SCORES = variate To save scores (derivatives of the log-likelihood with respect to the parameters)

Description

An TFIT statement produces many quantities that you may want to use to assess, interpret and apply the fitted model. The TKEEP directive allows you to copy these quantities into Genstat data structures. If the METHOD option of the TFIT statement was set to initialize, then the results saved by the options SE, INVERSE, VCOVARIANCE and SCORE are unavailable. However, you can save the estimates of the missing values and their standard errors. The residual degrees of freedom in this case does not make allowance for the number of parameters in the model, but does allow for the missing values that have been estimated.

The OUTPUTSERIES parameter specifies the variate that was supplied by the SERIES parameter of the TFIT statement; this can be omitted.

You can use the RESIDUALS parameter to save the residuals in a variate, exactly as in the TFIT directive.

The ESTIMATES parameter can supply a variate to store the estimated parameters of the TSM. Each estimated parameter is represented once, but the innovation variance is omitted entirely. Genstat includes only the first of any set of parameters constrained to be equal using the FIX option of TFIT. The order of the parameters otherwise corresponds to their order in the variate of parameters in TSM, and is unaffected by any numbering used in the FIX option.

The SE parameter allows you to specify a variate to save the standard errors of the estimated parameters of the TSM. The values correspond exactly to those in the ESTIMATES variate. Parameters in a time series model may be aliased. This is detected when the equations for the estimates are being solved, and the message ALIASED is printed instead of the standard error when the PRINT option of TFIT or TDISPLAY includes the setting estimates. The corresponding units of the SE variate are set to missing values.

The INVERSE parameter can provide a symmetric matrix to save the product (XX)-1, where X is the most recent design matrix derived from the linearized least-squares regressions that were used to minimize the deviance. The ordering of the rows and columns corresponds exactly to that used for the ESTIMATES variate. The row of this matrix corresponding to any aliased parameter is set to zero except that the diagonal element is set to the missing value.

The VCOVARIANCE parameter allows you to supply a symmetric matrix for the estimated variance-covariance matrix, a2(XX)-1, of the TSM parameters. The ordering of the rows and columns and the treatment of aliased parameters corresponds exactly to that used for the ESTIMATES variate.

The DEVIANCE parameter specifies a scalar to hold the final value of the deviance criterion defined by the LIKELIHOOD option of TFIT.

The DF parameter saves the residual number of degrees of freedom, defined for a simple ARIMA model by Nd-(number of estimated parameters). If a seasonal model is used, this number is further reduced by Ds.

The MVESTIMATES parameter specifies a variate to hold estimates of the missing values of the series, in the order they appear in the series. You can thereby obtain forecasts of the series, by extending the SERIES in TFIT with a set of missing values. This is less efficient than using the TFORECAST directive, but it does have the advantage that the standard errors of the estimates take into account the finite extent of the data, and also the fact that the model parameters are estimated.

The SEMV parameter can supply a variate to hold the estimated standard errors of the missing values of the series, in the order they appear in the series.

The COMPONENTS parameter can be used after a multi-input model has been fitted using TFIT to access the components of the output series that are due to the various input series; you can also access the output noise. In simple regression, the input components are proportional to the input series. But the component resulting from a transfer-function model may be quite different from this. You can examine these components separately, or sum them to show the total fit to the output series that is explained by the input series. Note that the fitted values may appear to be offset from that output series, because the constant term is part of the noise component, and so is not included. You may want to examine the output noise component. For example, if you thought that the ARIMA model for the output noise was inadequate, you could investigate the noise component with univariate ARIMA modelling.

The SCORE parameter can specify a variate to hold the model scores. The scores are usually defined as the first derivatives of the log likelihood with respect to the model parameters. To get these, the scores supplied by TKEEP should be scaled by dividing by the estimated residual variance and reversing its sign. The elements of the SCORE variate correspond exactly to the parameters as they appear in the ESTIMATES variate. After using TFIT to fit a time series model, the scores should in theory be zero provided the model parameters do not lie on the boundary of their allowed range. The scores are used within TFIT to calculate the parameter changes at each iteration.

You can use the SAVE option to specify the time-series save structure from which the output is to be taken. By default TKEEP uses the structure from the most recent TFIT statement.

Option: SAVE.

Parameters: OUTPUTSERIES, RESIDUALS, ESTIMATES, SE, INVERSE, VCOVARIANCE, DEVIANCE, DF, MVESTIMATES, SEMV, COMPONENTS, SCORES.

See also

Directives: TSM, FTSM, TDISPLAY, TFILTER, TFIT, TFORECAST, TRANSFERFUNCTION, TSUMMARIZE.

Procedures: BJESTIMATE, BJFORECAST, BJIDENTIFY.

Commands for: Time series.

Example

" Example TFIT-1: Fitting a seasonal ARIMA model"

VARIATE time; VALUES=!(1...120)
FILEREAD [NAME='%gendir%/examples/TFIT-1.DAT'] apt

" Display the correlation structure of the logged data"
CALCULATE lapt = LOG(apt)
BJIDENTIFY [GRAPHICS=high; WINDOWS=!(5,6,7,8)] lapt

" Calculate the autocorrelations of the differences and seasonally
  differenced series"
CALCULATE ddslapt = DIFFERENCE(DIFFERENCE(lapt; 12); 1)
CORRELATE [PRINT=auto; MAXLAG=48] ddslapt; AUTO=ddsr

" Define a model for the series: 
  IMA(1) (that is, a model with a single moving-average parameter
          applied to the differences of the series)
  plus a seasonal IMA(1) component"
TSM [MODELTYPE=arima] airpass; ORDERS=!((0,1,1)2,12)
" Form preliminary estimates of the parameters, using a log transformation
  (BOXCOX=0 is equivalent to log)"
FTSM [PRINT=model] airpass; ddsr; BOXCOX=0
" Get the best estimates, fixing the constant"
TFIT [CONSTANT=fix] SERIES=apt; TSM=airpass

" Graph the residuals against time"
TKEEP RESID=resids
DGRAPH [WINDOW=3; KEYWINDOW=0; TITLE='Residuals vs Time'] resids; time

" Test the independence of the residuals"
CORRELATE [GRAPH=auto; MAXLAG=48] resids; TEST=S
PRINT 'Test statistic for independence of the residuals',S
Updated on June 17, 2019

Was this article helpful?