Merge branch 'master' into fix-mcmc-algorithm

time-shift
Stéphane Adjemian (Scylla) 2013-11-22 16:56:23 +01:00
commit 43f11de27b
22 changed files with 126 additions and 115 deletions

View File

@ -5300,10 +5300,10 @@ where @var{FORECAST_OBJECT} is one of the following@footnote{See @ref{forecast}
Mean of the posterior forecast distribution
@item HPDinf/HPDsup
Upper/lower bound of the 90\% HPD interval taking into account only parameter uncertainty
Upper/lower bound of the 90% HPD interval taking into account only parameter uncertainty
@item HPDTotalinf/HPDTotalsup
Upper/lower bound of the 90\% HPD interval taking into account both parameter and future shock uncertainty
Upper/lower bound of the 90% HPD interval taking into account both parameter and future shock uncertainty
@end table

View File

@ -38,7 +38,7 @@ function [mean,variance] = GetPosteriorMeanVariance(M,drop)
n = n + m;
continue
elseif n < drop*NbrDraws
k = drop*NbrDraws - n + 1;
k = ceil(drop*NbrDraws - n + 1);
x2 = o.x2(k:end,:);
else
x2 = o.x2;
@ -51,4 +51,4 @@ function [mean,variance] = GetPosteriorMeanVariance(M,drop)
n = n + m;
nkept = nkept + p;
end
end
end

View File

@ -65,7 +65,7 @@ if nvx
estim_params_.var_exo(calibrated_par_index,2)=xparam1_calib(offset+calibrated_par_index,1);
%find parameters that are calibrated and do not violate inverse gamma prior
xparam1_properly_calibrated(offset+calibrated_par_index,1) = xparam1_calib(offset+calibrated_par_index,1);
inv_gamma_violation=find(estim_params_.var_exo(calibrated_par_index,2)==0 & estim_params_.var_exo(calibrated_par_index,4)==0);
inv_gamma_violation=find(estim_params_.var_exo(calibrated_par_index,2)==0 & estim_params_.var_exo(calibrated_par_index,5)==4);
if inv_gamma_violation
estim_params_.var_exo(calibrated_par_index(inv_gamma_violation),2)=NaN;
xparam1_properly_calibrated(offset+calibrated_par_index(inv_gamma_violation),1)=NaN;

View File

@ -52,7 +52,7 @@ M_.Sigma_e = zeros(size(Sigma_e));
info = 0;
if options_.steadystate_flag
[oo_.steady_state,M.params,info] = ...
[oo_.steady_state,M_.params,info] = ...
evaluate_steady_state(oo_.steady_state,M_,options_,oo_,0);
end

View File

@ -23,85 +23,52 @@ if nargin<2
info = 0;
end
if iscell(name)
nn = length(name);
else
nn = 1;
end
if iscell(name)
tex = cell(nn,1);
end
for i=1:nn
if info
if iscell(name)
tex(i) = {name{i}};
id = findstr(name{i},'_');
len = length(tex{i});
else
tex = name;
id = findstr(name,'_');
len = length(tex);
end
if isempty(id)
continue
end
n = length(id);
if id(1)==1
if iscell(name)
tex(i) = {['\_', tex{i}(2:end)]};
else
tex = ['\_', tex(2:end)];
end
if n>1
id = id(2:end)+1;
n = n-1;
len = len+1;
else
continue
end
end
if id(end)==len
if iscell(name)
tex(i) = {[tex{i}(1:end-1) '\_']};
else
tex = [tex(1:end-1) '\_'];
end
if n>1
id = id(1:end-1);
n = n-1;
else
continue
end
end
if n==1
if iscell(name)
tex(i) = {[ tex{i}(1:(id-1)) '_{' tex{i}((id+1):end) '}' ]};
else
tex = [ tex(1:(id-1)) '_{' tex((id+1):end) '}' ];
end
continue
else
for j=1:n-1
if iscell(name)
tex(i) = {[tex{i}(1:id(j)-1) '\_' tex{i}((id(j)+1):end)]};
else
tex = [tex(1:id(j)-1) '\_' tex((id(j)+1):end)];
end
id = id(2:end)+1;
end
if iscell(name)
tex(i) = {[tex{i}(1:(id-1)) '_{' tex{i}((id+1):end) '}']};
else
tex = [tex(1:(id-1)) '_{' tex((id+1):end) '}'];
end
end
if info
if iscell(name)
nn = length(name);
else
nn = 1;
end
end
tex = regexprep(name, '_', '\\_');
if info
for i=1:nn
if iscell(name)
tex(i) = {strrep(name{i}, '_', '\_')};
texname = tex{i};
else
tex = strrep(name, '_', '\_');
texname = tex;
end
idx = strfind(texname,'_');
ndx = length(idx);
ntx = length(texname);
if ndx
gotonextcondition = 1;
if isequal(ndx,1) && ~isequal(idx,2) && ~isequal(idx,ntx)
texname = [ texname(1:idx-2) '_{' texname(idx+1:end) '}'];
gotonextcondition = 0;
end
if gotonextcondition && isequal(ndx,2) && ~isequal(idx(1),2) && isequal(idx(2),ntx)
texname = [ texname(1:idx(1)-2) '_{' texname(idx(1)+1:end) '}' ];
gotonextcondition = 0;
end
if gotonextcondition && isequal(ndx,2) && idx(2)<ntx
texname = [ texname(1:idx(2)-2) '_{' texname(idx(2)+1:end) '}' ];
gotonextcondition = 0;
end
if gotonextcondition && ndx>2
if idx(end)<ntx
texname = [ texname(1:idx(end)-2) '_{' texname(idx(end)+1:end) '}' ];
else
texname = [ texname(1:idx(end-1)-2) '_{' texname(idx(end-1)+1:end) '}' ];
end
end
if iscell(name)
tex(i) = { texname };
else
tex = texname;
end
end
end
end
@ -211,4 +178,16 @@ end
%$ end
%$
%$ T = all(t);
%@eof:3
%@eof:3
%@test:4
%$ pwd
%$ try
%$ db = dseries('csv/dd.csv');
%$ t(1) = 1;
%$ catch
%$ t(1) = 0;
%$ end
%$
%$ T = all(t);
%@eof:4

View File

@ -19,6 +19,8 @@
#include "SteadyStateSolver.hh"
const double SteadyStateSolver::tolerance = 1e-7;
SteadyStateSolver::SteadyStateSolver(const std::string &basename, size_t n_endo_arg)
: static_dll(basename), n_endo(n_endo_arg), residual(n_endo), g1(n_endo)
{

View File

@ -48,7 +48,7 @@ private:
static int static_df(const gsl_vector *yy, void *p, gsl_matrix *J);
static int static_fdf(const gsl_vector *yy, void *p, gsl_vector *F, gsl_matrix *J);
const static double tolerance = 1e-7;
const static double tolerance;
const static size_t max_iterations = 1000;
public:
class SteadyStateException

View File

@ -261,11 +261,9 @@ DiscretionaryPolicyStatement::writeOutput(ostream &output, const string &basenam
}
EstimationStatement::EstimationStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg,
const SymbolTable &symbol_table_arg) :
const OptionsList &options_list_arg) :
symbol_list(symbol_list_arg),
options_list(options_list_arg),
symbol_table(symbol_table_arg)
options_list(options_list_arg)
{
}

