Language Reference |
KALCVS Call |
The KALCVS subroutine uses backward recursions to compute the smoothed estimate and its covariance matrix, , where is the number of observations in the complete data set.
The input arguments to the KALCVS subroutine are as follows.
is a matrix that contains data .
is an vector for a time-invariant input vector in the transition equation, or a vector that contains input vectors in the transition equation.
is an matrix for a time-invariant transition matrix in the transition equation, or a matrix that contains transition matrices.
is an vector for a time-invariant input vector in the measurement equation, or a vector that contains input vectors in the measurement equation.
is an matrix for a time-invariant measurement matrix in the measurement equation, or a matrix that contains time-variant matrices in the measurement equation.
is an covariance matrix for the errors in the transition and the measurement equations, or a matrix that contains covariance matrices in the transition equation and measurement equation noises—that is, .
is a matrix that contains one-step forecasts .
is a matrix that contains mean square error matrices of predicted state vectors .
is an optional vector that contains . The returned value is .
is an optional matrix that contains . The returned value is .
The KALCVS call returns the following values:
is a matrix that contains smoothed state vectors .
is a matrix that contains covariance matrices of smoothed state vectors .
When the Kalman filtering is performed in the KALCVF call, the KALCVS call computes smoothed state vectors and their covariance matrices. The fixed-interval smoothing state vector at time is obtained by the conditional expectation given all observations.
The smoothing algorithm uses one-step forecasts and their covariance matrices, which are given in the KALCVF call. For notation, is the smoothed value of the state vector , and the mean square error matrix is denoted . For smoothing,
where . The initial values are and .
When the SSM is specified by using the alternative transition equation
the fixed-interval smoothing is performed by using the following backward recursions:
where it is assumed that .
You can use the KALCVS call regardless of the specification of the transition equation when . Harvey (1989) gives the following fixed-interval smoothing formula, which produces the same smoothed value:
where
under the shifted transition equation, but
under the alternative transition equation.
The KALCVS call is accompanied by the KALCVF call, as shown in the following statements. Note that you do not need to specify UN and VUN.
call kalcvf(pred, vpred, filt, vfilt, y, 0, a, f, b, h, var); call kalcvs(sm, vsm, y, a, f, b, h, var, pred, vpred);
You can also compute the smoothed estimate and its covariance matrix on an observation-by-observation basis. When the SSM is time invariant, the following example performs smoothing. In this situation, you should initialize UN and VUN as matrices of value 0, as shown in the following statements:
call kalcvf(pred, vpred, filt, vfilt, y, 0, a, f, b, h, var); n = nrow(y); nz = ncol(f); un = j(1, nz, 0); vun = j(nz, nz, 0); do i = 1 to n; y_i = y[n-i+1,]; pred_i = pred[n-i+1,]; vpred_i = vpred[(n-i)*nz+1:(n-i+1)*nz,]; call kalcvs(sm_i, vsm_i, y_i, a, f, b, h, var, pred_i, vpred_i, un, vun); sm = sm_i // sm; vsm = vsm_i // vsm; end;
The KALCVF call has an example program that includes the KALCVS call.
Copyright © SAS Institute, Inc. All Rights Reserved.