Language Reference

KALCVF Call

computes the one-step prediction {z}_{t+1| t} and the filtered estimate {z}_{t| t}, as well as their covariance matrices. The call uses forward recursions, and you can also use it to obtain k-step estimates.

CALL KALCVF( pred, vpred, filt, vfilt, data, lead, a, f, b, h,
           var <, z0, vz0>);


The inputs to the KALCVF subroutine are as follows:
data
is a t x n_y matrix containing data ({y}_1,  ... , {y}_t)^'.

lead
is the number of steps to forecast after the end of the data.

a
is an n_z x 1 vector for a time-invariant input vector in the transition equation, or a (t+{lead})n_z x 1 vector containing input vectors in the transition equation.

f
is an n_z x n_z matrix for a time-invariant transition matrix in the transition equation, or a (t+{lead})n_z x n_z matrix containing transition matrices in the transition equation.

b
is an n_y x 1 vector for a time-invariant input vector in the measurement equation, or a (t+{lead})n_y x 1 vector containing input vectors in the measurement equation.

h
is an n_y x n_z matrix for a time-invariant measurement matrix in the measurement equation, or a (t+{lead})n_y x n_z matrix containing measurement matrices in the measurement equation.

var
is an (n_y + n_z) x (n_y + n_z) matrix for a time-invariant variance matrix for the error in the transition equation and the error in the measurement equation, or a (t+{lead})(n_y + n_z) x (n_y + n_z) matrix containing variance matrices for the error in the transition equation and the error in the measurement equation - that is, (\eta^'_t, \epsilon^'_t)^'.

z0
is an optional 1 x n_z initial state vector {z}^'_{1|}.

vz0
is an optional n_z x n_z covariance matrix of an initial state vector {p}_{1|}.
The KALCVF call returns the following values:
pred
is a (t+{lead}) x n_z matrix containing one-step predicted state vectors ({z}_{1|}, ... , {z}_{t+1| t},   {z}_{t+2| t},  ... , {z}_{t+{lead}| t})^'.

vpred
is a (t+{lead})n_z x n_z matrix containing mean square errors of predicted state vectors ({p}_{1|},  ... , {p}_{t+1| t}, {p}_{t+2| t},    ... , {p}_{t+{lead}| t})^'.

filt
is a t x n_z matrix containing filtered state vectors ({z}_{1| 1},  ... , {z}_{t| t})^'.

vfilt
is a tn_z x n_z matrix containing mean square errors of filtered state vectors ({p}_{1| 1},  ... , {p}_{t| t})^'.
The KALCVF call computes the conditional expectation of the state vector {z}_t given the observations, assuming that the mean and the variance of the initial state vector are known. The filtered value is the conditional expectation of the state vector {z}_t given the observations up to time t. For k-step forecasting where k\gt, the conditional expectation at time t+k is computed given observations up to t. For notation, {v}_t and {{r}}_t are variances of \eta_t and {\epsilon}_t, respectively, and {g}_t is a covariance of \eta_t and {\epsilon}_t. {a}^- stands for the generalized inverse of {a}. The filtered value and its covariance matrix are denoted {z}_{t| t} and {p}_{t| t}, respectively. For k\gt, {z}_{t+k| t} and {p}_{t+k| t} stand for the k-step forecast of {z}_{t+k} and its mean square error. The Kalman filtering algorithm for one-step prediction and filtering is given as follows:
\hat{\epsilon}_t & = & {y}_t - {b}_t - {h}_t {z}_{t| t-1} \    {d}_t & = & {h}_t ...   ...    {p}_{t+1| t} & = & {f}_t {p}_{t| t-1}{f}^'_t + {v}_t -    {k}_t {d}_t {k}^'_t
And for k-step forecasting for k\gt 1,
{z}_{t+k| t} & = & {a}_{t+k-1} + {f}_{t+k-1} {z}_{t+k-1| t} \    {p}_{t+k| t} & = & {f}_{t+k-1} {p}_{t+k-1| t}    {f}^'_{t+k-1} + {v}_{t+k-1}
When you use the alternative transition equation
{z}_t = {a}_t + {f}_t{z}_{t-1} + \eta_t
the forward recursion algorithm is written
\hat{\epsilon}_t & = & {y}_t - {b}_t - {h}_t{z}_{t| t-1} \    {d}_t & = & {h}_t {...   ... t} & = & {f}_{t+1} {p}_{t| t-1}{f}^'_{t+1} +    {v}_{t+1} - {k}_t {d}_t {k}^'_t
And for k-step forecasting (k\gt 1),
{z}_{t+k| t} & = & {a}_{t+k} + {f}_{t+k}{z}_{t+k-1| t} \    {p}_{t+k| t} & = & {f}_{t+k} {p}_{t+k-1| t} {f}^'_{t+k} +    {v}_{t+k}
You can use the KALCVF call when you specify the alternative transition equation and {g}_t = 0.

The initial state vector and its covariance matrix of the time invariant Kalman filters are computed under the stationarity condition
{z}_{1|} & = & ({i}- {f})^- {a}\    {p}_{1|} & = & ({i}- {f}\otimes {f})^- {vec}({v})
where {f} and {v} are the time-invariant transition matrix and the covariance matrix of transition equation noise, and vec({v}) is an n_z^2 x 1 column vector that is constructed by the stacking n_z columns of matrix {v}. Note that all eigenvalues of the matrix {f} are inside the unit circle when the SSM is stationary. When the preceding formula cannot be applied, the initial state vector estimate {z}_{1|} is set to {a}_1 and its covariance matrix {p}_{1|} is given by 10^6I. Optionally, you can specify initial values.

The KALCVF call accepts missing values in observations. If there is a missing observation, the filtered state vector for the missing observation is given by the one-step forecast.

The following program gives an example of the KALCVF call:

  
    q=2; 
    p=2; 
    n=10; 
    lead=3; 
  
    total=n+lead; 
  
    seed = 25735; 
    x=round(10*normal(j(n,p,seed)))/10; 
    f=round(10*normal(j(q*total,q,seed)))/10; 
    a=round(10*normal(j(total*q,1,seed)))/10; 
    h=round(10*normal(j(p*total,q,seed)))/10; 
    b=round(10*normal(j(p*total,1,seed)))/10; 
    do i = 1 to total; 
    temp=round(10*normal(j(p+q,p+q,seed)))/10; 
    var=var//(temp*temp`); 
    end; 
  
    call kalcvf(pred,vpred,filt,vfilt,x,lead,a,f,b,h,var); 
  
    /* default initial state and covariance */ 
    call kalcvs(sm,vsm,x,a,f,b,h,var,pred,vpred); 
    print sm [format=9.4] vsm [format=9.4];
 

This program produces the following output:

  
                SM                 VSM 
  
           -1.5236   -0.1000    1.5813   -0.4779 
            0.3058   -0.1131   -0.4779    0.3963 
           -0.2593    0.2496    2.4629    0.2426 
           -0.5533    0.0332    0.2426    0.0944 
           -0.5813    0.1251    0.2023   -0.0228 
           -0.3017    0.7480   -0.0228    0.5799 
            1.1333   -0.2144    0.8615   -0.7653 
            1.5193   -0.6237   -0.7653    1.2334 
           -0.6641   -0.7770    1.0836    0.8706 
            0.5994    2.3333    0.8706    1.5252 
                                0.3677    0.2510 
                                0.2510    0.2051 
                                0.3243   -0.4093 
                               -0.4093    1.2287 
                                0.1736   -0.0712 
                               -0.0712    0.9048 
                                1.3153    0.8748 
                                0.8748    1.6575 
                                8.6650    0.1841 
                                0.1841    4.4770
 

Previous Page | Next Page | Top of Page