Commit 3459b08c authored by Ferhat Mihoubi's avatar Ferhat Mihoubi
Browse files

- Corrects the first order approximation of block-decomposed models

- The block-decomposed models can now be estimated
parent fe1b2411
......@@ -21,9 +21,7 @@ function [r, g1] = block_mfs_steadystate(y, b, y_all)
global M_ oo_
indx = M_.blocksMFS{b};
y_all(indx) = y;
y_all(M_.blocksMFS{b}) = y;
x = [oo_.exo_steady_state; oo_.exo_det_steady_state];
eval(['[r,g1] = ' M_.fname '_static(b, y_all, x, M_.params);']);
......
......@@ -55,7 +55,7 @@ oo_.exo_simul = tempex;
eigenvalues_ = dr.eigval;
if (options_.block)
nyf = dr.nfwrd+dr.nboth;
nyf = dr.nyf;
else
nyf = nnz(dr.kstate(:,2)>M_.maximum_endo_lag+1);
end;
......
......@@ -109,7 +109,11 @@ for k=1:nx
end;
str = sprintf('%-20s',str1);
for i=1:nvar
x = dr.ghx(ivar(i),k);
if options_.block
x = dr.ghx(i,k);
else
x = dr.ghx(ivar(i),k);
end;
if abs(x) > 1e-6
flag = 1;
str = [str sprintf('%16.6f',x)];
......@@ -128,7 +132,11 @@ for k=1:nu
flag = 0;
str = sprintf('%-20s',M_.exo_names(k,:));
for i=1:nvar
x = dr.ghu(ivar(i),k);
if options_.block
x = dr.ghu(i,k);
else
x = dr.ghu(ivar(i),k);
end;
if abs(x) > 1e-6
flag = 1;
str = [str sprintf('%16.6f',x)];
......
This diff is collapsed.
......@@ -143,7 +143,11 @@ if isequal(options_.mode_compute,0) && isempty(options_.mode_file) && options_.m
end
end
for i=bayestopt_.smoother_saved_var_list'
i1 = dr.order_var(bayestopt_.smoother_var_list(i));
if options_.block == 1
i1 = M_.block_structure.variable_reordered(bayestopt_.smoother_var_list(i));
else
i1 = dr.order_var(bayestopt_.smoother_var_list(i));
end;
eval(['oo_.SmoothedVariables.' deblank(M_.endo_names(i1,:)) ' = atT(i,:)'';']);
eval(['oo_.FilteredVariables.' deblank(M_.endo_names(i1,:)) ' = squeeze(aK(1,i,:));']);
eval(['oo_.UpdatedVariables.' deblank(M_.endo_names(i1,:)) ' = updated_variables(i,:)'';']);
......@@ -937,7 +941,11 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
end
end
for i=bayestopt_.smoother_saved_var_list'
i1 = dr.order_var(bayestopt_.smoother_var_list(i));
if options_.block == 1
i1 = M_.block_structure.variable_reordered(bayestopt_.smoother_var_list(i));
else
i1 = dr.order_var(bayestopt_.smoother_var_list(i));
end;
eval(['oo_.SmoothedVariables.' deblank(M_.endo_names(i1,:)) ' = atT(i,:)'';']);
eval(['oo_.FilteredVariables.' deblank(M_.endo_names(i1,:)) ' = squeeze(aK(1,i,:));']);
eval(['oo_.UpdatedVariables.' deblank(M_.endo_names(i1,:)) ...
......
......@@ -208,19 +208,32 @@ for i=1:n_varobs
k1 = [k1 strmatch(deblank(options_.varobs(i,:)),M_.endo_names, 'exact')];
end
% Define union of observed and state variables
k2 = union(var_obs_index',[dr.nstatic+1:dr.nstatic+dr.npred]', '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);
% 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.
bayestopt_.mf2 = var_obs_index;
bayestopt_.mfys = k1;
[junk,ic] = intersect(k2,nstatic+(1:npred)');
oo_.dr.restrict_columns = [ic; length(k2)+(1:nspred-npred)'];
if options_.block == 1
[k2, i_posA, i_posB] = union(k1', M_.state_var', 'rows');
% Set restrict_state to postion of observed + state variables in expanded state vector.
oo_.dr.restrict_var_list = [k1(i_posA) M_.state_var(sort(i_posB))];
% set mf0 to positions of state variables in restricted state vector for likelihood computation.
[junk,bayestopt_.mf0] = ismember(M_.state_var',oo_.dr.restrict_var_list);
% Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
[junk,bayestopt_.mf1] = ismember(k1,oo_.dr.restrict_var_list);
% Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing.
bayestopt_.mf2 = var_obs_index;
bayestopt_.mfys = k1;
oo_.dr.restrict_columns = [size(i_posA,1)+(1:size(M_.state_var,2))];
else
k2 = union(var_obs_index',[dr.nstatic+1:dr.nstatic+dr.npred]', '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);
% 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.
bayestopt_.mf2 = var_obs_index;
bayestopt_.mfys = k1;
[junk,ic] = intersect(k2,nstatic+(1:npred)');
oo_.dr.restrict_columns = [ic; length(k2)+(1:nspred-npred)'];
end;
k3 = [];
if options_.selected_variables_only
......
......@@ -31,6 +31,7 @@ function dr=set_state_space(dr,M_)
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global options_
max_lead = M_.maximum_endo_lead;
max_lag = M_.maximum_endo_lag;
......@@ -54,7 +55,11 @@ nboth = length(both_var);
npred = length(pred_var);
nfwrd = length(fwrd_var);
nstatic = length(stat_var);
order_var = [ stat_var(:); pred_var(:); both_var(:); fwrd_var(:)];
if options_.block == 1
order_var = M_.block_structure.variable_reordered;
else
order_var = [ stat_var(:); pred_var(:); both_var(:); fwrd_var(:)];
end;
inv_order_var(order_var) = (1:endo_nbr);
% building kmask for z state vector in t+1
......
......@@ -67,8 +67,13 @@ if options_.k_order_solver% Call dynare++ routines.
y_(dr.order_var,:) = y_;
else
if options_.block
k2 = [dr.glb_pred dr.glb_both];
if M_.maximum_lag > 0
k2 = dr.state_var;
else
k2 = [];
end;
order_var = 1:M_.endo_nbr;
dr.order_var = order_var;
else
k2 = dr.kstate(find(dr.kstate(:,2) <= M_.maximum_lag+1),[1 2]);
k2 = k2(:,1)+(M_.maximum_lag+1-k2(:,2))*M_.endo_nbr;
......
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