Commit c121aa14 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

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_.nfwrd
parent 92727ed7
......@@ -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
\ No newline at end of file
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;
\ No newline at end of file
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;
\ No newline at end of file
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;
\ No newline at end of file
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;
\ No newline at end of file
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
\ No newline at end of file
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_