Added texinfo header.
parent
e270c29bd9
commit
ffbb5bc765
|
@ -1,31 +1,61 @@
|
|||
function [LIK, lik, a] = kalman_filter_ss(Y,start,last,a,T,K,iF,dF,Z,pp,Zflag)
|
||||
% Computes the likelihood of a stationnary state space model (steady state kalman filter).
|
||||
%
|
||||
% INPUTS
|
||||
% Y [double] pp*smpl matrix of data.
|
||||
% start [integer] scalar, index of the first observation (column of Y).
|
||||
% last [integer] scalar, index of the last observation (column of Y).
|
||||
% a [double] mm*1 vector, initial level of the state vector.
|
||||
% P [double] mm*mm matrix, covariance matrix of the initial state vector.
|
||||
% T [double] mm*mm transition matrix of the state equation.
|
||||
% K [double] mm*pp matrix, steady state kalman gain.
|
||||
% iF [double] pp*pp matrix, inverse of the steady state covariance matrix of the predicted errors.
|
||||
% dF [double] scalar, determinant of the steady state covariance matrix of the predicted errors.
|
||||
% Z [integer] pp*1 vector of indices for the observed variables, if Zflag=0.
|
||||
% pp [integer] scalar, number of observed variables.
|
||||
%
|
||||
%
|
||||
% OUTPUTS
|
||||
% LIK [double] scalar, minus log likelihood.
|
||||
% lik [double] (last-start+1)*1 vector, density of each observation.
|
||||
% a [double] mm*1 vector, estimate of the state vector.
|
||||
%
|
||||
% NOTES
|
||||
% The vector "lik" is used to evaluate the jacobian of the likelihood.
|
||||
|
||||
%@info:
|
||||
%! @deftypefn {Function File} {[@var{LIK},@var{likk},@var{a},@var{P} ] =} DsgeLikelihood (@var{Y}, @var{start}, @var{last}, @var{a}, @var{P}, @var{kalman_tol}, @var{riccati_tol},@var{presample},@var{T},@var{Q},@var{R},@var{H},@var{Z},@var{mm},@var{pp},@var{rr},@var{Zflag},@var{diffuse_periods})
|
||||
%! @anchor{kalman_filter}
|
||||
%! @sp 1
|
||||
%! Computes the likelihood of a stationary state space model, given initial condition for the states (mean), the steady state kalman gain and the steady state inveverted covariance matrix of the prediction errors.
|
||||
%! @sp 2
|
||||
%! @strong{Inputs}
|
||||
%! @sp 1
|
||||
%! @table @ @var
|
||||
%! @item Y
|
||||
%! Matrix (@var{pp}*T) of doubles, data.
|
||||
%! @item start
|
||||
%! Integer scalar, first period.
|
||||
%! @item last
|
||||
%! Integer scalar, last period (@var{last}-@var{first} has to be inferior to T).
|
||||
%! @item a
|
||||
%! Vector (mm*1) of doubles, initial mean of the state vector.
|
||||
%! @item T
|
||||
%! Matrix (mm*mm) of doubles, transition matrix of the state equation.
|
||||
%! @item K
|
||||
%! Matrix (mm*@var{pp}) of doubles, steady state kalman gain.
|
||||
%! @item iF
|
||||
%! Matrix (@var{pp}*@var{pp}) of doubles, inverse of the steady state covariance matrix of the prediction errors.
|
||||
%! @item dF
|
||||
%! Double scalar, determinant of the steady state covariance matrix of teh prediction errors.
|
||||
%! @item Z
|
||||
%! Matrix (@var{pp}*mm) of doubles or vector of integers, matrix relating the states to the observed variables or vector of indices (depending on the value of @var{Zflag}).
|
||||
%! @item pp
|
||||
%! Integer scalar, number of observed variables.
|
||||
%! @item Zflag
|
||||
%! Integer scalar, equal to 0 if Z is a vector of indices targeting the obseved variables in the state vector, equal to 1 if Z is a @var{pp}*@var{mm} matrix.
|
||||
%! @end table
|
||||
%! @sp 2
|
||||
%! @strong{Outputs}
|
||||
%! @sp 1
|
||||
%! @table @ @var
|
||||
%! @item LIK
|
||||
%! Double scalar, value of (minus) the likelihood.
|
||||
%! @item likk
|
||||
%! Column vector of doubles, values of the density of each observation.
|
||||
%! @item a
|
||||
%! Vector (mm*1) of doubles, mean of the state vector at the end of the (sub)sample.
|
||||
%! @end table
|
||||
%! @sp 2
|
||||
%! @strong{This function is called by:}
|
||||
%! @sp 1
|
||||
%! @ref{kalman_filter}
|
||||
%! @sp 2
|
||||
%! @strong{This function calls:}
|
||||
%! @sp 1
|
||||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright (C) 2011 Dynare Team
|
||||
% stephane DOT adjemian AT ens DOT fr
|
||||
%
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
|
@ -41,6 +71,8 @@ function [LIK, lik, a] = kalman_filter_ss(Y,start,last,a,T,K,iF,dF,Z,pp,Zflag)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
% AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT fr
|
||||
|
||||
% Get sample size.
|
||||
smpl = last-start+1;
|
||||
|
||||
|
@ -66,5 +98,5 @@ lik = lik + log(dF);
|
|||
% Add log-likelihhod constants and divide by two
|
||||
lik = .5*(lik + pp*log(2*pi));
|
||||
|
||||
% Sum the observation's densities (minus the likelihood)
|
||||
% Sum the observation's densities (minus the likelihood)
|
||||
LIK = sum(lik);
|
Loading…
Reference in New Issue