View File

@ -157,11 +157,9 @@ class EstimationStatement : public Statement
private:
const SymbolList symbol_list;
const OptionsList options_list;
const SymbolTable &symbol_table;
public:
EstimationStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg,
const SymbolTable &symbol_table);
const OptionsList &options_list_arg);
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
virtual void writeOutput(ostream &output, const string &basename) const;
};

View File

@ -1172,6 +1172,8 @@ estimated_elem3 : expression_or_empty COMMA expression_or_empty
estimated_params_init : ESTIMATED_PARAMS_INIT ';' estimated_init_list END ';'
{ driver.estimated_params_init(); }
| ESTIMATED_PARAMS_INIT '(' USE_CALIBRATION ')' ';' END ';'
{ driver.estimated_params_init(true); }
| ESTIMATED_PARAMS_INIT '(' USE_CALIBRATION ')' ';' estimated_init_list END ';'
{ driver.estimated_params_init(true); }
;

View File

@ -17,8 +17,6 @@
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
using namespace std;
#include <iostream>
#include <sstream>
#include <fstream>

View File

@ -17,8 +17,6 @@
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
using namespace std;
#include <iostream>
#include "ParsingDriver.hh"

View File

@ -115,7 +115,7 @@ class ExprNode
friend class DynamicModel;
friend class StaticModel;
friend class ModelTree;
friend class ExprNodeLess;
friend struct ExprNodeLess;
friend class NumConstNode;
friend class VariableNode;
friend class UnaryOpNode;

