Commit f4c3482a authored by george's avatar george
Browse files

P convergence likelihood bug fix

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2824 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 181b2686
......@@ -51,12 +51,10 @@ function [LIK, lik] = DiffuseLikelihood1(T,R,Q,Pinf,Pstar,Y,trend,start)
dF = 1;
QQ = R*Q*transpose(R);
t = 0;
lik = zeros(smpl+1,1);
lik = zeros(smpl,1);
LIK = Inf;
lik(smpl+1) = smpl*pp*log(2*pi);
notsteady = 1;
crit = options_.kalman_tol;
reste = 0;
while rank(Pinf,crit) & t < smpl
t = t+1;
v = Y(:,t)-a(mf)-trend(:,t);
......@@ -116,14 +114,17 @@ function [LIK, lik] = DiffuseLikelihood1(T,R,Q,Pinf,Pstar,Y,trend,start)
error(['The variance of the forecast error remains singular until the' ...
'end of the sample'])
end
reste = smpl-t;
while t < smpl
t = t+1;
v = Y(:,t)-a(mf)-trend(:,t);
a = T*(a+K*v);
lik(t) = transpose(v)*iF*v;
end
lik(t) = lik(t) + reste*log(dF);
if t < smpl
t0 = t+1;
while t < smpl
t = t+1;
v = Y(:,t)-a(mf)-trend(:,t);
a = T*(a+K*v);
lik(t) = transpose(v)*iF*v;
end
lik(t0:smpl) = lik(t0:smpl) + log(dF);
end
% adding log-likelihhod constants
lik = (lik + pp*log(2*pi))/2;
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);% Minus the log-likelihood.
LIK = sum(lik(start:end)); % Minus the log-likelihood.
\ No newline at end of file
......@@ -50,12 +50,10 @@ function [LIK, lik] = DiffuseLikelihood1_Z(T,Z,R,Q,Pinf,Pstar,Y,start)
dF = 1;
QQ = R*Q*transpose(R);
t = 0;
lik = zeros(smpl+1,1);
lik = zeros(smpl,1);
LIK = Inf;
lik(smpl+1) = smpl*pp*log(2*pi);
notsteady = 1;
crit = options_.kalman_tol;
reste = 0;
while rank(Pinf,crit) & t < smpl
t = t+1;
v = Y(:,t)-Z*a;
......@@ -116,14 +114,17 @@ function [LIK, lik] = DiffuseLikelihood1_Z(T,Z,R,Q,Pinf,Pstar,Y,start)
error(['The variance of the forecast error remains singular until the' ...
'end of the sample'])
end
reste = smpl-t;
while t < smpl
t = t+1;
v = Y(:,t)-Z*a;
a = T*(a+K*v);
lik(t) = v'*iF*v;
if t < smpl
t0 = t+1;
while t < smpl
t = t+1;
v = Y(:,t)-Z*a;
a = T*(a+K*v);
lik(t) = v'*iF*v;
end
lik(t0:smpl) = lik(t0:smpl) + log(dF);
end
lik(t) = lik(t) + reste*log(dF);
% adding log-likelihhod constants
lik = (lik + pp*log(2*pi))/2;
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);% Minus the log-likelihood.
LIK = sum(lik(start:end)); % Minus the log-likelihood.
\ No newline at end of file
......@@ -52,12 +52,10 @@ function [LIK, lik] = DiffuseLikelihoodH1(T,R,Q,H,Pinf,Pstar,Y,trend,start)
dF = 1;
QQ = R*Q*transpose(R);
t = 0;
lik = zeros(smpl+1,1);
lik = zeros(smpl,1);
LIK = Inf;
lik(smpl+1) = smpl*pp*log(2*pi);
notsteady = 1;
crit = options_.kalman_tol;
reste = 0;
while rank(Pinf,crit) & t < smpl
t = t+1;
v = Y(:,t)-a(mf)-trend(:,t);
......@@ -117,14 +115,17 @@ function [LIK, lik] = DiffuseLikelihoodH1(T,R,Q,H,Pinf,Pstar,Y,trend,start)
error(['The variance of the forecast error remains singular until the' ...
'end of the sample'])
end
reste = smpl-t;
while t < smpl
t = t+1;
v = Y(:,t)-a(mf)-trend(:,t);
a = T*(a+K*v);
lik(t) = transpose(v)*iF*v;
if t < smpl
t0 = t+1;
while t < smpl
t = t+1;
v = Y(:,t)-a(mf)-trend(:,t);
a = T*(a+K*v);
lik(t) = transpose(v)*iF*v;
end
lik(t0:smpl) = lik(t0:smpl) + log(dF);
end
lik(t) = lik(t) + reste*log(dF);
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);% Minus the
% log-likelihood.
% adding log-likelihhod constants
lik = (lik + pp*log(2*pi))/2;
LIK = sum(lik(start:end)); % Minus the log-likelihood.
......@@ -52,12 +52,10 @@ function [LIK, lik] = DiffuseLikelihoodH1_Z(T,Z,R,Q,H,Pinf,Pstar,Y,start)
dF = 1;
QQ = R*Q*transpose(R);
t = 0;
lik = zeros(smpl+1,1);
lik = zeros(smpl,1);
LIK = Inf;
lik(smpl+1) = smpl*pp*log(2*pi);
notsteady = 1;
crit = options_.kalman_tol;
reste = 0;
while rank(Pinf,crit) & t < smpl
t = t+1;
v = Y(:,t)-Z*a;
......@@ -118,14 +116,17 @@ function [LIK, lik] = DiffuseLikelihoodH1_Z(T,Z,R,Q,H,Pinf,Pstar,Y,start)
error(['The variance of the forecast error remains singular until the' ...
'end of the sample'])
end
reste = smpl-t;
while t < smpl
t = t+1;
v = Y(:,t)-Z*a;
a = T*(a+K*v);
lik(t) = v'*iF*v;
if t < smpl
t0 = t+1;
while t < smpl
t = t+1;
v = Y(:,t)-Z*a;
a = T*(a+K*v);
lik(t) = v'*iF*v;
end
lik(t0:smpl) = lik(t0:smpl) + log(dF);
end
lik(t) = lik(t) + reste*log(dF);
% adding log-likelihhod constants
lik = (lik + pp*log(2*pi))/2;
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);% Minus the log-likelihood.
LIK = sum(lik(start:end)); % Minus the log-likelihood.
\ 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