v4: reduced state space for likelihood computation
git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@781 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
ac5a09a233
commit
21f989819e
|
@ -70,7 +70,7 @@ function [LIK, lik] = DiffuseLikelihood1(T,R,Q,Pinf,Pstar,Y,trend,start)
|
|||
lik(t) = log(dF)+transpose(v)*iF*v;
|
||||
K = Pstar(:,mf)*iF; %% premultiplication by the transition matrix T is removed (stephane)
|
||||
a = T*(a+K*v); %% --> factorization of the transition matrix...
|
||||
Pstar = T*(Pstar-Pstar(:,mf)*iF*Pstar(mf,:))*transpose(T)+QQ; %% ... idem (stephane)
|
||||
Pstar = T*(Pstar-K*Pstar(mf,:))*transpose(T)+QQ; %% ... idem (stephane)
|
||||
end
|
||||
notsteady = ~(max(max(abs(Pstar-oldPstar)))<crit);
|
||||
end
|
||||
|
|
|
@ -141,7 +141,7 @@ function [LIK, lik] = DiffuseLikelihoodH1(T,R,Q,H,Pinf,Pstar,Y,trend,start)
|
|||
lik(t) = log(dF)+transpose(v)*iF*v;
|
||||
K = Pstar(:,mf)*iF; %% premultiplication by the transition matrix T is removed (stephane)
|
||||
a = T*(a+K*v); %% --> factorization of the transition matrix...
|
||||
Pstar = T*(Pstar-Pstar(:,mf)*iF*Pstar(mf,:))*transpose(T)+QQ; %% ... idem (stephane)
|
||||
Pstar = T*(Pstar-K*Pstar(mf,:))*transpose(T)+QQ; %% ... idem (stephane)
|
||||
end
|
||||
notsteady = ~(max(max(abs(Pstar-oldPstar)))<crit);
|
||||
end
|
||||
|
|
|
@ -87,6 +87,7 @@ function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data
|
|||
% 2. call model setup & reduction program
|
||||
%------------------------------------------------------------------------------
|
||||
[T,R,SteadyState,info] = dynare_resolve;
|
||||
rs = bayestopt_.restrict_state;
|
||||
if info(1) == 1 | info(1) == 2 | info(1) == 5
|
||||
fval = bayestopt_.penalty+1;
|
||||
cost_flag = 0;
|
||||
|
@ -96,6 +97,9 @@ function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data
|
|||
cost_flag = 0;
|
||||
return
|
||||
end
|
||||
T = T(rs,rs);
|
||||
R = R(rs,:);
|
||||
bayestopt_.mf = bayestopt_.mf1;
|
||||
if options_.loglinear == 1
|
||||
constant = log(SteadyState(bayestopt_.mfys));
|
||||
else
|
||||
|
|
|
@ -16,6 +16,7 @@ function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoo
|
|||
% 2. call model setup & reduction program
|
||||
%------------------------------------------------------------------------------
|
||||
[T,R,SteadyState] = dynare_resolve;
|
||||
bayestopt_.mf = bayestopt_.mf2;
|
||||
if options_.loglinear == 1
|
||||
constant = log(SteadyState(bayestopt_.mfys));
|
||||
else
|
||||
|
|
|
@ -200,8 +200,20 @@ for i=1:n_varobs
|
|||
k = [k strmatch(deblank(options_.varobs(i,:)),M_.endo_names(dr.order_var,:),'exact')];
|
||||
k1 = [k1 strmatch(deblank(options_.varobs(i,:)),M_.endo_names, 'exact')];
|
||||
end
|
||||
% union of observed and state variables
|
||||
k2 = union(k',[dr.nstatic+1:dr.nstatic+dr.npred]');
|
||||
% including variables in t-2 and earlier, if any
|
||||
k2 = [k2;[M_.endo_nbr+(1:dr.nspred-dr.npred)]'];
|
||||
|
||||
bayestopt_.mf = k;
|
||||
% set restrict_state to postion of observed + state variables
|
||||
% in expanded state vector
|
||||
bayestopt_.restrict_state = k2;
|
||||
% set mf1 to positions of observed variables in restricted state vector
|
||||
% for likelihood computation
|
||||
[junk,bayestopt_.mf1] = ismember(k,k2);
|
||||
% set mf2 to positions of observed variables in expanded state vector
|
||||
% for filtering and smoothing
|
||||
bayestopt_.mf2 = k;
|
||||
bayestopt_.mfys = k1;
|
||||
options_ = set_default_option(options_,'nobs',size(rawdata,1)-options_.first_obs+1);
|
||||
gend = options_.nobs;
|
||||
|
|
|
@ -78,7 +78,7 @@ dr.kad = kad;
|
|||
dr.kae = kae;
|
||||
dr.nboth = nboth;
|
||||
dr.nfwrd = nfwrd;
|
||||
|
||||
% 06/01/03 MJ removed negative entries for kstate(:,3) when lags on more
|
||||
% than 1 period
|
||||
% 06/25/03 MJ corrected logic for kmask computation when M_.maximum_lead == 0
|
||||
% number of forward variables in the state vector
|
||||
dr.nsfwrd = sum(kstate(:,2) > M_.maximum_lag+1);
|
||||
% number of predetermined variables in the state vector
|
||||
dr.nspred = sum(kstate(:,2) <= M_.maximum_lag+1);
|
||||
|
|
Loading…
Reference in New Issue