Chapter Contents |
Previous |
Next |

Language Reference |

**CALL KALCVS(***sm, vsm, data,**a*,*f*,*b*,*h*, var, pred, vpred <,un, vun>**);**

The inputs to the KALCVS subroutine are as follows:

*data*- is a
*T*×*N*_{y}matrix containing data (**y**_{1}, ... ,**y**_{T})'. *a*- is an
*N*_{z}×1 vector for a time-invariant input vector in the transition equation, or a*TN*_{z}×1 vector containing input vectors in the transition equation. *f*- is an
*N*_{z}×*N*_{z}matrix for a time-invariant transition matrix in the transition equation, or a*TN*_{z}×*N*_{z}matrix containing*T*transition matrices. *b*- is an
*N*_{y}×1 vector for a time-invariant input vector in the measurement equation, or a*TN*_{y}×1 vector containing input vectors in the measurement equation. *h*- is an
*N*_{y}×*N*_{z}matrix for a time-invariant measurement matrix in the measurement equation, or a*TN*_{y}×*N*_{z}matrix containing*T*time variant**H**_{t}matrices in the measurement equation. *var*- is an (
*N*_{y}+*N*_{z}) ×(*N*_{y}+*N*_{z}) covariance matrix for the errors in the transition and the measurement equations, or a*T*(*N*_{y}+*N*_{z}) ×(*N*_{y}+*N*_{z}) matrix containing covariance matrices in the transition equation and measurement equation noises, that is, . *pred*- is a
*T*×*N*_{z}matrix containing one-step forecasts . *vpred*- is a
*TN*_{z}×*N*_{z}matrix containing mean square error matrices of predicted state vectors . *un*- is an optional 1 ×
*N*_{z}vector containing .The returned value is . *vun*- is an optional
*N*_{z}×*N*_{z}matrix containing**U**_{T}. The returned value is**U**_{0}.

*sm*- is a
*T*×*N*_{z}matrix containing smoothed state vectors . *vsm*- is a
*TN*_{z}×*N*_{z}matrix containing covariance matrices of smoothed state vectors .

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

When the SSM is specified using 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 |
Previous |
Next |
Top |

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