Commit c9d08951 authored by george's avatar george
Browse files

DsgeLikelihood_hh.m lik calculation compatibility and consistency changes

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2825 ac1d8469-bf42-47a9-8791-bf33cf982152
parent f4c3482a
......@@ -61,8 +61,7 @@ smpl = size(Y,2);
a = zeros(mm,1);
QQ = R*Q*transpose(R);
t = 0;
lik = zeros(smpl+1,1);
lik(smpl+1) = smpl*pp*log(2*pi); %% the constant of minus two times the log-likelihood
lik = zeros(smpl,1);
notsteady = 1;
crit = options_.kalman_tol;
crit1 = 1.e-6;
......@@ -190,5 +189,7 @@ while t < smpl
a = T*a;
end
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);
% adding log-likelihhod constants
lik = (lik + pp*log(2*pi))/2;
LIK = sum(lik(start:end)); % Minus the log-likelihood.
......@@ -60,8 +60,7 @@ smpl = size(Y,2);
a = zeros(mm,1);
QQ = R*Q*R';
t = 0;
lik = zeros(smpl+1,1);
lik(smpl+1) = smpl*pp*log(2*pi); %% the constant of minus two times the log-likelihood
lik = zeros(smpl,1);
notsteady = 1;
crit = options_.kalman_tol;
crit1 = 1.e-6;
......@@ -175,6 +174,7 @@ while t < smpl
end
a = T*a;
end
% adding log-likelihhod constants
lik = (lik + pp*log(2*pi))/2;
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);
LIK = sum(lik(start:end)); % Minus the log-likelihood.
......@@ -61,8 +61,7 @@ smpl = size(Y,2);
a = zeros(mm,1);
QQ = R*Q*transpose(R);
t = 0;
lik = zeros(smpl+1,1);
lik(smpl+1) = smpl*pp*log(2*pi); %% the constant of minus two times the log-likelihood
lik = zeros(smpl,1);
notsteady = 1;
crit = options_.kalman_tol;
crit1 = 1.e-6;
......@@ -173,5 +172,7 @@ while t < smpl
end
a = T*a;
end
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);
% adding log-likelihhod constants
lik = (lik + pp*log(2*pi))/2;
LIK = sum(lik(start:end)); % Minus the log-likelihood.
......@@ -61,8 +61,7 @@ smpl = size(Y,2);
a = zeros(mm,1);
QQ = R*Q*R';
t = 0;
lik = zeros(smpl+1,1);
lik(smpl+1) = smpl*pp*log(2*pi); %% the constant of minus two times the log-likelihood
lik = zeros(smpl,1);
notsteady = 1;
crit = options_.kalman_tol;
crit1 = 1.e-6;
......@@ -176,6 +175,8 @@ while t < smpl
end
a = T*a;
end
% adding log-likelihhod constants
lik = (lik + pp*log(2*pi))/2;
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);
LIK = sum(lik(start:end)); % Minus the log-likelihood.
function LIK = DiffuseLikelihoodH3corr(T,R,Q,H,Pinf,Pstar,Y,trend,start)
function [LIK lik] = DiffuseLikelihoodH3corr(T,R,Q,H,Pinf,Pstar,Y,trend,start)
% Same as DiffuseLikelihoodH3 but allows correlation between the measurement
% errors (this is not a problem with the multivariate approach).
......@@ -36,8 +36,7 @@ Pstar = cat(1,cat(2,Pstar,zeros(mm,pp)),cat(2,zeros(pp,mm),H));
a = zeros(mm+pp,1);
QQ = R*Q*transpose(R);
t = 0;
lik = zeros(smpl+1,1);
lik(smpl+1) = smpl*pp*log(2*pi); %% the constant of minus two times the log-likelihood
lik = zeros(smpl,1);
notsteady = 1;
crit = options_.kalman_tol;
newRank = rank(Pinf,crit);
......@@ -110,4 +109,7 @@ while t < smpl
end
a = T*a;
end
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);
\ No newline at end of file
% adding log-likelihhod constants
lik = (lik + pp*log(2*pi))/2;
LIK = sum(lik(start:end)); % Minus the log-likelihood.
......@@ -317,5 +317,5 @@ function [fval,llik,cost_flag,ys,trend_coeff,info] = DsgeLikelihood_hh(xparam1,g
lnprior = priordens(xparam1,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7,bayestopt_.p3,bayestopt_.p4);
fval = (likelihood-lnprior);
options_.kalman_algo = kalman_algo;
llik=[-lnprior; .5*lik(start:end)];
llik=[-lnprior; lik(start:end)];
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment