Library: | kalman |
See also: | gkalarray gkalfilter gkalsmoother gkalresiduals |
Quantlet: | gkallag | |
Description: | Calculates covariance matrices for the smoothed series of a state space model (uni- or multivariate) with one lag. The quantlet gkallag needs a pre-run of gkalfilter. The state space model has the form (for the notation, see Harvey 1989): State equation alpha_t = c_t + T_t alpha_t-1 + e^s_t Measurement equation y_t = d_t + Z_t alpha_t + e^m_t with alpha_0 ~ (mu,Sig), e^s_t ~ (0,R_t), e^m_t ~ (0,H_t) All parameters are known. We denote with Ps_(t,t-1|T) the covariance matrices of the filtered series. The output of the procedure is an array Ps_(t,t-1|T) for all t. |
Usage: | gkallagout = gkallag(Y, Ta, Z, Ra, H, Pa) | |
Input: | ||
Y | N_max x TIME matrix | |
Ta | K x K x TIME array with observations T_t | |
Z | N_max x K system matrix Z_T | |
Ra | K x K x TIME array with covariance matrices R_t | |
H | N_max x N_max covariance matrix H_T | |
Pa | K x K x (TIME+1) array of covariance matrices P_t, output of gkalfilter | |
Output: | ||
gkallagOut | K x K x TIME array of covariance matrices for smoothed state space series P_(t,t-1|T). The first entry is Ps_(1,0|T). |
library("kalman") library("xplore") ; loads the quantlets from xplore library Pa = read("housePa.dat") dimPa = read("housedimPa.dat") Pa = reshape(Pa',dimPa) Y = read("houseprice.dat") T =(#(1.4,1)'|#(-0.4,0)')~0*matrix(2,3)|(0*matrix(3,2)~unit(3)) Ta = gkalarray(Y,T,0,0) Ra = gkalarray(Y,diag(#(0.4,0,0,0,0)),0,0) Z = matrix(3)~0*matrix(3,4) IZ = 0*matrix(3,2)~(#(1:3)'|#(4:6)'|#(7:9)') XZ = read("housequality.dat") Za = gkalarray(Y,Z,IZ,XZ) H = 2*unit(3) gkallagOut = gkallag(Y,Ta,Za[,,100],Ra,H,Pa) gkallagOut[,,5]
Array with the covariance matrices for the smoothed series at t and t-1.