P convergence likelihood bug fix
git-svn-id: https://www.dynare.org/svn/dynare/trunk@2824 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
181b268699
commit
f4c3482acd
|
@ -51,12 +51,10 @@ function [LIK, lik] = DiffuseLikelihood1(T,R,Q,Pinf,Pstar,Y,trend,start)
|
||||||
dF = 1;
|
dF = 1;
|
||||||
QQ = R*Q*transpose(R);
|
QQ = R*Q*transpose(R);
|
||||||
t = 0;
|
t = 0;
|
||||||
lik = zeros(smpl+1,1);
|
lik = zeros(smpl,1);
|
||||||
LIK = Inf;
|
LIK = Inf;
|
||||||
lik(smpl+1) = smpl*pp*log(2*pi);
|
|
||||||
notsteady = 1;
|
notsteady = 1;
|
||||||
crit = options_.kalman_tol;
|
crit = options_.kalman_tol;
|
||||||
reste = 0;
|
|
||||||
while rank(Pinf,crit) & t < smpl
|
while rank(Pinf,crit) & t < smpl
|
||||||
t = t+1;
|
t = t+1;
|
||||||
v = Y(:,t)-a(mf)-trend(:,t);
|
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' ...
|
error(['The variance of the forecast error remains singular until the' ...
|
||||||
'end of the sample'])
|
'end of the sample'])
|
||||||
end
|
end
|
||||||
reste = smpl-t;
|
if t < smpl
|
||||||
|
t0 = t+1;
|
||||||
while t < smpl
|
while t < smpl
|
||||||
t = t+1;
|
t = t+1;
|
||||||
v = Y(:,t)-a(mf)-trend(:,t);
|
v = Y(:,t)-a(mf)-trend(:,t);
|
||||||
a = T*(a+K*v);
|
a = T*(a+K*v);
|
||||||
lik(t) = transpose(v)*iF*v;
|
lik(t) = transpose(v)*iF*v;
|
||||||
end
|
end
|
||||||
lik(t) = lik(t) + reste*log(dF);
|
lik(t0:smpl) = lik(t0:smpl) + log(dF);
|
||||||
|
end
|
||||||
|
% adding log-likelihhod constants
|
||||||
|
lik = (lik + pp*log(2*pi))/2;
|
||||||
|
|
||||||
|
LIK = sum(lik(start:end)); % Minus the log-likelihood.
|
||||||
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);% Minus the log-likelihood.
|
|
|
@ -50,12 +50,10 @@ function [LIK, lik] = DiffuseLikelihood1_Z(T,Z,R,Q,Pinf,Pstar,Y,start)
|
||||||
dF = 1;
|
dF = 1;
|
||||||
QQ = R*Q*transpose(R);
|
QQ = R*Q*transpose(R);
|
||||||
t = 0;
|
t = 0;
|
||||||
lik = zeros(smpl+1,1);
|
lik = zeros(smpl,1);
|
||||||
LIK = Inf;
|
LIK = Inf;
|
||||||
lik(smpl+1) = smpl*pp*log(2*pi);
|
|
||||||
notsteady = 1;
|
notsteady = 1;
|
||||||
crit = options_.kalman_tol;
|
crit = options_.kalman_tol;
|
||||||
reste = 0;
|
|
||||||
while rank(Pinf,crit) & t < smpl
|
while rank(Pinf,crit) & t < smpl
|
||||||
t = t+1;
|
t = t+1;
|
||||||
v = Y(:,t)-Z*a;
|
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' ...
|
error(['The variance of the forecast error remains singular until the' ...
|
||||||
'end of the sample'])
|
'end of the sample'])
|
||||||
end
|
end
|
||||||
reste = smpl-t;
|
if t < smpl
|
||||||
|
t0 = t+1;
|
||||||
while t < smpl
|
while t < smpl
|
||||||
t = t+1;
|
t = t+1;
|
||||||
v = Y(:,t)-Z*a;
|
v = Y(:,t)-Z*a;
|
||||||
a = T*(a+K*v);
|
a = T*(a+K*v);
|
||||||
lik(t) = v'*iF*v;
|
lik(t) = v'*iF*v;
|
||||||
end
|
end
|
||||||
lik(t) = lik(t) + reste*log(dF);
|
lik(t0:smpl) = lik(t0:smpl) + log(dF);
|
||||||
|
end
|
||||||
|
% adding log-likelihhod constants
|
||||||
|
lik = (lik + pp*log(2*pi))/2;
|
||||||
|
|
||||||
|
LIK = sum(lik(start:end)); % Minus the log-likelihood.
|
||||||
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);% Minus the log-likelihood.
|
|
|
@ -52,12 +52,10 @@ function [LIK, lik] = DiffuseLikelihoodH1(T,R,Q,H,Pinf,Pstar,Y,trend,start)
|
||||||
dF = 1;
|
dF = 1;
|
||||||
QQ = R*Q*transpose(R);
|
QQ = R*Q*transpose(R);
|
||||||
t = 0;
|
t = 0;
|
||||||
lik = zeros(smpl+1,1);
|
lik = zeros(smpl,1);
|
||||||
LIK = Inf;
|
LIK = Inf;
|
||||||
lik(smpl+1) = smpl*pp*log(2*pi);
|
|
||||||
notsteady = 1;
|
notsteady = 1;
|
||||||
crit = options_.kalman_tol;
|
crit = options_.kalman_tol;
|
||||||
reste = 0;
|
|
||||||
while rank(Pinf,crit) & t < smpl
|
while rank(Pinf,crit) & t < smpl
|
||||||
t = t+1;
|
t = t+1;
|
||||||
v = Y(:,t)-a(mf)-trend(:,t);
|
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' ...
|
error(['The variance of the forecast error remains singular until the' ...
|
||||||
'end of the sample'])
|
'end of the sample'])
|
||||||
end
|
end
|
||||||
reste = smpl-t;
|
if t < smpl
|
||||||
|
t0 = t+1;
|
||||||
while t < smpl
|
while t < smpl
|
||||||
t = t+1;
|
t = t+1;
|
||||||
v = Y(:,t)-a(mf)-trend(:,t);
|
v = Y(:,t)-a(mf)-trend(:,t);
|
||||||
a = T*(a+K*v);
|
a = T*(a+K*v);
|
||||||
lik(t) = transpose(v)*iF*v;
|
lik(t) = transpose(v)*iF*v;
|
||||||
end
|
end
|
||||||
lik(t) = lik(t) + reste*log(dF);
|
lik(t0:smpl) = lik(t0:smpl) + log(dF);
|
||||||
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);% Minus the
|
end
|
||||||
% 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;
|
dF = 1;
|
||||||
QQ = R*Q*transpose(R);
|
QQ = R*Q*transpose(R);
|
||||||
t = 0;
|
t = 0;
|
||||||
lik = zeros(smpl+1,1);
|
lik = zeros(smpl,1);
|
||||||
LIK = Inf;
|
LIK = Inf;
|
||||||
lik(smpl+1) = smpl*pp*log(2*pi);
|
|
||||||
notsteady = 1;
|
notsteady = 1;
|
||||||
crit = options_.kalman_tol;
|
crit = options_.kalman_tol;
|
||||||
reste = 0;
|
|
||||||
while rank(Pinf,crit) & t < smpl
|
while rank(Pinf,crit) & t < smpl
|
||||||
t = t+1;
|
t = t+1;
|
||||||
v = Y(:,t)-Z*a;
|
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' ...
|
error(['The variance of the forecast error remains singular until the' ...
|
||||||
'end of the sample'])
|
'end of the sample'])
|
||||||
end
|
end
|
||||||
reste = smpl-t;
|
if t < smpl
|
||||||
|
t0 = t+1;
|
||||||
while t < smpl
|
while t < smpl
|
||||||
t = t+1;
|
t = t+1;
|
||||||
v = Y(:,t)-Z*a;
|
v = Y(:,t)-Z*a;
|
||||||
a = T*(a+K*v);
|
a = T*(a+K*v);
|
||||||
lik(t) = v'*iF*v;
|
lik(t) = v'*iF*v;
|
||||||
end
|
end
|
||||||
lik(t) = lik(t) + reste*log(dF);
|
lik(t0:smpl) = lik(t0:smpl) + log(dF);
|
||||||
|
end
|
||||||
|
% adding log-likelihhod constants
|
||||||
|
lik = (lik + pp*log(2*pi))/2;
|
||||||
|
|
||||||
|
LIK = sum(lik(start:end)); % Minus the log-likelihood.
|
||||||
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);% Minus the log-likelihood.
|
|
Loading…
Reference in New Issue