diff --git a/matlab/dr_block.m b/matlab/dr_block.m
index e09eec429..7eee88acd 100644
--- a/matlab/dr_block.m
+++ b/matlab/dr_block.m
@@ -315,13 +315,17 @@ for i = 1:Size;
dr.eigval = [dr.eigval ; data(i).eigval];
case 6
%% ------------------------------------------------------------------
- %Solve Forward complete
+ %Solve Forward complete
+ if (maximum_lag > 0)
+ ghx = - jacob(: , n_pred + 1 : n_pred + n_static ...
+ + n_pred + n_both) \ jacob(: , 1 : n_pred);
+ else
+ ghx = 0;
+ end;
if maximum_lag > 0 && n_pred > 0
- data(i).eigval = eig(- jacob(: , 1 : n_pred) / ...
- jacob(: , (n_pred + n_static + 1 : n_pred + n_static + n_pred )));
+ data(i).eigval = -eig(ghx(n_static+1:end,:));
data(i).rank = 0;
- full_rank = (rcond(jacob(: , (n_pred + n_static + 1 : n_pred ...
- + n_static + n_pred ))) > 1e-9);
+ full_rank = (rcond(ghx(n_static+1:end,:)) > 1e-9);
else
data(i).eigval = [];
data(i).rank = 0;
@@ -330,11 +334,6 @@ for i = 1:Size;
dr.eigval = [dr.eigval ; data(i).eigval];
dr.full_rank = dr.full_rank && full_rank;
if task ~= 1
- if (maximum_lag > 0)
- ghx = - jacob(: , 1 : n_pred) / jacob(: , n_pred + n_static + 1 : n_pred + n_static + n_pred + n_both);
- else
- ghx = 0;
- end;
if other_endo_nbr
fx = data(i).g1_o;
% retrieves the derivatives with respect to endogenous
diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m
index bcd3cff40..9e75c5995 100644
--- a/matlab/global_initialization.m
+++ b/matlab/global_initialization.m
@@ -363,7 +363,7 @@ estimation_info.structural_innovation_corr_prior_index = {};
estimation_info.structural_innovation_corr_options_index = {};
estimation_info.structural_innovation_corr.range_index = {};
estimation_info.joint_parameter_prior_index = {};
-estimation_info.joint_parameter = cell2table(cell(0,11));
+estimation_info.joint_parameter = {'index','domain','interval','mean','median','mode','shape','shift','stdev','truncate','variance'};
options_.initial_period = NaN; %dates(1,1);
options_.dataset.file = [];
options_.dataset.series = [];
diff --git a/matlab/ms-sbvar/identification/exclusions.m b/matlab/ms-sbvar/identification/exclusions.m
index 9632356fe..a2447b1ba 100644
--- a/matlab/ms-sbvar/identification/exclusions.m
+++ b/matlab/ms-sbvar/identification/exclusions.m
@@ -1,4 +1,4 @@
-function [Ui,Vi,n0,np,ixmC0Pres] = exclusions(nvar,nexo,options_ms)
+function [Ui,Vi,n0,np,ixmC0Pres,Qi] = exclusions(nvar,nexo,options_ms)
% function [Ui,Vi,n0,np,ixmC0Pres] = exclusions(nvar,nexo,options_ms)
%
% INPUTS
diff --git a/matlab/ms-sbvar/sbvar_global_identification_check.m b/matlab/ms-sbvar/sbvar_global_identification_check.m
new file mode 100644
index 000000000..642220f54
--- /dev/null
+++ b/matlab/ms-sbvar/sbvar_global_identification_check.m
@@ -0,0 +1,77 @@
+function indent = sbvar_global_identification_check(options_)
+% function sbvar_global_identification_check(options_.ms)
+%
+% INPUTS
+% options_ms: (struct) options
+%
+% OUTPUTS
+% ident: (boolean) false = not identified; true = identified
+%
+% SPECIAL REQUIREMENTS
+% none
+
+% Copyright (C) 2015 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with Dynare. If not, see .
+
+ident = false;
+
+if isequal(options_.ms.restriction_fname, 'upper_cholesky') || ...
+ isequal(options_.ms.restriction_fname, 'lower_cholesky')
+ ident = true;
+ if ~options_.noprint
+ disp(' ')
+ disp('SBVAR: Cholesky identification is always identified')
+ disp(' ')
+ end
+ return
+end
+nvar = length(options_.varobs); % number of endogenous variables
+nexo = 1;
+
+[Uiconst,Viconst,n0,np,ixmC0Pres,Qi] = exclusions(nvar,nexo,options_.ms );
+
+% order column constraints by rank
+Qranks = zeros(nvar,2);
+for j=1:nvar
+ Qranks(j,:) = [j,rank(Qi{j})];
+end
+Qranks = sortrows(Qranks,-2);
+
+ident = true;
+
+for j=1:nvar
+ i = Qranks(j,1);
+ for k=1:1
+ M = [Qi{i}*rand(size(Qi{i},1),nvar);[eye(j) zeros(j,nvar- ...
+ j)]];
+ disp([j,k,rank(M)])
+ if rank(M) < nvar
+ ident = false
+ break
+ end
+ end
+end
+
+if ~options_.noprint
+ disp(' ')
+ if ident
+ disp('The sufficient condition for SBVAR identification is met')
+ else
+ disp('WARNGING: The sufficient condition for SBVAR identification is not met')
+ end
+ disp(' ')
+end
\ No newline at end of file
diff --git a/matlab/perfect-foresight-models/sim1_purely_forward.m b/matlab/perfect-foresight-models/sim1_purely_forward.m
index 8a8fa3294..34b60f510 100644
--- a/matlab/perfect-foresight-models/sim1_purely_forward.m
+++ b/matlab/perfect-foresight-models/sim1_purely_forward.m
@@ -37,7 +37,7 @@ function oo_ = sim1_purely_forward(options_, M_, oo_)
1, options_.gstep, options_.solve_tolf, ...
options_.solve_tolx, options_.simul.maxit, ...
options_.debug,oo_.exo_simul, M_.params, oo_.steady_state, ...
- it);
+ it+M_.maximum_lag);
if info
oo_.deterministic_simulation.status = 0;
diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc
index 2d7b1ffc3..e16d11354 100644
--- a/preprocessor/ComputingTasks.cc
+++ b/preprocessor/ComputingTasks.cc
@@ -2157,7 +2157,7 @@ JointPriorStatement::writeOutput(ostream &output, const string &basename) const
writeOutputHelper(output, "truncate", lhs_field);
writeOutputHelper(output, "variance", lhs_field);
- output << "estimation_info.joint_parameter_tmp = table(key, ..." << endl
+ output << "estimation_info.joint_parameter_tmp = [key, ..." << endl
<< " " << lhs_field << ".domain , ..." << endl
<< " " << lhs_field << ".interval , ..." << endl
<< " " << lhs_field << ".mean , ..." << endl
@@ -2167,15 +2167,9 @@ JointPriorStatement::writeOutput(ostream &output, const string &basename) const
<< " " << lhs_field << ".shift , ..." << endl
<< " " << lhs_field << ".stdev , ..." << endl
<< " " << lhs_field << ".truncate , ..." << endl
- << " " << lhs_field << ".variance, ..." << endl
- << " 'VariableNames',{'index','domain','interval','mean','median','mode','shape','shift','stdev','truncate','variance'});" << endl;
-
- output << "if height(estimation_info.joint_parameter)" << endl
- << " estimation_info.joint_parameter = [estimation_info.joint_parameter; estimation_info.joint_parameter_tmp];" << endl
- << "else" << endl
- << " estimation_info.joint_parameter = estimation_info.joint_parameter_tmp;" << endl
- << "end" << endl
- << "clear estimation_info.joint_parameter_tmp;" << endl;
+ << " " << lhs_field << ".variance];" << endl
+ << "estimation_info.joint_parameter = [estimation_info.joint_parameter; estimation_info.joint_parameter_tmp];" << endl
+ << "estimation_info=rmfield(estimation_info, 'joint_parameter_tmp');" << endl;
}
void
@@ -2183,10 +2177,14 @@ JointPriorStatement::writeOutputHelper(ostream &output, const string &field, con
{
OptionsList::num_options_t::const_iterator itn = options_list.num_options.find(field);
output << lhs_field << "." << field << " = {";
+ if (field=="variance")
+ output << "{";
if (itn != options_list.num_options.end())
output << itn->second;
else
output << "{}";
+ if (field=="variance")
+ output << "}";
output << "};" << endl;
}
diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc
index e21cf81e8..847fc7e33 100644
--- a/preprocessor/ModFile.cc
+++ b/preprocessor/ModFile.cc
@@ -290,7 +290,7 @@ ModFile::checkPass()
// Check if some exogenous is not used in the model block
set unusedExo = dynamic_model.findUnusedExogenous();
- if (unusedExo.size() > 1)
+ if (unusedExo.size() > 0)
{
warnings << "WARNING: some exogenous (";
for (set::const_iterator it = unusedExo.begin();
diff --git a/tests/ms-sbvar/test_global_identification_FAILURE.mod b/tests/ms-sbvar/test_global_identification_FAILURE.mod
new file mode 100644
index 000000000..8ff9cfddd
--- /dev/null
+++ b/tests/ms-sbvar/test_global_identification_FAILURE.mod
@@ -0,0 +1,16 @@
+// same as test_lower_cholesky.mod, but using exclusion syntax
+var R Pie Y;
+
+varobs Y Pie R;
+
+svar_identification;
+exclusion lag 0;
+equation 1, Pie, Y;
+exclusion lag 1;
+equation 2, Y;
+end;
+
+sbvar_global_identification_check(options_);
+
+sbvar(datafile = data,freq=4,initial_year=1959,final_year=2005,nlags=4);
+
diff --git a/tests/ms-sbvar/test_global_identification_OK.mod b/tests/ms-sbvar/test_global_identification_OK.mod
new file mode 100644
index 000000000..7e54d9223
--- /dev/null
+++ b/tests/ms-sbvar/test_global_identification_OK.mod
@@ -0,0 +1,15 @@
+// same as test_lower_cholesky.mod, but using exclusion syntax
+var R Pie Y;
+
+varobs Y Pie R;
+
+svar_identification;
+exclusion lag 0;
+equation 1, Pie, Y;
+equation 2, Y;
+end;
+
+sbvar_global_identification_check(options_);
+
+sbvar(datafile = data,freq=4,initial_year=1959,final_year=2005,nlags=4);
+