View File

@ -1540,7 +1540,7 @@ ParsingDriver::set_corr_options(string *name1, string *name2, string *subsample_
void
ParsingDriver::run_estimation()
{
mod_file->addStatement(new EstimationStatement(symbol_list, options_list, mod_file->symbol_table));
mod_file->addStatement(new EstimationStatement(symbol_list, options_list));
symbol_list.clear();
options_list.clear();
}
@ -1948,7 +1948,7 @@ ParsingDriver::plot_conditional_forecast(string *periods)
void
ParsingDriver::conditional_forecast_paths()
{
mod_file->addStatement(new ConditionalForecastPathsStatement(det_shocks, mod_file->symbol_table));
mod_file->addStatement(new ConditionalForecastPathsStatement(det_shocks));
det_shocks.clear();
}

View File

@ -17,8 +17,6 @@
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
using namespace std;
#include <cassert>
#include <cstdlib>
#include <iostream>
@ -314,9 +312,8 @@ MShocksStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidat
mod_file_struct.shocks_present_but_simul_not_yet = true;
}
ConditionalForecastPathsStatement::ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg, const SymbolTable &symbol_table_arg) :
ConditionalForecastPathsStatement::ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg) :
paths(paths_arg),
symbol_table(symbol_table_arg),
path_length(-1)
{
}

View File

@ -90,11 +90,9 @@ class ConditionalForecastPathsStatement : public Statement
{
private:
const AbstractShocksStatement::det_shocks_t paths;
const SymbolTable &symbol_table;
int path_length;
public:
ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg,
const SymbolTable &symbol_table_arg);
ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg);
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
virtual void writeOutput(ostream &output, const string &basename) const;
};

View File

@ -20,8 +20,6 @@
#ifndef _SIGMAEINITIALIZATION_HH
#define _SIGMAEINITIALIZATION_HH
using namespace std;
#include <string>
#include <vector>

View File

@ -20,8 +20,6 @@
#ifndef _STATEMENT_HH
#define _STATEMENT_HH
using namespace std;
#include <ostream>
#include <string>
#include <map>

View File

@ -20,12 +20,12 @@
#ifndef _SYMBOL_LIST_HH
#define _SYMBOL_LIST_HH
using namespace std;
#include <string>
#include <vector>
#include <ostream>
using namespace std;
//! Used to store a list of symbols
/*! This class is no more than a vector<string>, with a pretty-printer for Matlab */
class SymbolList

View File

@ -17,8 +17,6 @@
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
using namespace std;
#include "WarningConsolidation.hh"
#include <ostream>

View File

@ -20,12 +20,12 @@
#ifndef _WARNINGCONSOLIDATION_HH
#define _WARNINGCONSOLIDATION_HH
using namespace std;
#include <sstream>
#include <string>
#include "location.hh"
using namespace std;
//! Stores Warnings issued by the Preprocessor
class WarningConsolidation
{

47
tests/csv/dd.csv Normal file

File diff suppressed because one or more lines are too long