Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Language Reference

KALCVS Call

CALL KALCVS( sm, vsm, data, a, f, b, h, var, pred, vpred <,un, vun>);
The KALCVS call uses backward recursions to compute the smoothed estimate z_{t| T} and its covariance matrix, P_{t| T}, where T is the number of observations in the complete data set.

The inputs to the KALCVS subroutine are as follows:
data
is a T ×Ny matrix containing data (y1, ... , yT)'.

a
is an Nz ×1 vector for a time-invariant input vector in the transition equation, or a TNz ×1 vector containing input vectors in the transition equation.

f
is an Nz ×Nz matrix for a time-invariant transition matrix in the transition equation, or a TNz ×Nz matrix containing T transition matrices.

b
is an Ny ×1 vector for a time-invariant input vector in the measurement equation, or a TNy ×1 vector containing input vectors in the measurement equation.

h
is an Ny ×Nz matrix for a time-invariant measurement matrix in the measurement equation, or a TNy ×Nz matrix containing T time variant Ht matrices in the measurement equation.

var
is an (Ny + Nz) ×(Ny + Nz) covariance matrix for the errors in the transition and the measurement equations, or a T(Ny + Nz) ×(Ny + Nz) matrix containing covariance matrices in the transition equation and measurement equation noises, that is, (\eta^'_t, \epsilon^'_t)^'.

pred
is a T ×Nz matrix containing one-step forecasts (z_{1|},  ... , z_{T| T-1})^'.

vpred
is a TNz ×Nz matrix containing mean square error matrices of predicted state vectors (P_{1|},  ... , P_{T| T-1})^'.

un
is an optional 1 ×Nz vector containing {\mu}_T.The returned value is {\mu}_0.

vun
is an optional Nz ×Nz matrix containing UT. The returned value is U0.
The KALCVS call returns the following values:
sm
is a T ×Nz matrix containing smoothed state vectors (z_{1| T},  ... , z_{T| T})^'.

vsm
is a TNz ×Nz matrix containing covariance matrices of smoothed state vectors (P_{1| T},  ... , P_{T| T})^'.
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 t 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, z_{t| T} is the smoothed value of the state vector zt, and the mean square error matrix is denoted P_{t| T}.For smoothing,
\hat{\epsilon}_t & = & y_t - b_t - H_t z_{t| t-1} \ 
D_t & = & H_t P_{t| t-1} H^...
 ... t-1} {\mu}_{t-1} \ 
P_{t| T} & = & P_{t| t-1} - P_{t| t-1} U_{t-1} 
 P_{t| t-1}
where t = T, T-1, ... , 1. The initial values are {\mu}_T = 0 and UT = 0.

When the SSM is specified using the alternative transition equation
z_t = a_t + F_t{z}_{t-1} + \eta_t
the fixed-interval smoothing is performed using the following backward recursions:
\hat{\epsilon}_t & = & y_t - b_t - H_t z_{t| t-1} \ 
D_t & = & H_t P_{t| t-1} H^...
 ...-1} 
 {\mu}_{t-1} \ 
P_{t| T} & = & P_{t| t-1} - P_{t| t-1} U_{t-1} 
 P_{t| t-1}
where it is assumed that Gt = 0. You can use the KALCVS call regardless of the specification of the transition equation when Gt = 0. Harvey (1989) gives the following fixed-interval smoothing formula, which produces the same smoothed value:
z_{t| T} & = & z_{t| t} + P^*_t (z_{t+1| T} - z_{t+1| t}) \ 
P_{t| T} & = & P_{t| t} + P^*_t (P_{t+1| T} - P_{t+1| t}) P^{*'_t
where
P^*_t = P_{t| t} F^'_t P^-_{t+1| t}
under the shifted transition equation, but
P^*_t = P_{t| t} F^'_{t+1} P_{t+1| t}^-
under the alternative transition equation.

The KALCVS call is accompanied by the KALCVF call, as shown in the following code. 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.
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;

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.