Remove oo_.dr.{nstatic,npred,nboth,nfwrd,nspred,nsfwrd}
Replace them by equivalents in M_ (and an extra one: M_.dynamic). IMPORTANT POINT: oo_.dr.npred used to count both purely backward and mixed/both variables. This was the cause of lots of confusion. The new M_.npred only counts purely backward variables. We now have the following indentities: M_.npred + M_.nboth + M_.nfwrd + M_.nstatic = M_.endo_nbr M_.nspred = M_.npred + M_.nboth M_.nsfwrd = M_.nfwrd + M_.nboth M_.ndynamic = M_.npred + M_.nboth + M_.nfwrdtime-shift
parent
92727ed75c
commit
c121aa14b1
|
@ -3387,32 +3387,31 @@ Dynare distinguishes four types of endogenous variables:
|
|||
@table @emph
|
||||
|
||||
@item Purely backward (or purely predetermined) variables
|
||||
@vindex oo_.dr.npred
|
||||
@vindex oo_.dr.nboth
|
||||
@vindex M_.npred
|
||||
Those that appear only at current and past period in the model, but
|
||||
not at future period (@i{i.e.} at @math{t} and @math{t-1} but not
|
||||
@math{t+1}). The number of such variables is equal to
|
||||
@code{oo_.dr.npred - oo_.dr.nboth}.
|
||||
@code{M_.npred}.
|
||||
|
||||
@item Purely forward variables
|
||||
@vindex oo_.dr.nfwrd
|
||||
@vindex M_.nfwrd
|
||||
Those that appear only at current and future period in the model, but
|
||||
not at past period (@i{i.e.} at @math{t} and @math{t+1} but not
|
||||
@math{t-1}). The number of such variables is stored in
|
||||
@code{oo_.dr.nfwrd}.
|
||||
@code{M_.nfwrd}.
|
||||
|
||||
@item Mixed variables
|
||||
@vindex oo_.dr.nboth
|
||||
@vindex M_.nboth
|
||||
Those that appear at current, past and future period in the model
|
||||
(@i{i.e.} at @math{t}, @math{t+1} and @math{t-1}). The number of such
|
||||
variables is stored in @code{oo_.dr.nboth}.
|
||||
variables is stored in @code{M_.nboth}.
|
||||
|
||||
@item Static variables
|
||||
@vindex oo_.dr.nstatic
|
||||
@vindex M_.nstatic
|
||||
Those that appear only at current, not past and future period in the
|
||||
model (@i{i.e.} only at @math{t}, not at @math{t+1} or
|
||||
@math{t-1}). The number of such variables is stored in
|
||||
@code{oo_.dr.nstatic}.
|
||||
@code{M_.nstatic}.
|
||||
@end table
|
||||
|
||||
Note that all endogenous variables fall into one of these four
|
||||
|
@ -3421,7 +3420,7 @@ categories, since after the creation of auxiliary variables
|
|||
and one lag. We therefore have the following identity:
|
||||
|
||||
@example
|
||||
oo_.dr.npred + oo_.dr.nfwrd + oo_.dr.nstatic = M_.endo_nbr
|
||||
M_.npred + M_.both + M_.nfwrd + M_.nstatic = M_.endo_nbr
|
||||
@end example
|
||||
|
||||
Internally, Dynare uses two orderings of the endogenous variables: the
|
||||
|
@ -3445,11 +3444,14 @@ to the endogenous variable numbered @code{oo_.dr_order_var(k)} in
|
|||
declaration order. Conversely, k-th declared variable is numbered
|
||||
@code{oo_.dr.inv_order_var(k)} in DR-order.
|
||||
|
||||
@vindex oo_.dr.npred
|
||||
@vindex M_.nspred
|
||||
@vindex M_.nsfwrd
|
||||
@vindex M_.ndynamic
|
||||
Finally, the state variables of the model are the purely backward variables
|
||||
and the mixed variables. They are orderer in DR-order when they appear in
|
||||
decision rules elements. There are @code{oo_.dr.npred} such
|
||||
variables.
|
||||
decision rules elements. There are @code{M_.nspred = M_.npred + M_.nboth} such
|
||||
variables. Similarly, one has @code{M_.nfwrd = M_.nfwrd + M_.nboth},
|
||||
and @code{M_.ndynamic = M_.nfwrd+M_.nboth+M_.npred}.
|
||||
|
||||
@node First order approximation
|
||||
@subsection First order approximation
|
||||
|
@ -3542,7 +3544,7 @@ where @math{y^s} is the steady state value of @math{y}, and @math{z_t} is a
|
|||
vector consisting of the deviation from the steady state of the state
|
||||
variables (in DR-order) at date @math{t-1} followed by the exogenous variables at
|
||||
date @math{t} (in declaration order). The vector @math{z_t} is
|
||||
therefore of size @math{n_z} = @code{oo_.dr.npred +
|
||||
therefore of size @math{n_z} = @code{M_.nspred +
|
||||
M_.exo_nbr}.
|
||||
|
||||
The coefficients of the decision rules are stored as follows:
|
||||
|
|
|
@ -82,15 +82,15 @@ function [dr,info]=AIM_first_order_solver(jacobia,M,dr,qz_criterium)
|
|||
nd = size(dr.kstate,1);
|
||||
nba = nd-sum( abs(dr.eigval) < qz_criterium );
|
||||
|
||||
nyf = dr.nfwrd+dr.nboth;
|
||||
nsfwrd = M.nsfwrd;
|
||||
|
||||
if nba ~= nyf
|
||||
if nba ~= nsfwrd
|
||||
temp = sort(abs(dr.eigval));
|
||||
if nba > nyf
|
||||
temp = temp(nd-nba+1:nd-nyf)-1-qz_criterium;
|
||||
if nba > nsfwrd
|
||||
temp = temp(nd-nba+1:nd-nsfwrd)-1-qz_criterium;
|
||||
info(1) = 3;
|
||||
elseif nba < nyf;
|
||||
temp = temp(nd-nyf+1:nd-nba)-1-qz_criterium;
|
||||
elseif nba < nsfwrd;
|
||||
temp = temp(nd-nsfwrd+1:nd-nba)-1-qz_criterium;
|
||||
info(1) = 4;
|
||||
end
|
||||
info(2) = temp'*temp;
|
||||
|
|
|
@ -63,13 +63,13 @@ end
|
|||
f = zeros(nvar,GridSize);
|
||||
ghx = dr.ghx;
|
||||
ghu = dr.ghu;
|
||||
npred = dr.npred;
|
||||
nstatic = dr.nstatic;
|
||||
nspred = M_.nspred;
|
||||
nstatic = M_.nstatic;
|
||||
kstate = dr.kstate;
|
||||
order = dr.order_var;
|
||||
iv(order) = [1:length(order)];
|
||||
nx = size(ghx,2);
|
||||
ikx = [nstatic+1:nstatic+npred];
|
||||
ikx = [nstatic+1:nstatic+nspred];
|
||||
A = zeros(nx,nx);
|
||||
k0 = kstate(find(kstate(:,2) <= M_.maximum_lag+1),:);
|
||||
i0 = find(k0(:,2) == M_.maximum_lag+1);
|
||||
|
@ -175,4 +175,4 @@ if pltinfo
|
|||
box on
|
||||
axis tight
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ function [result,info] = check(M, options, oo)
|
|||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright (C) 2001-2011 Dynare Team
|
||||
% Copyright (C) 2001-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -77,16 +77,13 @@ if info(1) ~= 0 && info(1) ~= 3 && info(1) ~= 4
|
|||
end
|
||||
|
||||
eigenvalues_ = dr.eigval;
|
||||
if (options.block)
|
||||
nyf = dr.nyf;
|
||||
else
|
||||
nyf = nnz(dr.kstate(:,2)>M.maximum_endo_lag+1);
|
||||
end;
|
||||
[m_lambda,i]=sort(abs(eigenvalues_));
|
||||
n_explod = nnz(abs(eigenvalues_) > options.qz_criterium);
|
||||
|
||||
nsfwrd = M.nsfwrd
|
||||
|
||||
result = 0;
|
||||
if (nyf== n_explod) && (dr.full_rank)
|
||||
if (nsfwrd == n_explod) && (dr.full_rank)
|
||||
result = 1;
|
||||
end
|
||||
|
||||
|
@ -97,7 +94,7 @@ if options.noprint == 0
|
|||
z=[m_lambda real(eigenvalues_(i)) imag(eigenvalues_(i))]';
|
||||
disp(sprintf('%16.4g %16.4g %16.4g\n',z))
|
||||
disp(sprintf('\nThere are %d eigenvalue(s) larger than 1 in modulus ', n_explod));
|
||||
disp(sprintf('for %d forward-looking variable(s)',nyf));
|
||||
disp(sprintf('for %d forward-looking variable(s)',nsfwrd));
|
||||
disp(' ')
|
||||
if result
|
||||
disp('The rank condition is verified.')
|
||||
|
|
|
@ -8,7 +8,7 @@ function disp_dr(dr,order,var_list)
|
|||
% var_list [char array]: list of endogenous variables for which the
|
||||
% decision rules should be printed
|
||||
|
||||
% Copyright (C) 2001-2011 Dynare Team
|
||||
% Copyright (C) 2001-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -30,7 +30,7 @@ global M_ options_
|
|||
nx =size(dr.ghx,2);
|
||||
nu =size(dr.ghu,2);
|
||||
if options_.block
|
||||
k = dr.npred + dr.nboth;
|
||||
k = M_.nspred;
|
||||
k1 = 1:M_.endo_nbr;
|
||||
else
|
||||
k = find(dr.kstate(:,2) <= M_.maximum_lag+1);
|
||||
|
|
|
@ -7,7 +7,7 @@ function disp_model_summary(M,dr)
|
|||
% M [matlab structure] Definition of the model.
|
||||
% dr [matlab structure] Decision rules
|
||||
%
|
||||
% Copyright (C) 2001-2010 Dynare Team
|
||||
% Copyright (C) 2001-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -33,7 +33,7 @@ disp([' Number of state variables: ' ...
|
|||
int2str(length(find(dr.kstate(:,2) <= M.maximum_lag+1)))])
|
||||
disp([' Number of jumpers: ' ...
|
||||
int2str(length(find(dr.kstate(:,2) == M.maximum_lag+2)))])
|
||||
disp([' Number of static variables: ' int2str(dr.nstatic)])
|
||||
disp([' Number of static variables: ' int2str(M.nstatic)])
|
||||
my_title='MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS';
|
||||
labels = deblank(M.exo_names);
|
||||
headers = char('Variables',labels);
|
||||
|
|
|
@ -16,7 +16,7 @@ function oo_ = display_conditional_variance_decomposition(Steps, SubsetOfVariabl
|
|||
% [1] The covariance matrix of the state innovations needs to be diagonal.
|
||||
% [2] In this version, absence of measurement errors is assumed...
|
||||
|
||||
% Copyright (C) 2010-2011 Dynare Team
|
||||
% Copyright (C) 2010-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -40,7 +40,7 @@ StateSpaceModel.number_of_state_innovations = exo_nbr;
|
|||
StateSpaceModel.sigma_e_is_diagonal = M_.sigma_e_is_diagonal;
|
||||
|
||||
iv = (1:endo_nbr)';
|
||||
ic = dr.nstatic+(1:dr.npred)';
|
||||
ic = M_.nstatic+(1:M_.nspred)';
|
||||
|
||||
[StateSpaceModel.transition_matrix,StateSpaceModel.impulse_matrix] = kalman_transition_matrix(dr,iv,ic,exo_nbr);
|
||||
StateSpaceModel.state_innovations_covariance_matrix = M_.Sigma_e;
|
||||
|
@ -73,4 +73,4 @@ for i=1:length(Steps)
|
|||
end
|
||||
end
|
||||
|
||||
oo_.conditional_variance_decomposition = conditional_decomposition_array;
|
||||
oo_.conditional_variance_decomposition = conditional_decomposition_array;
|
||||
|
|
|
@ -74,10 +74,6 @@ end;
|
|||
mexErrCheck('bytecode', chck);
|
||||
dr.full_rank = 1;
|
||||
dr.eigval = [];
|
||||
dr.nstatic = 0;
|
||||
dr.nfwrd = 0;
|
||||
dr.npred = 0;
|
||||
dr.nboth = 0;
|
||||
dr.nd = 0;
|
||||
|
||||
dr.ghx = [];
|
||||
|
@ -89,11 +85,6 @@ n_sv = size(dr.state_var, 2);
|
|||
dr.ghx = zeros(M_.endo_nbr, length(dr.state_var));
|
||||
dr.exo_var = 1:M_.exo_nbr;
|
||||
dr.ghu = zeros(M_.endo_nbr, M_.exo_nbr);
|
||||
dr.nstatic = M_.nstatic;
|
||||
dr.nfwrd = M_.nfwrd;
|
||||
dr.npred = M_.npred;
|
||||
dr.nboth = M_.nboth;
|
||||
dr.nyf = 0;
|
||||
for i = 1:Size;
|
||||
ghx = [];
|
||||
indexi_0 = 0;
|
||||
|
@ -107,7 +98,6 @@ for i = 1:Size;
|
|||
n_fwrd = data(i).n_forward;
|
||||
n_both = data(i).n_mixed;
|
||||
n_static = data(i).n_static;
|
||||
dr.nyf = dr.nyf + n_fwrd + n_both;
|
||||
nd = n_pred + n_fwrd + 2*n_both;
|
||||
dr.nd = dr.nd + nd;
|
||||
n_dynamic = n_pred + n_fwrd + n_both;
|
||||
|
|
|
@ -107,16 +107,16 @@ for file = 1:NumberOfDrawsFiles
|
|||
end
|
||||
if first_call
|
||||
endo_nbr = M_.endo_nbr;
|
||||
nstatic = dr.nstatic;
|
||||
npred = dr.npred;
|
||||
nstatic = M_.nstatic;
|
||||
nspred = M_.nspred;
|
||||
iv = (1:endo_nbr)';
|
||||
ic = [ nstatic+(1:npred) endo_nbr+(1:size(dr.ghx,2)-npred) ]';
|
||||
ic = [ nstatic+(1:nspred) endo_nbr+(1:size(dr.ghx,2)-nspred) ]';
|
||||
StateSpaceModel.number_of_state_equations = M_.endo_nbr;
|
||||
StateSpaceModel.number_of_state_innovations = M_.exo_nbr;
|
||||
StateSpaceModel.sigma_e_is_diagonal = M_.sigma_e_is_diagonal;
|
||||
StateSpaceModel.order_var = dr.order_var;
|
||||
first_call = 0;
|
||||
clear('endo_nbr','nstatic','npred','k');
|
||||
clear('endo_nbr','nstatic','nspred','k');
|
||||
end
|
||||
[StateSpaceModel.transition_matrix,StateSpaceModel.impulse_matrix] = kalman_transition_matrix(dr,iv,ic,M_.exo_nbr);
|
||||
StateSpaceModel.state_innovations_covariance_matrix = M_.Sigma_e;
|
||||
|
@ -144,4 +144,4 @@ for file = 1:NumberOfDrawsFiles
|
|||
end
|
||||
end
|
||||
|
||||
options_.ar = nar;
|
||||
options_.ar = nar;
|
||||
|
|
|
@ -66,7 +66,7 @@ function [dr,info] = dyn_first_order_solver(jacobia,DynareModel,dr,DynareOptions
|
|||
|
||||
persistent reorder_jacobian_columns innovations_idx index_s index_m index_c
|
||||
persistent index_p row_indx index_0m index_0p k1 k2 state_var
|
||||
persistent ndynamic nstatic nfwrd npred nboth nd nyf n_current index_d
|
||||
persistent ndynamic nstatic nfwrd npred nboth nd nsfwrd n_current index_d
|
||||
persistent index_e index_d1 index_d2 index_e1 index_e2 row_indx_de_1
|
||||
persistent row_indx_de_2 cols_b
|
||||
|
||||
|
@ -85,12 +85,12 @@ if isempty(reorder_jacobian_columns)
|
|||
|
||||
maximum_lag = DynareModel.maximum_endo_lag;
|
||||
kstate = dr.kstate;
|
||||
nfwrd = dr.nfwrd;
|
||||
nboth = dr.nboth;
|
||||
npred = dr.npred-nboth;
|
||||
nstatic = dr.nstatic;
|
||||
ndynamic = npred+nfwrd+nboth;
|
||||
nyf = nfwrd + nboth;
|
||||
nfwrd = DynareModel.nfwrd;
|
||||
nboth = DynareModel.nboth;
|
||||
npred = DynareModel.npred;
|
||||
nstatic = DynareModel.nstatic;
|
||||
ndynamic = DynareModel.ndynamic;
|
||||
nsfwrd = DynareModel.nsfwrd;
|
||||
n = DynareModel.endo_nbr;
|
||||
|
||||
k1 = 1:(npred+nboth);
|
||||
|
@ -142,12 +142,12 @@ if isempty(reorder_jacobian_columns)
|
|||
row_indx = nstatic+row_indx_de_1;
|
||||
index_d = [index_0m index_p];
|
||||
llx = lead_lag_incidence(:,order_var);
|
||||
index_d1 = [find(llx(maximum_lag+1,nstatic+(1:npred))), npred+nboth+(1:nyf) ];
|
||||
index_d1 = [find(llx(maximum_lag+1,nstatic+(1:npred))), npred+nboth+(1:nsfwrd) ];
|
||||
index_d2 = npred+(1:nboth);
|
||||
|
||||
index_e = [index_m index_0p];
|
||||
index_e1 = [1:npred+nboth, npred+nboth+find(llx(maximum_lag+1,nstatic+npred+(1: ...
|
||||
nyf)))];
|
||||
nsfwrd)))];
|
||||
index_e2 = npred+nboth+(1:nboth);
|
||||
|
||||
[junk,cols_b] = find(lead_lag_incidence(maximum_lag+1, order_var));
|
||||
|
@ -239,13 +239,13 @@ else
|
|||
return
|
||||
end
|
||||
|
||||
if nba ~= nyf
|
||||
if nba ~= nsfwrd
|
||||
temp = sort(abs(dr.eigval));
|
||||
if nba > nyf
|
||||
temp = temp(nd-nba+1:nd-nyf)-1-DynareOptions.qz_criterium;
|
||||
if nba > nsfwrd
|
||||
temp = temp(nd-nba+1:nd-nsfwrd)-1-DynareOptions.qz_criterium;
|
||||
info(1) = 3;
|
||||
elseif nba < nyf;
|
||||
temp = temp(nd-nyf+1:nd-nba)-1-DynareOptions.qz_criterium;
|
||||
elseif nba < nsfwrd;
|
||||
temp = temp(nd-nsfwrd+1:nd-nba)-1-DynareOptions.qz_criterium;
|
||||
info(1) = 4;
|
||||
end
|
||||
info(2) = temp'*temp;
|
||||
|
@ -253,7 +253,7 @@ else
|
|||
end
|
||||
|
||||
%First order approximation
|
||||
indx_stable_root = 1: (nd - nyf); %=> index of stable roots
|
||||
indx_stable_root = 1: (nd - nsfwrd); %=> index of stable roots
|
||||
indx_explosive_root = npred + nboth + 1:nd; %=> index of explosive roots
|
||||
% derivatives with respect to dynamic state variables
|
||||
% forward variables
|
||||
|
@ -326,4 +326,4 @@ end
|
|||
% non-predetermined variables
|
||||
dr.gx = gx;
|
||||
%predetermined (endogenous state) variables, square transition matrix
|
||||
dr.Gy = hx;
|
||||
dr.Gy = hx;
|
||||
|
|
|
@ -56,16 +56,16 @@ function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_
|
|||
Gy = dr.Gy;
|
||||
|
||||
kstate = dr.kstate;
|
||||
nstatic = dr.nstatic;
|
||||
nfwrd = dr.nfwrd;
|
||||
npred = dr.npred;
|
||||
nboth = dr.nboth;
|
||||
nyf = nfwrd+nboth;
|
||||
nstatic = M_.nstatic;
|
||||
nfwrd = M_.nfwrd;
|
||||
nspred = M_.nspred;
|
||||
nboth = M_.nboth;
|
||||
nsfwrd = M_.nsfwrd;
|
||||
order_var = dr.order_var;
|
||||
nd = size(kstate,1);
|
||||
lead_lag_incidence = M_.lead_lag_incidence;
|
||||
|
||||
np = nd - nyf;
|
||||
np = nd - nsfwrd;
|
||||
|
||||
k1 = nonzeros(lead_lag_incidence(:,order_var)');
|
||||
kk = [k1; length(k1)+(1:M_.exo_nbr+M_.exo_det_nbr)'];
|
||||
|
@ -80,7 +80,7 @@ function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_
|
|||
zx(1:np,:)=eye(np);
|
||||
k0 = [1:M_.endo_nbr];
|
||||
gx1 = dr.ghx;
|
||||
hu = dr.ghu(nstatic+[1:npred],:);
|
||||
hu = dr.ghu(nstatic+[1:nspred],:);
|
||||
k0 = find(lead_lag_incidence(M_.maximum_endo_lag+1,order_var)');
|
||||
zx = [zx; gx1(k0,:)];
|
||||
zu = [zu; dr.ghu(k0,:)];
|
||||
|
@ -104,10 +104,10 @@ function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_
|
|||
k1 = find(kstate(:,2) == M_.maximum_endo_lag+2);
|
||||
% Jacobian with respect to the variables with the highest lead
|
||||
fyp = jacobia(:,kstate(k1,3)+nnz(M_.lead_lag_incidence(M_.maximum_endo_lag+1,:)));
|
||||
B(:,nstatic+npred-dr.nboth+1:end) = fyp;
|
||||
B(:,nstatic+M_.npred+1:end) = fyp;
|
||||
[junk,k1,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+M_.maximum_endo_lead+1,order_var));
|
||||
A(1:M_.endo_nbr,nstatic+1:nstatic+npred)=...
|
||||
A(1:M_.endo_nbr,nstatic+[1:npred])+fyp*gx1(k1,1:npred);
|
||||
A(1:M_.endo_nbr,nstatic+1:nstatic+nspred)=...
|
||||
A(1:M_.endo_nbr,nstatic+[1:nspred])+fyp*gx1(k1,1:nspred);
|
||||
C = Gy;
|
||||
D = [rhs; zeros(n-M_.endo_nbr,size(rhs,2))];
|
||||
|
||||
|
@ -117,11 +117,11 @@ function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_
|
|||
|
||||
%ghxu
|
||||
%rhs
|
||||
hu = dr.ghu(nstatic+1:nstatic+npred,:);
|
||||
hu = dr.ghu(nstatic+1:nstatic+nspred,:);
|
||||
[rhs, err] = sparse_hessian_times_B_kronecker_C(hessian,zx,zu,threads_BC);
|
||||
mexErrCheck('sparse_hessian_times_B_kronecker_C', err);
|
||||
|
||||
hu1 = [hu;zeros(np-npred,M_.exo_nbr)];
|
||||
hu1 = [hu;zeros(np-nspred,M_.exo_nbr)];
|
||||
[nrhx,nchx] = size(Gy);
|
||||
[nrhu1,nchu1] = size(hu1);
|
||||
|
||||
|
@ -150,7 +150,7 @@ function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_
|
|||
% derivatives of F with respect to forward variables
|
||||
% reordering predetermined variables in diminishing lag order
|
||||
O1 = zeros(M_.endo_nbr,nstatic);
|
||||
O2 = zeros(M_.endo_nbr,M_.endo_nbr-nstatic-npred);
|
||||
O2 = zeros(M_.endo_nbr,M_.endo_nbr-nstatic-nspred);
|
||||
LHS = zeros(M_.endo_nbr,M_.endo_nbr);
|
||||
LHS(:,k0) = jacobia(:,nonzeros(lead_lag_incidence(M_.maximum_endo_lag+1,order_var)));
|
||||
RHS = zeros(M_.endo_nbr,M_.exo_nbr^2);
|
||||
|
@ -159,11 +159,11 @@ function dr = dyn_second_order_solver(jacobia,hessian,dr,M_,threads_ABC,threads_
|
|||
E = eye(M_.endo_nbr);
|
||||
kh = reshape([1:nk^2],nk,nk);
|
||||
kp = sum(kstate(:,2) <= M_.maximum_endo_lag+1);
|
||||
E1 = [eye(npred); zeros(kp-npred,npred)];
|
||||
E1 = [eye(nspred); zeros(kp-nspred,nspred)];
|
||||
H = E1;
|
||||
hxx = dr.ghxx(nstatic+[1:npred],:);
|
||||
hxx = dr.ghxx(nstatic+[1:nspred],:);
|
||||
[junk,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+2,order_var));
|
||||
k3 = nnz(M_.lead_lag_incidence(1:M_.maximum_endo_lag+1,:))+(1:dr.nsfwrd)';
|
||||
k3 = nnz(M_.lead_lag_incidence(1:M_.maximum_endo_lag+1,:))+(1:M_.nsfwrd)';
|
||||
[B1, err] = sparse_hessian_times_B_kronecker_C(hessian(:,kh(k3,k3)),gu(k2a,:),threads_BC);
|
||||
mexErrCheck('sparse_hessian_times_B_kronecker_C', err);
|
||||
RHS = RHS + jacobia(:,k2)*guu(k2a,:)+B1;
|
||||
|
|
|
@ -201,9 +201,9 @@ objective_function_penalty_base = 1e8;
|
|||
% Get informations about the variables of the model.
|
||||
dr = set_state_space(oo_.dr,M_,options_);
|
||||
oo_.dr = dr;
|
||||
nstatic = dr.nstatic; % Number of static variables.
|
||||
npred = dr.npred; % Number of predetermined variables.
|
||||
nspred = dr.nspred; % Number of predetermined variables in the state equation.
|
||||
nstatic = M_.nstatic; % Number of static variables.
|
||||
npred = M_.nspred; % Number of predetermined variables.
|
||||
nspred = M_.nspred; % Number of predetermined variables in the state equation.
|
||||
|
||||
% Test if observed variables are declared.
|
||||
if isempty(options_.varobs)
|
||||
|
@ -219,12 +219,12 @@ for i=1:n_varobs
|
|||
end
|
||||
|
||||
% Define union of observed and state variables
|
||||
k2 = union(var_obs_index,[dr.nstatic+1:dr.nstatic+dr.npred]', 'rows');
|
||||
k2 = union(var_obs_index,[M_.nstatic+1:M_.nstatic+M_.nspred]', 'rows');
|
||||
% Set restrict_state to postion of observed + state variables in expanded state vector.
|
||||
oo_.dr.restrict_var_list = k2;
|
||||
bayestopt_.restrict_var_list = k2;
|
||||
% set mf0 to positions of state variables in restricted state vector for likelihood computation.
|
||||
[junk,bayestopt_.mf0] = ismember([dr.nstatic+1:dr.nstatic+dr.npred]',k2);
|
||||
[junk,bayestopt_.mf0] = ismember([M_.nstatic+1:M_.nstatic+M_.nspred]',k2);
|
||||
% Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
|
||||
[junk,bayestopt_.mf1] = ismember(var_obs_index,k2);
|
||||
% Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing.
|
||||
|
@ -271,11 +271,11 @@ if options_.block == 1
|
|||
[junk,bayestopt_.smoother_mf] = ismember(k1, ...
|
||||
bayestopt_.smoother_var_list);
|
||||
else
|
||||
k2 = union(var_obs_index,[dr.nstatic+1:dr.nstatic+dr.npred]', 'rows');
|
||||
k2 = union(var_obs_index,[M_.nstatic+1:M_.nstatic+M_.nspred]', 'rows');
|
||||
% Set restrict_state to postion of observed + state variables in expanded state vector.
|
||||
oo_.dr.restrict_var_list = k2;
|
||||
% set mf0 to positions of state variables in restricted state vector for likelihood computation.
|
||||
[junk,bayestopt_.mf0] = ismember([dr.nstatic+1:dr.nstatic+dr.npred]',k2);
|
||||
[junk,bayestopt_.mf0] = ismember([M_.nstatic+1:M_.nstatic+M_.nspred]',k2);
|
||||
% Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
|
||||
[junk,bayestopt_.mf1] = ismember(var_obs_index,k2);
|
||||
% Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing.
|
||||
|
|
|
@ -49,7 +49,7 @@ function [A,B,ys,info,Model,DynareOptions,DynareResults] = dynare_resolve(Model,
|
|||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright (C) 2001-2011 Dynare Team
|
||||
% Copyright (C) 2001-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -83,11 +83,11 @@ end
|
|||
switch nargin
|
||||
case 3
|
||||
endo_nbr = Model.endo_nbr;
|
||||
nstatic = DynareResults.dr.nstatic;
|
||||
npred = DynareResults.dr.npred;
|
||||
nstatic = Model.nstatic;
|
||||
nspred = Model.nspred;
|
||||
iv = (1:endo_nbr)';
|
||||
if DynareOptions.block == 0
|
||||
ic = [ nstatic+(1:npred) endo_nbr+(1:size(DynareResults.dr.ghx,2)-npred) ]';
|
||||
ic = [ nstatic+(1:nspred) endo_nbr+(1:size(DynareResults.dr.ghx,2)-nspred) ]';
|
||||
else
|
||||
ic = DynareResults.dr.restrict_columns;
|
||||
end;
|
||||
|
@ -104,4 +104,4 @@ if nargout==1
|
|||
end
|
||||
|
||||
[A,B] = kalman_transition_matrix(DynareResults.dr,iv,ic,Model.exo_nbr);
|
||||
ys = DynareResults.dr.ys;
|
||||
ys = DynareResults.dr.ys;
|
||||
|
|
|
@ -31,8 +31,8 @@ function planner_objective_value = evaluate_planner_objective(M,options,oo)
|
|||
dr = oo.dr;
|
||||
endo_nbr = M.endo_nbr;
|
||||
exo_nbr = M.exo_nbr;
|
||||
nstatic = dr.nstatic;
|
||||
npred = dr.npred;
|
||||
nstatic = M.nstatic;
|
||||
nspred = M.nspred;
|
||||
lead_lag_incidence = M.lead_lag_incidence;
|
||||
beta = get_optimal_policy_discount_factor(M.params,M.param_names);
|
||||
if options.ramsey_policy
|
||||
|
@ -44,8 +44,8 @@ ipred = find(lead_lag_incidence(M.maximum_lag,:))';
|
|||
order_var = dr.order_var;
|
||||
LQ = true;
|
||||
|
||||
Gy = dr.ghx(nstatic+(1:npred),:);
|
||||
Gu = dr.ghu(nstatic+(1:npred),:);
|
||||
Gy = dr.ghx(nstatic+(1:nspred),:);
|
||||
Gu = dr.ghu(nstatic+(1:nspred),:);
|
||||
gy(dr.order_var,:) = dr.ghx;
|
||||
gu(dr.order_var,:) = dr.ghu;
|
||||
|
||||
|
@ -53,10 +53,10 @@ if options.ramsey_policy && options.order == 1 && ~options.linear
|
|||
options.order = 2;
|
||||
options.qz_criterium = 1+1e-6;
|
||||
[dr,info] = stochastic_solvers(oo.dr,0,M,options,oo);
|
||||
Gyy = dr.ghxx(nstatic+(1:npred),:);
|
||||
Guu = dr.ghuu(nstatic+(1:npred),:);
|
||||
Gyu = dr.ghxu(nstatic+(1:npred),:);
|
||||
Gss = dr.ghs2(nstatic+(1:npred),:);
|
||||
Gyy = dr.ghxx(nstatic+(1:nspred),:);
|
||||
Guu = dr.ghuu(nstatic+(1:nspred),:);
|
||||
Gyu = dr.ghxu(nstatic+(1:nspred),:);
|
||||
Gss = dr.ghs2(nstatic+(1:nspred),:);
|
||||
gyy(dr.order_var,:) = dr.ghxx;
|
||||
guu(dr.order_var,:) = dr.ghuu;
|
||||
gyu(dr.order_var,:) = dr.ghxu;
|
||||
|
@ -81,12 +81,12 @@ mexErrCheck('A_times_B_kronecker_C', err);
|
|||
mexErrCheck('A_times_B_kronecker_C', err);
|
||||
|
||||
Wbar =U/(1-beta);
|
||||
Wy = Uy*gy/(eye(npred)-beta*Gy);
|
||||
Wy = Uy*gy/(eye(nspred)-beta*Gy);
|
||||
Wu = Uy*gu+beta*Wy*Gu;
|
||||
if LQ
|
||||
Wyy = Uyygygy/(eye(npred*npred)-beta*kron(Gy,Gy));
|
||||
Wyy = Uyygygy/(eye(nspred*nspred)-beta*kron(Gy,Gy));
|
||||
else
|
||||
Wyy = (Uy*gyy+Uyygygy+beta*Wy*Gyy)/(eye(npred*npred)-beta*kron(Gy,Gy));
|
||||
Wyy = (Uy*gyy+Uyygygy+beta*Wy*Gyy)/(eye(nspred*nspred)-beta*kron(Gy,Gy));
|
||||
end
|
||||
[Wyygugu, err] = A_times_B_kronecker_C(Wyy,Gu,Gu,options.threads.kronecker.A_times_B_kronecker_C);
|
||||
mexErrCheck('A_times_B_kronecker_C', err);
|
||||
|
@ -115,8 +115,8 @@ if ~isempty(M.endo_histval)
|
|||
yhat2(1:M.orig_endo_nbr) = M.endo_histval(1:M.orig_endo_nbr);
|
||||
end
|
||||
end
|
||||
yhat1 = yhat1(dr.order_var(nstatic+(1:npred)),1)-dr.ys(dr.order_var(nstatic+(1:npred)));
|
||||
yhat2 = yhat2(dr.order_var(nstatic+(1:npred)),1)-dr.ys(dr.order_var(nstatic+(1:npred)));
|
||||
yhat1 = yhat1(dr.order_var(nstatic+(1:nspred)),1)-dr.ys(dr.order_var(nstatic+(1:nspred)));
|
||||
yhat2 = yhat2(dr.order_var(nstatic+(1:nspred)),1)-dr.ys(dr.order_var(nstatic+(1:nspred)));
|
||||
u = oo.exo_simul(1,:)';
|
||||
|
||||
[Wyyyhatyhat1, err] = A_times_B_kronecker_C(Wyy,yhat1,yhat1,options.threads.kronecker.A_times_B_kronecker_C);
|
||||
|
@ -144,4 +144,4 @@ if ~options.noprint
|
|||
disp([' - with initial Lagrange multipliers set to steady state: ' ...
|
||||
num2str(planner_objective_value(1)) ])
|
||||
disp(' ')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ function [yf,int_width]=forcst(dr,y0,horizon,var_list)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2003-2011 Dynare Team
|
||||
% Copyright (C) 2003-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -38,12 +38,12 @@ global M_ oo_ options_
|
|||
|
||||
make_ex_;
|
||||
yf = simult_(y0,dr,zeros(horizon,M_.exo_nbr),1);
|
||||
nstatic = dr.nstatic;
|
||||
npred = dr.npred;
|
||||
nstatic = M_.nstatic;
|
||||
nspred = M_.nspred;
|
||||
nc = size(dr.ghx,2);
|
||||
endo_nbr = M_.endo_nbr;
|
||||
inv_order_var = dr.inv_order_var;
|
||||
[A,B] = kalman_transition_matrix(dr,nstatic+(1:npred),1:nc,M_.exo_nbr);
|
||||
[A,B] = kalman_transition_matrix(dr,nstatic+(1:nspred),1:nc,M_.exo_nbr);
|
||||
|
||||
if size(var_list,1) == 0
|
||||
var_list = M_.endo_names(1:M_.orig_endo_nbr,:);
|
||||
|
|
|
@ -13,7 +13,7 @@ function vx1 = get_variance_of_endogenous_variables(dr,i_var)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2003-2011 Dynare Team
|
||||
% Copyright (C) 2003-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -36,14 +36,14 @@ endo_nbr = M_.endo_nbr;
|
|||
|
||||
Sigma_e = M_.Sigma_e;
|
||||
|
||||
nstatic = dr.nstatic;
|
||||
npred = dr.npred;
|
||||
nstatic = M_.nstatic;
|
||||
nspred = M_.nspred;
|
||||
ghx = dr.ghx(i_var,:);
|
||||
ghu = dr.ghu(i_var,:);
|
||||
nc = size(ghx,2);
|
||||
n = length(i_var);
|
||||
|
||||
[A,B] = kalman_transition_matrix(dr,nstatic+(1:npred),1:nc,M_.exo_nbr);
|
||||
[A,B] = kalman_transition_matrix(dr,nstatic+(1:nspred),1:nc,M_.exo_nbr);
|
||||
|
||||
[vx,u] = lyapunov_symm(A,B*Sigma_e*B',options_.qz_criterium,options_.lyapunov_complex_threshold);
|
||||
|
||||
|
|
|
@ -35,14 +35,14 @@ global oo_ M_
|
|||
oo_.dr.ghx = ghx;
|
||||
oo_.dr.ghu = ghu;
|
||||
endo_nbr = M_.endo_nbr;
|
||||
nstatic = oo_.dr.nstatic;
|
||||
npred = oo_.dr.npred;
|
||||
nstatic = M_.nstatic;
|
||||
nspred = M_.nspred;
|
||||
iv = (1:endo_nbr)';
|
||||
ic = [ nstatic+(1:npred) endo_nbr+(1:size(oo_.dr.ghx,2)-npred) ]';
|
||||
ic = [ nstatic+(1:nspred) endo_nbr+(1:size(oo_.dr.ghx,2)-nspred) ]';
|
||||
aux = oo_.dr.transition_auxiliary_variables;
|
||||
k = find(aux(:,2) > npred);
|
||||
k = find(aux(:,2) > nspred);
|
||||
aux(:,2) = aux(:,2) + nstatic;
|
||||
aux(k,2) = aux(k,2) + oo_.dr.nfwrd;
|
||||
aux(k,2) = aux(k,2) + M_.nfwrd;
|
||||
end
|
||||
n_iv = length(iv);
|
||||
n_ir1 = size(aux,1);
|
||||
|
|
|
@ -111,10 +111,10 @@ if opt_gsa.load_ident_files==0,
|
|||
|
||||
[nr1, nc1, nnn] = size(T);
|
||||
endo_nbr = M_.endo_nbr;
|
||||
nstatic = oo_.dr.nstatic;
|
||||
npred = oo_.dr.npred;
|
||||
nstatic = M_.nstatic;
|
||||
nspred = M_.nspred;
|
||||
iv = (1:endo_nbr)';
|
||||
ic = [ nstatic+(1:npred) endo_nbr+(1:size(oo_.dr.ghx,2)-npred) ]';
|
||||
ic = [ nstatic+(1:nspred) endo_nbr+(1:size(oo_.dr.ghx,2)-nspred) ]';
|
||||
|
||||
dr.ghx = T(:, [1:(nc1-M_.exo_nbr)],1);
|
||||
dr.ghu = T(:, [(nc1-M_.exo_nbr+1):end], 1);
|
||||
|
|
|
@ -212,7 +212,7 @@ for j=1:size(anamendo,1)
|
|||
iplo=0;
|
||||
for je=1:size(anamlagendo,1)
|
||||
namlagendo=deblank(anamlagendo(je,:));
|
||||
ilagendo=strmatch(namlagendo,M_.endo_names(oo_.dr.order_var(oo_.dr.nstatic+1:oo_.dr.nstatic+nsok),:),'exact');
|
||||
ilagendo=strmatch(namlagendo,M_.endo_names(oo_.dr.order_var(M_.nstatic+1:M_.nstatic+nsok),:),'exact');
|
||||
disp(' ')
|
||||
disp(['[', namendo,' vs. lagged ',namlagendo,']'])
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ end
|
|||
|
||||
load([dirname,'/',M_.fname,'_prior'],'lpmat','lpmat0','istable','T');
|
||||
|
||||
nspred=oo_.dr.nspred;
|
||||
nspred=M_.nspred;
|
||||
|
||||
[kn, np]=size(lpmat);
|
||||
nshock = length(bayestopt_.pshape)-np;
|
||||
|
@ -110,7 +110,7 @@ for j=1:size(anamendo,1),
|
|||
ifig=0;
|
||||
for je=1:size(anamlagendo,1)
|
||||
namlagendo=deblank(anamlagendo(je,:));
|
||||
ilagendo=strmatch(namlagendo,M_.endo_names(oo_.dr.order_var(oo_.dr.nstatic+1:oo_.dr.nstatic+nsok),:),'exact');
|
||||
ilagendo=strmatch(namlagendo,M_.endo_names(oo_.dr.order_var(M_.nstatic+1:M_.nstatic+nsok),:),'exact');
|
||||
|
||||
if ~isempty(ilagendo),
|
||||
y0=teff(T(iendo,ilagendo,:),kn,istable);
|
||||
|
|
|
@ -76,9 +76,9 @@ ntra = opt_gsa.morris_ntra;
|
|||
dr_ = oo_.dr;
|
||||
%if isfield(dr_,'ghx'),
|
||||
ys_ = oo_.dr.ys;
|
||||
nspred = dr_.nspred; %size(dr_.ghx,2);
|
||||
nboth = dr_.nboth;
|
||||
nfwrd = dr_.nfwrd;
|
||||
nspred = M_.nspred; %size(dr_.ghx,2);
|
||||
nboth = M_.nboth;
|
||||
nfwrd = M_.nfwrd;
|
||||
%end
|
||||
fname_ = M_.fname;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ M.var_order_endo_names = M.endo_names(dr.order_var,:);
|
|||
order = options.order;
|
||||
endo_nbr = M.endo_nbr;
|
||||
exo_nbr = M.exo_nbr;
|
||||
npred = dr.npred;
|
||||
nspred = M.nspred;
|
||||
|
||||
switch(order)
|
||||
case 1
|
||||
|
@ -44,13 +44,13 @@ switch(order)
|
|||
M,options);
|
||||
dr.ghx = derivs.gy;
|
||||
dr.ghu = derivs.gu;
|
||||
dr.ghxx = unfold2(derivs.gyy,npred);
|
||||
dr.ghxx = unfold2(derivs.gyy,nspred);
|
||||
dr.ghxu = derivs.gyu;
|
||||
dr.ghuu = unfold2(derivs.guu,exo_nbr);
|
||||
dr.ghs2 = derivs.gss;
|
||||
dr.ghxxx = unfold3(derivs.gyyy,npred);
|
||||
dr.ghxxu = unfold21(derivs.gyyu,npred,exo_nbr);
|
||||
dr.ghxuu = unfold12(derivs.gyuu,npred,exo_nbr);
|
||||
dr.ghxxx = unfold3(derivs.gyyy,nspred);
|
||||
dr.ghxxu = unfold21(derivs.gyyu,nspred,exo_nbr);
|
||||
dr.ghxuu = unfold12(derivs.gyuu,nspred,exo_nbr);
|
||||
dr.ghuuu = unfold3(derivs.guuu,exo_nbr);
|
||||
dr.ghxss = derivs.gyss;
|
||||
dr.ghuss = derivs.guss;
|
||||
|
@ -71,10 +71,10 @@ if options.pruning
|
|||
return
|
||||
end
|
||||
|
||||
npred = dr.npred;
|
||||
nspred = M.nspred;
|
||||
|
||||
dr.ghx = dr.g_1(:,1:npred);
|
||||
dr.ghu = dr.g_1(:,npred+1:end);
|
||||
dr.ghx = dr.g_1(:,1:nspred);
|
||||
dr.ghu = dr.g_1(:,nspred+1:end);
|
||||
|
||||
if options.loglinear == 1
|
||||
k = find(dr.kstate(:,2) <= M.maximum_endo_lag+1);
|
||||
|
@ -90,27 +90,27 @@ if order > 1
|
|||
dr.ghs2 = 2*g_0;
|
||||
s0 = 0;
|
||||
s1 = 0;
|
||||
ghxx=zeros(endo_nbr, npred^2);
|
||||
ghxu=zeros(endo_nbr, npred*exo_nbr);
|
||||
ghxx=zeros(endo_nbr, nspred^2);
|
||||
ghxu=zeros(endo_nbr, nspred*exo_nbr);
|
||||
ghuu=zeros(endo_nbr, exo_nbr^2);
|
||||
for i=1:size(g_2,2)
|
||||
if s0 < npred && s1 < npred
|
||||
ghxx(:,s0*npred+s1+1) = 2*g_2(:,i);
|
||||
if s0 < nspred && s1 < nspred
|
||||
ghxx(:,s0*nspred+s1+1) = 2*g_2(:,i);
|
||||
if s1 > s0
|
||||
ghxx(:,s1*npred+s0+1) = 2*g_2(:,i);
|
||||
ghxx(:,s1*nspred+s0+1) = 2*g_2(:,i);
|
||||
end
|
||||
elseif s0 < npred && s1 < npred+exo_nbr
|
||||
ghxu(:,(s0*exo_nbr+s1-npred+1)) = 2*g_2(:,i);
|
||||
elseif s0 < npred+exo_nbr && s1 < npred+exo_nbr
|
||||
ghuu(:,(s0-npred)*exo_nbr+s1-npred +1) = 2*g_2(:,i);
|
||||
elseif s0 < nspred && s1 < nspred+exo_nbr
|
||||
ghxu(:,(s0*exo_nbr+s1-nspred+1)) = 2*g_2(:,i);
|
||||
elseif s0 < nspred+exo_nbr && s1 < nspred+exo_nbr
|
||||
ghuu(:,(s0-nspred)*exo_nbr+s1-nspred +1) = 2*g_2(:,i);
|
||||
if s1 > s0
|
||||
ghuu(:,(s1-npred)*exo_nbr+s0-npred+1) = 2*g_2(:,i);
|
||||
ghuu(:,(s1-nspred)*exo_nbr+s0-nspred+1) = 2*g_2(:,i);
|
||||
end
|
||||
else
|
||||
error('dr1:k_order_perturbation:g_2','Unaccounted columns in g_2');
|
||||
end
|
||||
s1 = s1+1;
|
||||
if s1 == npred+exo_nbr
|
||||
if s1 == nspred+exo_nbr
|
||||
s0 = s0+1;
|
||||
s1 = s0;
|
||||
end
|
||||
|
@ -182,4 +182,4 @@ end
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ function dr=mult_elimination(varlist,M_, options_, oo_)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2003-2011 Dynare Team
|
||||
% Copyright (C) 2003-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -31,21 +31,21 @@ function dr=mult_elimination(varlist,M_, options_, oo_)
|
|||
|
||||
dr = oo_.dr;
|
||||
|
||||
nstatic = dr.nstatic;
|
||||
npred = dr.npred;
|
||||
nstatic = M_.nstatic;
|
||||
nspred = M_.nspred;
|
||||
order_var = dr.order_var;
|
||||
nstates = M_.endo_names(order_var(nstatic+(1:npred)),:);
|
||||
nstates = M_.endo_names(order_var(nstatic+(1:nspred)),:);
|
||||
|
||||
il = strmatch('MULT_',nstates);
|
||||
nil = setdiff(1:dr.npred,il);
|
||||
nil = setdiff(1:nspred,il);
|
||||
m_nbr = length(il);
|
||||
nm_nbr = length(nil);
|
||||
|
||||
AA1 = dr.ghx(:,nil);
|
||||
AA2 = dr.ghx(:,il);
|
||||
A1 = dr.ghx(nstatic+(1:npred),nil);
|
||||
A2 = dr.ghx(nstatic+(1:npred),il);
|
||||
B = dr.ghu(nstatic+(1:npred),:);
|
||||
A1 = dr.ghx(nstatic+(1:nspred),nil);
|
||||
A2 = dr.ghx(nstatic+(1:nspred),il);
|
||||
B = dr.ghu(nstatic+(1:nspred),:);
|
||||
A11 = A1(nil,:);
|
||||
A21 = A1(il,:);
|
||||
A12 = A2(nil,:);
|
||||
|
@ -68,7 +68,7 @@ M2 = AA2*E2*[R2_1*Q2(:,1:n2)'*[Q1_12' Q1_22']*[A11;A21]; zeros(m_nbr-n2,length(n
|
|||
M3 = dr.ghu;
|
||||
M4 = AA2*E2*[R2_1*Q2(:,1:n2)'*[Q1_12' Q1_22']*[B1;B2]; zeros(m_nbr-n2,size(B,2))];
|
||||
|
||||
k1 = nstatic+(1:npred);
|
||||
k1 = nstatic+(1:nspred);
|
||||
k1 = k1(nil);
|
||||
|
||||
endo_nbr = M_.orig_endo_nbr;
|
||||
|
@ -100,7 +100,6 @@ dr.M3 = M3;
|
|||
dr.M4 = M4;
|
||||
|
||||
nvar = length(varlist);
|
||||
nspred = dr.nspred;
|
||||
|
||||
if nvar > 0 && options_.noprint == 0
|
||||
res_table = zeros(2*(nm_nbr+M_.exo_nbr),nvar);
|
||||
|
|
|
@ -157,10 +157,10 @@ end
|
|||
|
||||
dr=set_state_space(dr,M_,options_);
|
||||
kstate = dr.kstate;
|
||||
nstatic = dr.nstatic;
|
||||
nfwrd = dr.nfwrd;
|
||||
npred = dr.npred;
|
||||
nboth = dr.nboth;
|
||||
nstatic = M_.nstatic;
|
||||
nfwrd = M_.nfwrd;
|
||||
nspred = M_.nspred;
|
||||
nboth = M_.nboth;
|
||||
order_var = dr.order_var;
|
||||
nd = size(kstate,1);
|
||||
nz = nnz(M_.lead_lag_incidence);
|
||||
|
@ -240,7 +240,7 @@ end % end if useAIM and...
|
|||
% E_t z(t+3)
|
||||
|
||||
% partition jacobian:
|
||||
jlen=dr.nspred+dr.nsfwrd+M_.endo_nbr+M_.exo_nbr; % length of jacobian
|
||||
jlen=M_.nspred+M_.nsfwrd+M_.endo_nbr+M_.exo_nbr; % length of jacobian
|
||||
PSI=-jacobia_(:, jlen-M_.exo_nbr+1:end); % exog
|
||||
% first transpose M_.lead_lag_incidence';
|
||||
lead_lag=M_.lead_lag_incidence';
|
||||
|
@ -251,12 +251,12 @@ end % end if useAIM and...
|
|||
AA2=AA0; % empty A2 and A3
|
||||
AA3=AA0;
|
||||
if xlen==nendo % && M_.maximum_lag <=1 && M_.maximum_lead <=1 % apply a shortcut
|
||||
AA1=jacobia_(:,npred+1:npred+nendo);
|
||||
AA1=jacobia_(:,nspred+1:nspred+nendo);
|
||||
if M_.maximum_lead ==1
|
||||
fnd = find(lead_lag(:,M_.maximum_lag+2));
|
||||
AA0(:, fnd)= jacobia_(:,nonzeros(lead_lag(:,M_.maximum_lag+2))); %forwd jacobian
|
||||
end
|
||||
if npred>0 && M_.maximum_lag ==1
|
||||
if nspred>0 && M_.maximum_lag ==1
|
||||
fnd = find(lead_lag(:,1));
|
||||
AA2(:, fnd)= jacobia_(:,nonzeros(lead_lag(:,1))); %backward
|
||||
end
|
||||
|
@ -264,7 +264,7 @@ end % end if useAIM and...
|
|||
if nendo-xlen==num_inst
|
||||
PSI=[PSI;zeros(num_inst, M_.exo_nbr)];
|
||||
% AA1 contemporary
|
||||
AA_all=jacobia_(:,npred+1:npred+nendo);
|
||||
AA_all=jacobia_(:,nspred+1:nspred+nendo);
|
||||
AA1=AA_all(:,lq_instruments.m_var); % endo without instruments
|
||||
lq_instruments.ij1=AA_all(:,lq_instruments.inst_var_indices); % instruments only
|
||||
lq_instruments.B1=-[lq_instruments.ij1; eye(num_inst)];
|
||||
|
@ -279,7 +279,7 @@ end % end if useAIM and...
|
|||
lq_instruments.B0=[lq_instruments.ij0; eye(num_inst)];
|
||||
AA0=[AA0, zeros(xlen,num_inst); zeros(num_inst,xlen+num_inst)];
|
||||
end
|
||||
if npred>0 && M_.maximum_lag ==1
|
||||
if nspred>0 && M_.maximum_lag ==1
|
||||
AA_all(:,:)=0.0;
|
||||
fnd = find(lead_lag(:,1));
|
||||
AA_all(:, fnd)= jacobia_(:,nonzeros(lead_lag(:,1))); %backward
|
||||
|
|
|
@ -34,7 +34,7 @@ function dr=set_state_space(dr,DynareModel,DynareOptions)
|
|||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright (C) 1996-2011 Dynare Team
|
||||
% Copyright (C) 1996-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -69,10 +69,6 @@ else
|
|||
both_var = [];
|
||||
stat_var = setdiff([1:endo_nbr]',fwrd_var);
|
||||
end
|
||||
nboth = length(both_var);
|
||||
npred = length(pred_var);
|
||||
nfwrd = length(fwrd_var);
|
||||
nstatic = length(stat_var);
|
||||
if DynareOptions.block == 1
|
||||
order_var = DynareModel.block_structure.variable_reordered;
|
||||
else
|
||||
|
@ -116,14 +112,6 @@ kstate = kstate(i_kmask,:);
|
|||
|
||||
dr.order_var = order_var;
|
||||
dr.inv_order_var = inv_order_var';
|
||||
dr.nstatic = nstatic;
|
||||
dr.npred = npred+nboth;
|
||||
dr.kstate = kstate;
|
||||
dr.nboth = nboth;
|
||||
dr.nfwrd = nfwrd;
|
||||
% number of forward variables in the state vector
|
||||
dr.nsfwrd = nfwrd+nboth;
|
||||
% number of predetermined variables in the state vector
|
||||
dr.nspred = npred+nboth;
|
||||
|
||||
dr.transition_auxiliary_variables = [];
|
||||
|
|
|
@ -15,7 +15,7 @@ function y_=simult_(y0,dr,ex_,iorder)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2001-2011 Dynare Team
|
||||
% Copyright (C) 2001-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -57,15 +57,15 @@ if options_.k_order_solver && ~options_.pruning % Call dynare++ routines.
|
|||
ex_ = [zeros(1,exo_nbr); ex_];
|
||||
switch options_.order
|
||||
case 1
|
||||
[err, y_] = dynare_simul_(1,dr.nstatic,dr.npred-dr.nboth,dr.nboth,dr.nfwrd,exo_nbr, ...
|
||||
[err, y_] = dynare_simul_(1,M_.nstatic,M_.npred,M_.nboth,M_.nfwrd,exo_nbr, ...
|
||||
y_(dr.order_var,1),ex_',M_.Sigma_e,options_.DynareRandomStreams.seed,dr.ys(dr.order_var),...
|
||||
zeros(endo_nbr,1),dr.g_1);
|
||||
case 2
|
||||
[err, y_] = dynare_simul_(2,dr.nstatic,dr.npred-dr.nboth,dr.nboth,dr.nfwrd,exo_nbr, ...
|
||||
[err, y_] = dynare_simul_(2,M_.nstatic,M_.npred,M_.nboth,M_.nfwrd,exo_nbr, ...
|
||||
y_(dr.order_var,1),ex_',M_.Sigma_e,options_.DynareRandomStreams.seed,dr.ys(dr.order_var),dr.g_0, ...
|
||||
dr.g_1,dr.g_2);
|
||||
case 3
|
||||
[err, y_] = dynare_simul_(3,dr.nstatic,dr.npred-dr.nboth,dr.nboth,dr.nfwrd,exo_nbr, ...
|
||||
[err, y_] = dynare_simul_(3,M_.nstatic,M_.npred,M_.nboth,M_.nfwrd,exo_nbr, ...
|
||||
y_(dr.order_var,1),ex_',M_.Sigma_e,options_.DynareRandomStreams.seed,dr.ys(dr.order_var),dr.g_0, ...
|
||||
dr.g_1,dr.g_2,dr.g_3);
|
||||
otherwise
|
||||
|
@ -152,11 +152,11 @@ else
|
|||
ghxss = dr.ghxss;
|
||||
ghuss = dr.ghuss;
|
||||
threads = options_.threads.kronecker.A_times_B_kronecker_C;
|
||||
npred = dr.npred;
|
||||
ipred = dr.nstatic+(1:npred);
|
||||
nspred = M_.nspred;
|
||||
ipred = M_.nstatic+(1:nspred);
|
||||
yhat1 = y0(order_var(k2))-dr.ys(order_var(k2));
|
||||
yhat2 = zeros(npred,1);
|
||||
yhat3 = zeros(npred,1);
|
||||
yhat2 = zeros(nspred,1);
|
||||
yhat3 = zeros(nspred,1);
|
||||
for i=2:iter+M_.maximum_lag
|
||||
u = ex_(i-1,:)';
|
||||
[gyy, err] = A_times_B_kronecker_C(ghxx,yhat1,threads);
|
||||
|
@ -188,4 +188,4 @@ else
|
|||
yhat3 = yhat3(ipred);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ function [y_,int_width]=simultxdet(y0,ex,ex_det, iorder,var_list,M_,oo_,options_
|
|||
% The condition size(ex,1)+M_.maximum_lag=size(ex_det,1) must be verified
|
||||
% for consistency.
|
||||
|
||||
% Copyright (C) 2008-2011 Dynare Team
|
||||
% Copyright (C) 2008-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -35,8 +35,8 @@ dr = oo_.dr;
|
|||
ykmin = M_.maximum_lag;
|
||||
endo_nbr = M_.endo_nbr;
|
||||
exo_det_steady_state = oo_.exo_det_steady_state;
|
||||
nstatic = dr.nstatic;
|
||||
npred =dr.npred;
|
||||
nstatic = M_.nstatic;
|
||||
nspred = M_.nspred;
|
||||
nc = size(dr.ghx,2);
|
||||
iter = size(ex,1);
|
||||
if size(ex_det, 1) ~= iter+ykmin
|
||||
|
@ -114,7 +114,7 @@ elseif iorder == 2
|
|||
end
|
||||
end
|
||||
|
||||
[A,B] = kalman_transition_matrix(dr,nstatic+(1:npred),1:nc,M_.exo_nbr);
|
||||
[A,B] = kalman_transition_matrix(dr,nstatic+(1:nspred),1:nc,M_.exo_nbr);
|
||||
|
||||
inv_order_var = dr.inv_order_var;
|
||||
ghx1 = dr.ghx(inv_order_var(ivar),:);
|
||||
|
|
|
@ -88,16 +88,9 @@ if ~options_.noprint
|
|||
disp(' ')
|
||||
disp([' Number of variables: ' int2str(M_.endo_nbr)])
|
||||
disp([' Number of stochastic shocks: ' int2str(M_.exo_nbr)])
|
||||
if (options_.block)
|
||||
disp([' Number of state variables: ' int2str(oo_.dr.npred+oo_.dr.nboth)])
|
||||
disp([' Number of jumpers: ' int2str(oo_.dr.nfwrd+oo_.dr.nboth)])
|
||||
else
|
||||
disp([' Number of state variables: ' ...
|
||||
int2str(length(find(oo_.dr.kstate(:,2) <= M_.maximum_lag+1)))])
|
||||
disp([' Number of jumpers: ' ...
|
||||
int2str(length(find(oo_.dr.kstate(:,2) == M_.maximum_lag+2)))])
|
||||
end;
|
||||
disp([' Number of static variables: ' int2str(oo_.dr.nstatic)])
|
||||
disp([' Number of state variables: ' int2str(M_.nspred)])
|
||||
disp([' Number of jumpers: ' int2str(M_.nsfwrd)])
|
||||
disp([' Number of static variables: ' int2str(M_.nstatic)])
|
||||
my_title='MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS';
|
||||
labels = deblank(M_.exo_names);
|
||||
headers = char('Variables',labels);
|
||||
|
|
|
@ -128,11 +128,11 @@ if any(any(isnan(jacobia_)))
|
|||
end
|
||||
|
||||
kstate = dr.kstate;
|
||||
nstatic = dr.nstatic;
|
||||
nfwrd = dr.nfwrd;
|
||||
npred = dr.npred;
|
||||
nboth = dr.nboth;
|
||||
nfwrds = nfwrd+nboth;
|
||||
nstatic = M_.nstatic;
|
||||
nfwrd = M_.nfwrd;
|
||||
nspred = M_.nspred;
|
||||
nboth = M_.nboth;
|
||||
nsfwrd = M_.nsfwrd;
|
||||
order_var = dr.order_var;
|
||||
nd = size(kstate,1);
|
||||
nz = nnz(M_.lead_lag_incidence);
|
||||
|
@ -194,34 +194,34 @@ if M_.exo_det_nbr > 0
|
|||
f1 = sparse(jacobia_(:,nonzeros(M_.lead_lag_incidence(M_.maximum_endo_lag+2:end,order_var))));
|
||||
f0 = sparse(jacobia_(:,nonzeros(M_.lead_lag_incidence(M_.maximum_endo_lag+1,order_var))));
|
||||
fudet = sparse(jacobia_(:,nz+M_.exo_nbr+1:end));
|
||||
M1 = inv(f0+[zeros(M_.endo_nbr,nstatic) f1*gx zeros(M_.endo_nbr,nfwrds-nboth)]);
|
||||
M1 = inv(f0+[zeros(M_.endo_nbr,nstatic) f1*gx zeros(M_.endo_nbr,nsfwrd-nboth)]);
|
||||
M2 = M1*f1;
|
||||
dr.ghud = cell(M_.exo_det_length,1);
|
||||
dr.ghud{1} = -M1*fudet;
|
||||
for i = 2:M_.exo_det_length
|
||||
dr.ghud{i} = -M2*dr.ghud{i-1}(end-nfwrds+1:end,:);
|
||||
dr.ghud{i} = -M2*dr.ghud{i-1}(end-nsfwrd+1:end,:);
|
||||
end
|
||||
|
||||
if options_.order > 1
|
||||
lead_lag_incidence = M_.lead_lag_incidence;
|
||||
k0 = find(lead_lag_incidence(M_.maximum_endo_lag+1,order_var)');
|
||||
k1 = find(lead_lag_incidence(M_.maximum_endo_lag+2,order_var)');
|
||||
hu = dr.ghu(nstatic+[1:npred],:);
|
||||
hud = dr.ghud{1}(nstatic+1:nstatic+npred,:);
|
||||
zx = [eye(npred);dr.ghx(k0,:);gx*dr.Gy;zeros(M_.exo_nbr+M_.exo_det_nbr, ...
|
||||
npred)];
|
||||
zu = [zeros(npred,M_.exo_nbr); dr.ghu(k0,:); gx*hu; zeros(M_.exo_nbr+M_.exo_det_nbr, ...
|
||||
hu = dr.ghu(nstatic+[1:nspred],:);
|
||||
hud = dr.ghud{1}(nstatic+1:nstatic+nspred,:);
|
||||
zx = [eye(nspred);dr.ghx(k0,:);gx*dr.Gy;zeros(M_.exo_nbr+M_.exo_det_nbr, ...
|
||||
nspred)];
|
||||
zu = [zeros(nspred,M_.exo_nbr); dr.ghu(k0,:); gx*hu; zeros(M_.exo_nbr+M_.exo_det_nbr, ...
|
||||
M_.exo_nbr)];
|
||||
zud=[zeros(npred,M_.exo_det_nbr);dr.ghud{1};gx(:,1:npred)*hud;zeros(M_.exo_nbr,M_.exo_det_nbr);eye(M_.exo_det_nbr)];
|
||||
zud=[zeros(nspred,M_.exo_det_nbr);dr.ghud{1};gx(:,1:nspred)*hud;zeros(M_.exo_nbr,M_.exo_det_nbr);eye(M_.exo_det_nbr)];
|
||||
R1 = hessian1*kron(zx,zud);
|
||||
dr.ghxud = cell(M_.exo_det_length,1);
|
||||
kf = [M_.endo_nbr-nfwrd-nboth+1:M_.endo_nbr];
|
||||
kp = nstatic+[1:npred];
|
||||
kp = nstatic+[1:nspred];
|
||||
dr.ghxud{1} = -M1*(R1+f1*dr.ghxx(kf,:)*kron(dr.ghx(kp,:),dr.ghud{1}(kp,:)));
|
||||
Eud = eye(M_.exo_det_nbr);
|
||||
for i = 2:M_.exo_det_length
|
||||
hudi = dr.ghud{i}(kp,:);
|
||||
zudi=[zeros(npred,M_.exo_det_nbr);dr.ghud{i};gx(:,1:npred)*hudi;zeros(M_.exo_nbr+M_.exo_det_nbr,M_.exo_det_nbr)];
|
||||
zudi=[zeros(nspred,M_.exo_det_nbr);dr.ghud{i};gx(:,1:nspred)*hudi;zeros(M_.exo_nbr+M_.exo_det_nbr,M_.exo_det_nbr)];
|
||||
R2 = hessian1*kron(zx,zudi);
|
||||
dr.ghxud{i} = -M2*(dr.ghxud{i-1}(kf,:)*kron(dr.Gy,Eud)+dr.ghxx(kf,:)*kron(dr.ghx(kp,:),dr.ghud{i}(kp,:)))-M1*R2;
|
||||
end
|
||||
|
@ -231,7 +231,7 @@ if M_.exo_det_nbr > 0
|
|||
Eud = eye(M_.exo_det_nbr);
|
||||
for i = 2:M_.exo_det_length
|
||||
hudi = dr.ghud{i}(kp,:);
|
||||
zudi=[zeros(npred,M_.exo_det_nbr);dr.ghud{i};gx(:,1:npred)*hudi;zeros(M_.exo_nbr+M_.exo_det_nbr,M_.exo_det_nbr)];
|
||||
zudi=[zeros(nspred,M_.exo_det_nbr);dr.ghud{i};gx(:,1:nspred)*hudi;zeros(M_.exo_nbr+M_.exo_det_nbr,M_.exo_det_nbr)];
|
||||
R2 = hessian1*kron(zu,zudi);
|
||||
dr.ghuud{i} = -M2*dr.ghxud{i-1}(kf,:)*kron(hu,Eud)-M1*R2;
|
||||
end
|
||||
|
@ -239,8 +239,8 @@ if M_.exo_det_nbr > 0
|
|||
dr.ghudud = cell(M_.exo_det_length,M_.exo_det_length);
|
||||
dr.ghudud{1,1} = -M1*R1-M2*dr.ghxx(kf,:)*kron(hud,hud);
|
||||
for i = 2:M_.exo_det_length
|
||||
hudi = dr.ghud{i}(nstatic+1:nstatic+npred,:);
|
||||
zudi=[zeros(npred,M_.exo_det_nbr);dr.ghud{i};gx(:,1:npred)*hudi+dr.ghud{i-1}(kf,:);zeros(M_.exo_nbr+M_.exo_det_nbr,M_.exo_det_nbr)];
|
||||
hudi = dr.ghud{i}(nstatic+1:nstatic+nspred,:);
|
||||
zudi=[zeros(nspred,M_.exo_det_nbr);dr.ghud{i};gx(:,1:nspred)*hudi+dr.ghud{i-1}(kf,:);zeros(M_.exo_nbr+M_.exo_det_nbr,M_.exo_det_nbr)];
|
||||
R2 = hessian1*kron(zudi,zudi);
|
||||
dr.ghudud{i,i} = -M2*(dr.ghudud{i-1,i-1}(kf,:)+...
|
||||
2*dr.ghxud{i-1}(kf,:)*kron(hudi,Eud) ...
|
||||
|
@ -251,7 +251,7 @@ if M_.exo_det_nbr > 0
|
|||
-M1*R2;
|
||||
for j=2:i-1
|
||||
hudj = dr.ghud{j}(kp,:);
|
||||
zudj=[zeros(npred,M_.exo_det_nbr);dr.ghud{j};gx(:,1:npred)*hudj;zeros(M_.exo_nbr+M_.exo_det_nbr,M_.exo_det_nbr)];
|
||||
zudj=[zeros(nspred,M_.exo_det_nbr);dr.ghud{j};gx(:,1:nspred)*hudj;zeros(M_.exo_nbr+M_.exo_det_nbr,M_.exo_det_nbr)];
|
||||
R2 = hessian1*kron(zudj,zudi);
|
||||
dr.ghudud{j,i} = -M2*(dr.ghudud{j-1,i-1}(kf,:)+dr.ghxud{j-1}(kf,:)* ...
|
||||
kron(hudi,Eud)+dr.ghxud{i-1}(kf,:)* ...
|
||||
|
|
|
@ -24,7 +24,7 @@ function [Gamma_y,stationary_vars] = th_autocovariances(dr,ivar,M_,options_,node
|
|||
% SPECIAL REQUIREMENTS
|
||||
%
|
||||
|
||||
% Copyright (C) 2001-2011 Dynare Team
|
||||
% Copyright (C) 2001-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -65,15 +65,15 @@ nvar = size(ivar,1);
|
|||
|
||||
ghx = dr.ghx;
|
||||
ghu = dr.ghu;
|
||||
npred = dr.npred;
|
||||
nstatic = dr.nstatic;
|
||||
nspred = M_.nspred;
|
||||
nstatic = M_.nstatic;
|
||||
|
||||
nx = size(ghx,2);
|
||||
if options_.block == 0
|
||||
%order_var = dr.order_var;
|
||||
inv_order_var = dr.inv_order_var;
|
||||
kstate = dr.kstate;
|
||||
ikx = [nstatic+1:nstatic+npred];
|
||||
ikx = [nstatic+1:nstatic+nspred];
|
||||
k0 = kstate(find(kstate(:,2) <= M_.maximum_lag+1),:);
|
||||
i0 = find(k0(:,2) == M_.maximum_lag+1);
|
||||
i00 = i0;
|
||||
|
@ -96,13 +96,12 @@ else
|
|||
trend = 1:M_.endo_nbr;
|
||||
inv_order_var = trend(M_.block_structure.variable_reordered);
|
||||
ghu1(1:length(dr.state_var),:) = ghu(dr.state_var,:);
|
||||
npred = npred + dr.nboth;
|
||||
end;
|
||||
b = ghu1*M_.Sigma_e*ghu1';
|
||||
|
||||
|
||||
if options_.block == 0
|
||||
ipred = nstatic+(1:npred)';
|
||||
ipred = nstatic+(1:nspred)';
|
||||
else
|
||||
ipred = dr.state_var;
|
||||
end;
|
||||
|
|
|
@ -13,7 +13,7 @@ function [A,B] = transition_matrix(dr, varargin)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2003-2009 Dynare Team
|
||||
% Copyright (C) 2003-2012 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -41,7 +41,7 @@ ykmin_ = M_.maximum_endo_lag;
|
|||
|
||||
nx = size(dr.ghx,2);
|
||||
kstate = dr.kstate;
|
||||
ikx = [dr.nstatic+1:dr.nstatic+dr.npred];
|
||||
ikx = [M_.nstatic+1:M_.nstatic+M_.nspred];
|
||||
|
||||
A = zeros(nx,nx);
|
||||
k0 = kstate(find(kstate(:,2) <= ykmin_+1),:);
|
||||
|
|
|
@ -130,17 +130,17 @@ extern "C" {
|
|||
if (!ySteady.isFinite())
|
||||
DYN_MEX_FUNC_ERR_MSG_TXT("The steady state vector contains NaN or Inf");
|
||||
|
||||
mxFldp = mxGetField(dr, 0, "nstatic");
|
||||
mxFldp = mxGetField(M_, 0, "nstatic");
|
||||
const int nStat = (int) mxGetScalar(mxFldp);
|
||||
mxFldp = mxGetField(dr, 0, "npred");
|
||||
int nPred = (int) mxGetScalar(mxFldp);
|
||||
mxFldp = mxGetField(dr, 0, "nspred");
|
||||
mxFldp = mxGetField(M_, 0, "npred");
|
||||
const int nPred = (int) mxGetScalar(mxFldp);
|
||||
mxFldp = mxGetField(M_, 0, "nspred");
|
||||
const int nsPred = (int) mxGetScalar(mxFldp);
|
||||
mxFldp = mxGetField(dr, 0, "nboth");
|
||||
mxFldp = mxGetField(M_, 0, "nboth");
|
||||
const int nBoth = (int) mxGetScalar(mxFldp);
|
||||
mxFldp = mxGetField(dr, 0, "nfwrd");
|
||||
mxFldp = mxGetField(M_, 0, "nfwrd");
|
||||
const int nForw = (int) mxGetScalar(mxFldp);
|
||||
mxFldp = mxGetField(dr, 0, "nsfwrd");
|
||||
mxFldp = mxGetField(M_, 0, "nsfwrd");
|
||||
const int nsForw = (int) mxGetScalar(mxFldp);
|
||||
|
||||
mxFldp = mxGetField(M_, 0, "exo_nbr");
|
||||
|
@ -150,8 +150,6 @@ extern "C" {
|
|||
mxFldp = mxGetField(M_, 0, "param_nbr");
|
||||
const int nPar = (int) mxGetScalar(mxFldp);
|
||||
|
||||
nPred -= nBoth; // correct nPred for nBoth.
|
||||
|
||||
mxFldp = mxGetField(dr, 0, "order_var");
|
||||
dparams = mxGetPr(mxFldp);
|
||||
npar = (int) mxGetM(mxFldp);
|
||||
|
|
|
@ -2341,7 +2341,10 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
|
|||
output << "M_.nstatic = " << nstatic << ";" << endl
|
||||
<< "M_.nfwrd = " << nfwrd << ";" << endl
|
||||
<< "M_.npred = " << npred << ";" << endl
|
||||
<< "M_.nboth = " << nboth << ";" << endl;
|
||||
<< "M_.nboth = " << nboth << ";" << endl
|
||||
<< "M_.nsfwrd = " << nfwrd+nboth << ";" << endl
|
||||
<< "M_.nspred = " << npred+nboth << ";" << endl
|
||||
<< "M_.ndynamic = " << npred+nboth+nfwrd << ";" << endl;
|
||||
|
||||
// Write equation tags
|
||||
output << "M_.equations_tags = {" << endl;
|
||||
|
|
|
@ -49,9 +49,9 @@ ramsey_policy(order=1,irf=0,planner_discount=0.95);
|
|||
|
||||
dr2 = mult_elimination({'R'},M_,options_,oo_);
|
||||
|
||||
k1 = oo_.dr.nstatic+(1:oo_.dr.npred);
|
||||
k1 = M_.nstatic+(1:M_.nspred);
|
||||
k2 = strmatch('MULT_',M_.endo_names(oo_.dr.order_var(k1),:));
|
||||
k3 = k1(setdiff(1:oo_.dr.npred,k2));
|
||||
k3 = k1(setdiff(1:M_.nspred,k2));
|
||||
k4 = oo_.dr.order_var(k3);
|
||||
|
||||
V0 = oo_.var(k4,k4);
|
||||
|
|
Loading…
Reference in New Issue