SYNOPSIS [loglik,per,d] = kalman_filter(Z,H,T,R,Q,Y,a,P) [loglik,per,d] = kalman_filter(Z,H,T,R,Q,Y,a,P,flag) [loglik,per,d] = kalman_filter(Z,H,T,R,Q,Y,a,Pstar,Pinf) [loglik,per,d] = kalman_filter(Z,H,T,R,Q,Y,a,Pstar,Pinf,flag) SEMANTICS The first two commands run a Kalman filter for non-diffuse initial conditions, the other two for diffuse initial conditions. Input: Z,H,T,R,Q gives a state space form Y observed data (columns correspond to periods) a mean of initial state P covariance of initial non-diffuse state Pstar finite part of covariance of initial diffuse state Pinf infinite part of covariance of initial diffuse state flag string starting with 'u', or 'U' runs a univariate form of the filter; if omitted, a multivariate version is run by default Output: loglik data log likelihood per number of succesfully filtered periods; if no error then per equals to the number of columns of Y d number of initial periods for which the state is still diffuse (d is always 0 for non-diffuse case) Copyright 2005, Ondra Kamenik
0001 % 0002 % SYNOPSIS 0003 % 0004 % [loglik,per,d] = kalman_filter(Z,H,T,R,Q,Y,a,P) 0005 % [loglik,per,d] = kalman_filter(Z,H,T,R,Q,Y,a,P,flag) 0006 % [loglik,per,d] = kalman_filter(Z,H,T,R,Q,Y,a,Pstar,Pinf) 0007 % [loglik,per,d] = kalman_filter(Z,H,T,R,Q,Y,a,Pstar,Pinf,flag) 0008 % 0009 % SEMANTICS 0010 % 0011 % The first two commands run a Kalman filter for non-diffuse 0012 % initial conditions, the other two for diffuse initial conditions. 0013 % 0014 % Input: 0015 % Z,H,T,R,Q gives a state space form 0016 % Y observed data (columns correspond to periods) 0017 % a mean of initial state 0018 % P covariance of initial non-diffuse state 0019 % Pstar finite part of covariance of initial diffuse state 0020 % Pinf infinite part of covariance of initial diffuse state 0021 % flag string starting with 'u', or 'U' runs a univariate 0022 % form of the filter; if omitted, a multivariate version 0023 % is run by default 0024 % 0025 % Output: 0026 % loglik data log likelihood 0027 % per number of succesfully filtered periods; if no error 0028 % then per equals to the number of columns of Y 0029 % d number of initial periods for which the state is 0030 % still diffuse (d is always 0 for non-diffuse case) 0031 % 0032 % Copyright 2005, Ondra Kamenik 0033 % 0034 0035 function [loglik, per, d] = kalman_filter(varargin) 0036 0037 [loglik, per, d] = kalman_filter_(varargin{:});