Merge branch 'master' of kirikou.dynare.org:/srv/d_kirikou/git/dynare
commit
d6155b1e96
|
@ -6075,7 +6075,7 @@ line. The main directives are:
|
|||
@item
|
||||
@code{@@#define}, for defining a macro-processor variable,
|
||||
@item
|
||||
@code{@@#if}, @code{@@#then}, @code{@@#else}, @code{@@#endif} for
|
||||
@code{@@#if}, @code{@@#ifdef}, @code{@@#else}, @code{@@#endif} for
|
||||
conditional statements,
|
||||
@item
|
||||
@code{@@#for}, @code{@@#endfor} for constructing loops.
|
||||
|
@ -6218,13 +6218,15 @@ end;
|
|||
@end deffn
|
||||
|
||||
@deffn {Macro directive} @@#if @var{MACRO_EXPRESSION}
|
||||
@deffnx {Macro directive} @@#ifdef @var{MACRO_VARIABLE}
|
||||
@deffnx {Macro directive} @@#else
|
||||
@deffnx {Macro directive} @@#endif
|
||||
Conditional inclusion of some part of the @file{.mod} file.
|
||||
The lines between @code{@@#if} and the next @code{@@#else} or
|
||||
@code{@@#end} is executed only if the condition evaluates to a
|
||||
non-null integer. The @code{@@#else} branch is optional and, if
|
||||
present, is only evaluated if the condition evaluates to @code{0}.
|
||||
The lines between @code{@@#if} or @code{@@#ifdef} and the next
|
||||
@code{@@#else} or @code{@@#endif} is executed only if the condition
|
||||
evaluates to a non-null integer. The @code{@@#else} branch is optional
|
||||
and, if present, is only evaluated if the condition evaluates to
|
||||
@code{0}.
|
||||
|
||||
@examplehead
|
||||
|
||||
|
@ -6242,6 +6244,23 @@ model;
|
|||
end;
|
||||
@end example
|
||||
|
||||
@examplehead
|
||||
|
||||
Choose between two alternative monetary policy rules using a
|
||||
macro-variable. As @code{linear_mon_pol} was not previously defined in
|
||||
this example, the second equation will be chosen:
|
||||
|
||||
@example
|
||||
model;
|
||||
@@#ifdef linear_mon_pol
|
||||
i = w*i(-1) + (1-w)*i_ss + w2*(pie-piestar);
|
||||
@@#else
|
||||
i = i(-1)^w * i_ss^(1-w) * (pie/piestar)^w2;
|
||||
@@#endif
|
||||
...
|
||||
end;
|
||||
@end example
|
||||
|
||||
@end deffn
|
||||
|
||||
@deffn {Macro directive} @@#for @var{MACRO_VARIABLE} in @var{MACRO_EXPRESSION}
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
\begin{itemize}
|
||||
\item file inclusion
|
||||
\item loops (\textit{for} structure)
|
||||
\item conditional inclusion (\textit{if/then/else} structures)
|
||||
\item conditional inclusion (\textit{if/else} structures)
|
||||
\item expression substitution
|
||||
\end{itemize}
|
||||
\item Implemented in Dynare starting from version 4.0
|
||||
|
@ -95,7 +95,7 @@
|
|||
\begin{itemize}
|
||||
\item file inclusion: \verb+@#include+
|
||||
\item definition a variable of the macro-processor: \verb+@#define+
|
||||
\item conditional statements (\verb+@#if/@#then/@#else/@#endif+)
|
||||
\item conditional statements (\verb+@#if/@#else/@#endif+)
|
||||
\item loop statements (\verb+@#for/@#endfor+)
|
||||
\end{itemize}
|
||||
\item In most cases, directives occupy exactly one line of text. In case of need, two anti-slashes (\verb+\\+) at the end of the line indicates that the directive is continued on the next line.
|
||||
|
|
|
@ -99,7 +99,7 @@ elseif type == 1; % Inverse Gamma 1
|
|||
end
|
||||
end
|
||||
% Solve for nu using the secant method.
|
||||
while abs(nu2-nu1) > 1e-8
|
||||
while abs(nu2/nu1-1) > 1e-14
|
||||
if err > 0
|
||||
nu1 = nu;
|
||||
if nu < nu2
|
||||
|
@ -117,10 +117,10 @@ elseif type == 1; % Inverse Gamma 1
|
|||
end
|
||||
s = (sigma2+mu2)*(nu-2);
|
||||
if check_solution_flag
|
||||
if abs(mu-sqrt(s/2)*gamma((nu-1)/2)/gamma(nu/2))>1e-9
|
||||
if abs(log(mu)-log(sqrt(s/2))-gammaln((nu-1)/2)+gammaln(nu/2))>1e-7
|
||||
error('inverse_gamma_specification:: Failed in solving for the hyperparameters!');
|
||||
end
|
||||
if abs(sigma-sqrt(s/(nu-2)-mu^2))>1e-9
|
||||
if abs(sigma-sqrt(s/(nu-2)-mu^2))>1e-7
|
||||
error('inverse_gamma_specification:: Failed in solving for the hyperparameters!');
|
||||
end
|
||||
end
|
||||
|
|
|
@ -61,10 +61,10 @@ switch task
|
|||
if horizon == 0
|
||||
horizon = 5;
|
||||
end
|
||||
if size(oo_.endo_simul,2) < maximum_lag
|
||||
if isempty(M_.endo_histval)
|
||||
y0 = repmat(oo_.steady_state,1,maximum_lag);
|
||||
else
|
||||
y0 = oo_.endo_simul(:,1:maximum_lag);
|
||||
y0 = M_.endo_histval;
|
||||
end
|
||||
case 'smoother'
|
||||
horizon = options_.forecast;
|
||||
|
|
|
@ -56,7 +56,6 @@ options_.lyapunov_complex_threshold = 1e-15;
|
|||
options_.solve_tolf = eps^(1/3);
|
||||
options_.solve_tolx = eps^(2/3);
|
||||
options_.solve_maxit = 500;
|
||||
options_.deterministic_simulation_initialization = 0;
|
||||
|
||||
% Default number of threads for parallelized mex files.
|
||||
options_.threads.kronecker.A_times_B_kronecker_C = 1;
|
||||
|
@ -333,6 +332,7 @@ oo_.exo_det_steady_state = [];
|
|||
oo_.exo_det_simul = [];
|
||||
|
||||
M_.params = [];
|
||||
M_.endo_histval = [];
|
||||
|
||||
% BVAR
|
||||
M_.bvar = [];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function s=skewness(y),
|
||||
function s=gsa_skewness(y),
|
||||
|
||||
% y=stand_(y);
|
||||
% s=mean(y.^3);
|
|
@ -1,5 +1,5 @@
|
|||
function [tadj, iff] = speed(A,B,mf,p),
|
||||
% [tadj, iff] = speed(A,B,mf,p),
|
||||
function [tadj, iff] = gsa_speed(A,B,mf,p),
|
||||
% [tadj, iff] = gsa_speed(A,B,mf,p),
|
||||
%
|
||||
% Part of the Sensitivity Analysis Toolbox for DYNARE
|
||||
%
|
|
@ -3,10 +3,10 @@ function [yy, xdir, isig, lam]=log_trans_(y0,xdir0)
|
|||
if nargin==1,
|
||||
xdir0='';
|
||||
end
|
||||
f=inline('skewness(log(y+lam))','lam','y');
|
||||
f=inline('gsa_skewness(log(y+lam))','lam','y');
|
||||
isig=1;
|
||||
if ~(max(y0)<0 | min(y0)>0)
|
||||
if skewness(y0)<0,
|
||||
if gsa_skewness(y0)<0,
|
||||
isig=-1;
|
||||
y0=-y0;
|
||||
end
|
||||
|
|
|
@ -127,7 +127,7 @@ if opt_gsa.load_ident_files==0,
|
|||
% ino=find(~ismember([1:nr],io));
|
||||
% T2=A(ino,1:nr,:);
|
||||
R=A(:,nr+1:nc,:);
|
||||
% [tadj, iff] = speed(A(1:nr,1:nr,:),R,io,0.5);
|
||||
% [tadj, iff] = gsa_speed(A(1:nr,1:nr,:),R,io,0.5);
|
||||
% [tadj, j0, ir_tadj, ic_tadj] = teff(tadj,Nsam,istable);
|
||||
% [iff, j0, ir_if, ic_if] = teff(iff,Nsam,istable);
|
||||
|
||||
|
|
|
@ -35,29 +35,16 @@ if isempty(oo_.steady_state)
|
|||
oo_.steady_state = zeros(M_.endo_nbr,1);
|
||||
end
|
||||
|
||||
if isempty(oo_.endo_simul)
|
||||
if isempty(M_.endo_histval)
|
||||
if isempty(ys0_)
|
||||
oo_.endo_simul = [oo_.steady_state*ones(1,M_.maximum_lag+options_.periods+M_.maximum_lead)];
|
||||
else
|
||||
oo_.endo_simul = [ys0_*ones(1,M_.maximum_lag) oo_.steady_state*ones(1,options_.periods+M_.maximum_lead)];
|
||||
end
|
||||
elseif size(oo_.endo_simul,2) < M_.maximum_lag+M_.maximum_lead+options_.periods
|
||||
switch options_.deterministic_simulation_initialization
|
||||
case 0
|
||||
oo_.endo_simul = [oo_.endo_simul ...
|
||||
oo_.steady_state*ones(1,M_.maximum_lag+options_.periods+M_.maximum_lead-size(oo_.endo_simul,2),1)];
|
||||
case 1% A linear approximation is used to initialize the solution.
|
||||
oldopt = options_;
|
||||
options_.order = 1;
|
||||
dr = oo_.dr;
|
||||
dr.ys = oo_.steady_state;
|
||||
[dr,info,M_,options_,oo_]=dr1(dr,0,M_,options_,oo_);
|
||||
exogenous_variables = zeros(M_.maximum_lag+options_.periods+M_.maximum_lead-size(oo_.endo_simul,2)+1,0);
|
||||
y0 = oo_.endo_simul(:,1:M_.maximum_lag);
|
||||
oo_.endo_simul=simult_(y0,dr,exogenous_variables,1);
|
||||
options_ = oldopt;
|
||||
case 2% Homotopic mod: Leave endo_simul as it is.
|
||||
otherwise
|
||||
error('Unknown method.')
|
||||
else
|
||||
if ~isempty(ys0_)
|
||||
error('histval and endval cannot be used simultaneously')
|
||||
end
|
||||
oo_.endo_simul = [M_.endo_histval ...
|
||||
oo_.steady_state*ones(1,options_.periods+M_.maximum_lead)];
|
||||
end
|
|
@ -62,13 +62,3 @@ end
|
|||
disp_steady_state(M_,oo_);
|
||||
|
||||
M_.Sigma_e = Sigma_e;
|
||||
|
||||
|
||||
if isempty(ys0_)
|
||||
oo_.endo_simul(:,1:M_.maximum_lag) = oo_.steady_state * ones(1, M_.maximum_lag);
|
||||
%%% Unless I'm wrong, this is (should be?) done in make_y_.m
|
||||
% $$$ else
|
||||
% $$$ options_ =set_default_option(options_,'periods',1);
|
||||
% $$$ oo_.endo_simul(:,M_.maximum_lag+1:M_.maximum_lag+options_.periods+ ...
|
||||
% $$$ M_.maximum_lead) = oo_.steady_state * ones(1,options_.periods+M_.maximum_lead);
|
||||
end
|
|
@ -130,13 +130,10 @@ if options_.periods > 0 && ~PI_PCL_solver
|
|||
options_ =options_old;
|
||||
return
|
||||
end
|
||||
% Note that the first column of oo_.endo_simul is preserved by the following
|
||||
% call to simult; this is important because stoch_simul can be followed by
|
||||
% forecast (see ticket #157)
|
||||
if size(oo_.endo_simul,2) == 0
|
||||
if isempty(M_.endo_histval)
|
||||
y0 = oo_.dr.ys;
|
||||
else
|
||||
y0 = oo_.endo_simul(:,1);
|
||||
y0 = M_.endo_histval;
|
||||
end
|
||||
oo_.endo_simul = simult(y0,oo_.dr);
|
||||
dyn2vec;
|
||||
|
|
|
@ -82,10 +82,10 @@ elseif options_.periods ~= 0
|
|||
options_ =options_old;
|
||||
return
|
||||
end
|
||||
if size(oo_.endo_simul,2) < maximum_lag
|
||||
if isempty(M_.endo_histval)
|
||||
y0 = oo_.dr.ys;
|
||||
else
|
||||
y0 = oo_.endo_simul(:,1);
|
||||
y0 = M_.endo_histval;
|
||||
end
|
||||
oo_.endo_simul = simult(y0,oo_.dr);
|
||||
dyn2vec;
|
||||
|
|
|
@ -14,10 +14,10 @@ LDFLAGS += $(shell $(MKOCTFILE) -p LDFLAGS)
|
|||
|
||||
LIBS += $(shell $(MKOCTFILE) -p OCTAVE_LIBS)
|
||||
LIBS += $(shell $(MKOCTFILE) -p BLAS_LIBS)
|
||||
LIBS += $(shell $(MKOCTFILE) -p LAPACK_LIBS)
|
||||
LIBS += $(shell $(MKOCTFILE) -p FFTW_LIBS)
|
||||
LIBS += $(shell $(MKOCTFILE) -p LIBS)
|
||||
LIBS += $(shell $(MKOCTFILE) -p FLIBS)
|
||||
LIBS += $(shell $(MKOCTFILE) -p CXXLIBS) # Only used for Octave/MinGW
|
||||
|
||||
all-local:
|
||||
$(MKDIR_P) $(top_srcdir)/../../octave
|
||||
|
|
|
@ -234,6 +234,18 @@ enum external_function_type
|
|||
ExternalFunctionSecondDerivative
|
||||
};
|
||||
|
||||
enum PriorDistributions
|
||||
{
|
||||
eNoShape = 0,
|
||||
eBeta = 1,
|
||||
eGamma = 2,
|
||||
eNormal = 3,
|
||||
eInvGamma = 4,
|
||||
eInvGamma1 = 4,
|
||||
eUniform = 5,
|
||||
eInvGamma2 = 6
|
||||
};
|
||||
|
||||
struct Block_contain_type
|
||||
{
|
||||
int Equation, Variable, Own_Derivative;
|
||||
|
|
|
@ -446,7 +446,7 @@ EstimatedParamsStatement::checkPass(ModFileStructure &mod_file_struct)
|
|||
mod_file_struct.dsge_prior_weight_in_estimated_params = true;
|
||||
|
||||
// Handle case of degenerate beta prior
|
||||
if (it->prior == "1") //BETA_PDF is associated with "1" in DynareBison.yy
|
||||
if (it->prior == eBeta)
|
||||
try
|
||||
{
|
||||
if (it->mean->eval(eval_context_t()) == 0.5
|
||||
|
@ -1358,7 +1358,7 @@ MarkovSwitchingStatement::MarkovSwitchingStatement(const OptionsList &options_li
|
|||
options_list.num_options.find("ms.number_of_regimes");
|
||||
if (it_num_regimes == options_list.num_options.end())
|
||||
{
|
||||
cerr << "ERROR: should not arrive here: MarkovSwitchingStatement::checkPass" << endl;
|
||||
cerr << "ERROR: should not arrive here: MarkovSwitchingStatement constructor" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int num_regimes = lexical_cast< int >(it_num_regimes->second);
|
||||
|
@ -1655,9 +1655,11 @@ BasicPriorStatement::~BasicPriorStatement()
|
|||
}
|
||||
|
||||
BasicPriorStatement::BasicPriorStatement(const string &name_arg,
|
||||
const PriorDistributions &prior_shape_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
name(name_arg),
|
||||
prior_shape(prior_shape_arg),
|
||||
variance(variance_arg),
|
||||
options_list(options_list_arg),
|
||||
first_statement_encountered(false)
|
||||
|
@ -1667,11 +1669,12 @@ BasicPriorStatement::BasicPriorStatement(const string &name_arg,
|
|||
void
|
||||
BasicPriorStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
if (options_list.num_options.find("shape") == options_list.num_options.end())
|
||||
if (prior_shape == eNoShape)
|
||||
{
|
||||
cerr << "ERROR: You must pass the shape option to the prior statement." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (options_list.num_options.find("date1") != options_list.num_options.end() ||
|
||||
options_list.num_options.find("date2") != options_list.num_options.end())
|
||||
if (options_list.num_options.find("date1") == options_list.num_options.end() ||
|
||||
|
@ -1681,6 +1684,19 @@ BasicPriorStatement::checkPass(ModFileStructure &mod_file_struct)
|
|||
<< "Please inform Dynare Team." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
OptionsList::num_options_t::const_iterator it_num = options_list.num_options.find("domain");
|
||||
if (it_num != options_list.num_options.end())
|
||||
{
|
||||
using namespace boost;
|
||||
vector<string> tokenizedDomain;
|
||||
split(tokenizedDomain, it_num->second, is_any_of("[ ]"), token_compress_on);
|
||||
if (tokenizedDomain.size() != 4)
|
||||
{
|
||||
cerr << "ERROR: You must pass exactly two values to the domain option." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1715,7 +1731,6 @@ BasicPriorStatement::writeVarianceOption(ostream &output, const string &lhs_fiel
|
|||
void
|
||||
BasicPriorStatement::writeOutputHelper(ostream &output, const string &field, const string &lhs_field) const
|
||||
{
|
||||
|
||||
OptionsList::num_options_t::const_iterator itn = options_list.num_options.find(field);
|
||||
if (itn != options_list.num_options.end())
|
||||
output << "estimation_info" << lhs_field << "(prior_indx)." << field
|
||||
|
@ -1727,10 +1742,18 @@ BasicPriorStatement::writeOutputHelper(ostream &output, const string &field, con
|
|||
<< " = '" << itd->second << "';" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
BasicPriorStatement::writeShape(ostream &output, const string &lhs_field) const
|
||||
{
|
||||
assert(prior_shape != eNoShape);
|
||||
output << "estimation_info" << lhs_field << "(prior_indx).shape = " << prior_shape << ";" << endl;
|
||||
}
|
||||
|
||||
PriorStatement::PriorStatement(const string &name_arg,
|
||||
const PriorDistributions &prior_shape_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
BasicPriorStatement(name_arg, variance_arg, options_list_arg)
|
||||
BasicPriorStatement(name_arg, prior_shape_arg, variance_arg, options_list_arg)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1748,10 +1771,10 @@ PriorStatement::writeOutput(ostream &output, const string &basename) const
|
|||
{
|
||||
string lhs_field = ".prior";
|
||||
|
||||
BasicPriorStatement::writePriorIndex(output, lhs_field);
|
||||
writePriorIndex(output, lhs_field);
|
||||
output << "estimation_info" << lhs_field << "_index(prior_indx) = {'" << name << "'};" << endl
|
||||
<< "estimation_info" << lhs_field <<"(prior_indx).name = '" << name << "';" << endl;
|
||||
|
||||
writeShape(output, lhs_field);
|
||||
writeOutputHelper(output, "mean", lhs_field);
|
||||
writeOutputHelper(output, "mode", lhs_field);
|
||||
writeOutputHelper(output, "stdev", lhs_field);
|
||||
|
@ -1761,14 +1784,15 @@ PriorStatement::writeOutput(ostream &output, const string &basename) const
|
|||
writeOutputHelper(output, "date2", lhs_field);
|
||||
writeOutputHelper(output, "domain", lhs_field);
|
||||
writeOutputHelper(output, "interval", lhs_field);
|
||||
BasicPriorStatement::writeVarianceOption(output, lhs_field);
|
||||
writeVarianceOption(output, lhs_field);
|
||||
}
|
||||
|
||||
StdPriorStatement::StdPriorStatement(const string &name_arg,
|
||||
const PriorDistributions &prior_shape_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg,
|
||||
const SymbolTable &symbol_table_arg ) :
|
||||
BasicPriorStatement(name_arg, variance_arg, options_list_arg),
|
||||
BasicPriorStatement(name_arg, prior_shape_arg, variance_arg, options_list_arg),
|
||||
symbol_table(symbol_table_arg)
|
||||
{
|
||||
}
|
||||
|
@ -1789,10 +1813,11 @@ StdPriorStatement::writeOutput(ostream &output, const string &basename) const
|
|||
get_base_name(symbol_table.getType(name), lhs_field);
|
||||
lhs_field = "." + lhs_field + ".prior";
|
||||
|
||||
BasicPriorStatement::writePriorIndex(output, lhs_field);
|
||||
writePriorIndex(output, lhs_field);
|
||||
output << "estimation_info" << lhs_field << "_index(prior_indx) = {'" << name << "'};" << endl;
|
||||
output << "estimation_info" << lhs_field << "(prior_indx).name = '" << name << "';" << endl;
|
||||
|
||||
writeShape(output, lhs_field);
|
||||
writeOutputHelper(output, "mean", lhs_field);
|
||||
writeOutputHelper(output, "mode", lhs_field);
|
||||
writeOutputHelper(output, "stdev", lhs_field);
|
||||
|
@ -1800,14 +1825,15 @@ StdPriorStatement::writeOutput(ostream &output, const string &basename) const
|
|||
writeOutputHelper(output, "shift", lhs_field);
|
||||
writeOutputHelper(output, "domain", lhs_field);
|
||||
writeOutputHelper(output, "interval", lhs_field);
|
||||
BasicPriorStatement::writeVarianceOption(output, lhs_field);
|
||||
writeVarianceOption(output, lhs_field);
|
||||
}
|
||||
|
||||
CorrPriorStatement::CorrPriorStatement(const string &name_arg1, const string &name_arg2,
|
||||
const PriorDistributions &prior_shape_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg,
|
||||
const SymbolTable &symbol_table_arg ) :
|
||||
BasicPriorStatement(name_arg1, variance_arg, options_list_arg),
|
||||
BasicPriorStatement(name_arg1, prior_shape_arg, variance_arg, options_list_arg),
|
||||
name1(name_arg2),
|
||||
symbol_table(symbol_table_arg)
|
||||
{
|
||||
|
@ -1836,11 +1862,12 @@ CorrPriorStatement::writeOutput(ostream &output, const string &basename) const
|
|||
get_base_name(symbol_table.getType(name), lhs_field);
|
||||
lhs_field = "." + lhs_field + "_corr.prior";
|
||||
|
||||
BasicPriorStatement::writePriorIndex(output, lhs_field);
|
||||
writePriorIndex(output, lhs_field);
|
||||
output << "estimation_info" << lhs_field << "_index(prior_indx) = {'" << name << "_" << name1 << "'};" << endl;
|
||||
output << "estimation_info" << lhs_field << "(prior_indx).name1 = '" << name << "';" << endl;
|
||||
output << "estimation_info" << lhs_field << "(prior_indx).name2 = '" << name1 << "';" << endl;
|
||||
|
||||
writeShape(output, lhs_field);
|
||||
writeOutputHelper(output, "mean", lhs_field);
|
||||
writeOutputHelper(output, "mode", lhs_field);
|
||||
writeOutputHelper(output, "stdev", lhs_field);
|
||||
|
@ -1848,7 +1875,7 @@ CorrPriorStatement::writeOutput(ostream &output, const string &basename) const
|
|||
writeOutputHelper(output, "shift", lhs_field);
|
||||
writeOutputHelper(output, "domain", lhs_field);
|
||||
writeOutputHelper(output, "interval", lhs_field);
|
||||
BasicPriorStatement::writeVarianceOption(output, lhs_field);
|
||||
writeVarianceOption(output, lhs_field);
|
||||
}
|
||||
|
||||
BasicOptionsStatement::~BasicOptionsStatement()
|
||||
|
@ -1929,7 +1956,7 @@ OptionsStatement::writeOutput(ostream &output, const string &basename) const
|
|||
{
|
||||
string lhs_field = ".options";
|
||||
|
||||
BasicOptionsStatement::writeOptionsIndex(output, lhs_field);
|
||||
writeOptionsIndex(output, lhs_field);
|
||||
output << "estimation_info" << lhs_field <<"_index(options_indx) = {'" << name << "'};" << endl
|
||||
<< "estimation_info" << lhs_field << "(options_indx).name = '" << name << "';" << endl;
|
||||
|
||||
|
@ -1964,7 +1991,7 @@ StdOptionsStatement::writeOutput(ostream &output, const string &basename) const
|
|||
get_base_name(symbol_table.getType(name), lhs_field);
|
||||
lhs_field = "." + lhs_field + ".options";
|
||||
|
||||
BasicOptionsStatement::writeOptionsIndex(output, lhs_field);
|
||||
writeOptionsIndex(output, lhs_field);
|
||||
output << "estimation_info" << lhs_field << "_index(options_indx) = {'" << name << "'};" << endl;
|
||||
output << "estimation_info" << lhs_field << "(options_indx).name = '" << name << "';" << endl;
|
||||
|
||||
|
@ -2006,7 +2033,7 @@ CorrOptionsStatement::writeOutput(ostream &output, const string &basename) const
|
|||
get_base_name(symbol_table.getType(name), lhs_field);
|
||||
lhs_field = "." + lhs_field + "_corr.options";
|
||||
|
||||
BasicOptionsStatement::writeOptionsIndex(output, lhs_field);
|
||||
writeOptionsIndex(output, lhs_field);
|
||||
output << "estimation_info" << lhs_field << "_index(options_indx) = {'" << name << "_" << name1 << "'};" << endl;
|
||||
lhs_field += ".";
|
||||
output << "estimation_info" << lhs_field << "(options_indx).name1 = '" << name << "';" << endl;
|
||||
|
|
|
@ -251,7 +251,8 @@ class EstimationParams
|
|||
{
|
||||
public:
|
||||
int type;
|
||||
string name, name2, prior;
|
||||
string name, name2;
|
||||
PriorDistributions prior;
|
||||
expr_t init_val, low_bound, up_bound, mean, std, p3, p4, jscale;
|
||||
|
||||
void
|
||||
|
@ -260,7 +261,7 @@ public:
|
|||
type = 0;
|
||||
name = "";
|
||||
name2 = "";
|
||||
prior = "NaN";
|
||||
prior = eNoShape;
|
||||
init_val = datatree.NaN;
|
||||
low_bound = datatree.MinusInfinity;
|
||||
up_bound = datatree.Infinity;
|
||||
|
@ -583,10 +584,12 @@ public:
|
|||
virtual ~BasicPriorStatement();
|
||||
protected:
|
||||
const string name;
|
||||
const PriorDistributions prior_shape;
|
||||
const expr_t variance;
|
||||
const OptionsList options_list;
|
||||
bool first_statement_encountered;
|
||||
BasicPriorStatement(const string &name_arg,
|
||||
const PriorDistributions &prior_shape_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
|
@ -594,12 +597,14 @@ protected:
|
|||
void writePriorIndex(ostream &output, const string &lhs_field) const;
|
||||
void writeVarianceOption(ostream &output, const string &lhs_field) const;
|
||||
void writeOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
|
||||
void writeShape(ostream &output, const string &lhs_field) const;
|
||||
};
|
||||
|
||||
class PriorStatement : public BasicPriorStatement
|
||||
{
|
||||
public:
|
||||
PriorStatement(const string &name_arg,
|
||||
const PriorDistributions &prior_shape_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
|
@ -612,6 +617,7 @@ private:
|
|||
const SymbolTable symbol_table;
|
||||
public:
|
||||
StdPriorStatement(const string &name_arg,
|
||||
const PriorDistributions &prior_shape_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg,
|
||||
const SymbolTable &symbol_table_arg);
|
||||
|
@ -627,6 +633,7 @@ private:
|
|||
public:
|
||||
CorrPriorStatement(const string &name_arg1,
|
||||
const string &name_arg2,
|
||||
const PriorDistributions &prior_shape_arg,
|
||||
const expr_t &variance_arg,
|
||||
const OptionsList &options_list_arg,
|
||||
const SymbolTable &symbol_table_arg);
|
||||
|
|
|
@ -33,6 +33,7 @@ using namespace std;
|
|||
class ParsingDriver;
|
||||
|
||||
#include "ExprNode.hh"
|
||||
#include "CodeInterpreter.hh"
|
||||
|
||||
/* Little hack: we redefine the macro which computes the locations, because
|
||||
we need to access the location from within the parsing driver for error
|
||||
|
@ -75,6 +76,7 @@ class ParsingDriver;
|
|||
SymbolType symbol_type_val;
|
||||
vector<string *> *vector_string_val;
|
||||
vector<int> *vector_int_val;
|
||||
PriorDistributions prior_distributions_val;
|
||||
};
|
||||
|
||||
%{
|
||||
|
@ -175,13 +177,13 @@ class ParsingDriver;
|
|||
%type <node_val> expression expression_or_empty
|
||||
%type <node_val> equation hand_side
|
||||
%type <string_val> non_negative_number signed_number signed_integer date_number
|
||||
%type <string_val> filename symbol prior_distribution vec_of_vec_value vec_value_list
|
||||
%type <string_val> filename symbol vec_of_vec_value vec_value_list
|
||||
%type <string_val> vec_value_1 vec_value signed_inf signed_number_w_inf
|
||||
%type <string_val> range prior_pdf_string vec_value_w_inf vec_value_1_w_inf
|
||||
%type <string_val> range vec_value_w_inf vec_value_1_w_inf
|
||||
%type <symbol_type_val> change_type_arg
|
||||
%type <vector_string_val> change_type_var_list
|
||||
%type <vector_int_val> vec_int_elem vec_int_1 vec_int vec_int_number
|
||||
|
||||
%type <prior_distributions_val> prior_pdf prior_distribution
|
||||
%%
|
||||
|
||||
%start statement_list;
|
||||
|
@ -1030,24 +1032,21 @@ estimated_elem1 : STDERR symbol
|
|||
}
|
||||
;
|
||||
|
||||
estimated_elem2 : prior_pdf_string COMMA estimated_elem3
|
||||
estimated_elem2 : prior_pdf COMMA estimated_elem3
|
||||
{
|
||||
driver.estim_params.prior = *$1;
|
||||
delete $1;
|
||||
driver.estim_params.prior = $1;
|
||||
}
|
||||
| expression_or_empty COMMA prior_pdf_string COMMA estimated_elem3
|
||||
| expression_or_empty COMMA prior_pdf COMMA estimated_elem3
|
||||
{
|
||||
driver.estim_params.init_val = $1;
|
||||
driver.estim_params.prior = *$3;
|
||||
delete $3;
|
||||
driver.estim_params.prior = $3;
|
||||
}
|
||||
| expression_or_empty COMMA expression_or_empty COMMA expression_or_empty COMMA prior_pdf_string COMMA estimated_elem3
|
||||
| expression_or_empty COMMA expression_or_empty COMMA expression_or_empty COMMA prior_pdf COMMA estimated_elem3
|
||||
{
|
||||
driver.estim_params.init_val = $1;
|
||||
driver.estim_params.low_bound = $3;
|
||||
driver.estim_params.up_bound = $5;
|
||||
driver.estim_params.prior = *$7;
|
||||
delete $7;
|
||||
driver.estim_params.prior = $7;
|
||||
}
|
||||
| expression
|
||||
{
|
||||
|
@ -1161,36 +1160,36 @@ estimated_bounds_elem : STDERR symbol COMMA expression COMMA expression ';'
|
|||
;
|
||||
|
||||
prior_distribution : BETA
|
||||
{ $$ = new string("1"); }
|
||||
{ $$ = eBeta; }
|
||||
| GAMMA
|
||||
{ $$ = new string("2"); }
|
||||
{ $$ = eGamma; }
|
||||
| NORMAL
|
||||
{ $$ = new string("3"); }
|
||||
{ $$ = eNormal; }
|
||||
| INV_GAMMA
|
||||
{ $$ = new string("4"); }
|
||||
{ $$ = eInvGamma; }
|
||||
| INV_GAMMA1
|
||||
{ $$ = new string("4"); }
|
||||
{ $$ = eInvGamma1; }
|
||||
| UNIFORM
|
||||
{ $$ = new string("5"); }
|
||||
{ $$ = eUniform; }
|
||||
| INV_GAMMA2
|
||||
{ $$ = new string("6"); }
|
||||
{ $$ = eInvGamma2; }
|
||||
;
|
||||
|
||||
prior_pdf_string : BETA_PDF
|
||||
{ $$ = new string("1"); }
|
||||
| GAMMA_PDF
|
||||
{ $$ = new string("2"); }
|
||||
| NORMAL_PDF
|
||||
{ $$ = new string("3"); }
|
||||
| INV_GAMMA_PDF
|
||||
{ $$ = new string("4"); }
|
||||
| INV_GAMMA1_PDF
|
||||
{ $$ = new string("4"); }
|
||||
| UNIFORM_PDF
|
||||
{ $$ = new string("5"); }
|
||||
| INV_GAMMA2_PDF
|
||||
{ $$ = new string("6"); }
|
||||
;
|
||||
prior_pdf : BETA_PDF
|
||||
{ $$ = eBeta; }
|
||||
| GAMMA_PDF
|
||||
{ $$ = eGamma; }
|
||||
| NORMAL_PDF
|
||||
{ $$ = eNormal; }
|
||||
| INV_GAMMA_PDF
|
||||
{ $$ = eInvGamma; }
|
||||
| INV_GAMMA1_PDF
|
||||
{ $$ = eInvGamma1; }
|
||||
| UNIFORM_PDF
|
||||
{ $$ = eUniform; }
|
||||
| INV_GAMMA2_PDF
|
||||
{ $$ = eInvGamma2; }
|
||||
;
|
||||
|
||||
set_time : SET_TIME '(' date_number ')' ';'
|
||||
{ driver.set_time($3); }
|
||||
|
@ -1224,16 +1223,16 @@ subsamples_name_list : subsamples_name_list COMMA o_subsample_name
|
|||
| o_subsample_name
|
||||
;
|
||||
|
||||
prior : symbol '.' PRIOR { driver.set_prior_variance(); } '(' prior_options_list ')' ';'
|
||||
prior : symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||
{ driver.set_prior($1); }
|
||||
| symbol '.' symbol '.' PRIOR { driver.set_prior_variance(); } '(' prior_options_list ')' ';'
|
||||
| symbol '.' symbol '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||
{
|
||||
driver.add_subsample_range(new string (*$1), $3);
|
||||
driver.set_prior($1);
|
||||
}
|
||||
| STD '(' symbol ')' '.' PRIOR { driver.set_prior_variance(); } '(' prior_options_list ')' ';'
|
||||
| STD '(' symbol ')' '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||
{ driver.set_std_prior($3); }
|
||||
| CORR '(' symbol COMMA symbol')' '.' PRIOR { driver.set_prior_variance(); } '(' prior_options_list ')' ';'
|
||||
| CORR '(' symbol COMMA symbol')' '.' PRIOR { driver.set_prior_variance(); driver.prior_shape = eNoShape; } '(' prior_options_list ')' ';'
|
||||
{ driver.set_corr_prior($3, $5); }
|
||||
;
|
||||
|
||||
|
@ -1992,7 +1991,7 @@ o_last_obs : LAST_OBS EQUAL date_number
|
|||
{ driver.option_date("last_obs", $3); }
|
||||
;
|
||||
o_shift : SHIFT EQUAL signed_number { driver.option_num("shift", $3); };
|
||||
o_shape : SHAPE EQUAL prior_distribution { driver.option_num("shape", $3); };
|
||||
o_shape : SHAPE EQUAL prior_distribution { driver.prior_shape = $3; };
|
||||
o_mode : MODE EQUAL signed_number { driver.option_num("mode", $3); };
|
||||
o_mean : MEAN EQUAL signed_number { driver.option_num("mean", $3); };
|
||||
o_stdev : STDEV EQUAL non_negative_number { driver.option_num("stdev", $3); };
|
||||
|
|
|
@ -132,8 +132,7 @@ InitValStatement::writeOutput(ostream &output, const string &basename) const
|
|||
void
|
||||
InitValStatement::writeOutputPostInit(ostream &output) const
|
||||
{
|
||||
output << "oo_.endo_simul=[oo_.steady_state*ones(1,M_.maximum_lag)];" << endl
|
||||
<< "if M_.exo_nbr > 0;" << endl
|
||||
output << "if M_.exo_nbr > 0;" << endl
|
||||
<< "\too_.exo_simul = [ones(M_.maximum_lag,1)*oo_.exo_steady_state'];" << endl
|
||||
<<"end;" << endl
|
||||
<< "if M_.exo_det_nbr > 0;" << endl
|
||||
|
@ -189,7 +188,7 @@ HistValStatement::writeOutput(ostream &output, const string &basename) const
|
|||
output << "%" << endl
|
||||
<< "% HISTVAL instructions" << endl
|
||||
<< "%" << endl
|
||||
<< "oo_.endo_simul = zeros(M_.endo_nbr,M_.maximum_lag);" << endl;
|
||||
<< "M_.endo_histval = zeros(M_.endo_nbr,M_.maximum_lag);" << endl;
|
||||
|
||||
for (hist_values_t::const_iterator it = hist_values.begin();
|
||||
it != hist_values.end(); it++)
|
||||
|
@ -225,7 +224,7 @@ HistValStatement::writeOutput(ostream &output, const string &basename) const
|
|||
int tsid = symbol_table.getTypeSpecificID(symb_id) + 1;
|
||||
|
||||
if (type == eEndogenous)
|
||||
output << "oo_.endo_simul( " << tsid << ", M_.maximum_lag + " << lag << ") = ";
|
||||
output << "M_.endo_histval( " << tsid << ", M_.maximum_lag + " << lag << ") = ";
|
||||
else if (type == eExogenous)
|
||||
output << "oo_.exo_simul( M_.maximum_lag + " << lag << ", " << tsid << " ) = ";
|
||||
else if (type != eExogenousDet)
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
InitValStatement(const init_values_t &init_values_arg,
|
||||
const SymbolTable &symbol_table_arg);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
//! Writes initializations for oo_.endo_simul, oo_.exo_simul and oo_.exo_det_simul
|
||||
//! Writes initializations for oo_.exo_simul and oo_.exo_det_simul
|
||||
void writeOutputPostInit(ostream &output) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -1303,9 +1303,10 @@ void
|
|||
ParsingDriver::set_prior(string *name)
|
||||
{
|
||||
check_symbol_is_parameter(name);
|
||||
mod_file->addStatement(new PriorStatement(*name, prior_variance, options_list));
|
||||
mod_file->addStatement(new PriorStatement(*name, prior_shape, prior_variance, options_list));
|
||||
options_list.clear();
|
||||
set_prior_variance();
|
||||
prior_shape = eNoShape;
|
||||
delete name;
|
||||
}
|
||||
|
||||
|
@ -1344,9 +1345,11 @@ void
|
|||
ParsingDriver::set_std_prior(string *name)
|
||||
{
|
||||
check_symbol_is_endogenous_or_exogenous(name);
|
||||
mod_file->addStatement(new StdPriorStatement(*name, prior_variance, options_list, mod_file->symbol_table));
|
||||
mod_file->addStatement(new StdPriorStatement(*name, prior_shape, prior_variance,
|
||||
options_list, mod_file->symbol_table));
|
||||
options_list.clear();
|
||||
set_prior_variance();
|
||||
prior_shape = eNoShape;
|
||||
delete name;
|
||||
}
|
||||
|
||||
|
@ -1364,9 +1367,11 @@ ParsingDriver::set_corr_prior(string *name1, string *name2)
|
|||
{
|
||||
check_symbol_is_endogenous_or_exogenous(name1);
|
||||
check_symbol_is_endogenous_or_exogenous(name2);
|
||||
mod_file->addStatement(new CorrPriorStatement(*name1, *name2, prior_variance, options_list, mod_file->symbol_table));
|
||||
mod_file->addStatement(new CorrPriorStatement(*name1, *name2, prior_shape, prior_variance,
|
||||
options_list, mod_file->symbol_table));
|
||||
options_list.clear();
|
||||
set_prior_variance();
|
||||
prior_shape = eNoShape;
|
||||
delete name1;
|
||||
delete name2;
|
||||
}
|
||||
|
|
|
@ -217,6 +217,9 @@ public:
|
|||
//! Estimation parameters
|
||||
EstimationParams estim_params;
|
||||
|
||||
//! Temporary storage for the prior shape
|
||||
PriorDistributions prior_shape;
|
||||
|
||||
//! Error handler with explicit location
|
||||
void error(const Dynare::parser::location_type &l, const string &m) __attribute__ ((noreturn));
|
||||
//! Error handler using saved location
|
||||
|
|
|
@ -162,12 +162,9 @@ public:
|
|||
|
||||
//! Execute computations (variable sorting + derivation)
|
||||
/*!
|
||||
\param jacobianExo whether derivatives w.r. to exo and exo_det should be in the Jacobian (derivatives w.r. to endo are always computed)
|
||||
\param hessian whether 2nd derivatives w.r. to exo, exo_det and endo should be computed (implies jacobianExo = true)
|
||||
\param thirdDerivatives whether 3rd derivatives w.r. to endo/exo/exo_det should be computed (implies jacobianExo = true)
|
||||
\param paramsDerivatives whether 2nd derivatives w.r. to a pair (endo/exo/exo_det, parameter) should be computed (implies jacobianExo = true)
|
||||
\param eval_context evaluation context for normalization
|
||||
\param no_tmp_terms if true, no temporary terms will be computed in the static files
|
||||
\param hessian whether 2nd derivatives w.r. to exo, exo_det and endo should be computed
|
||||
*/
|
||||
void computingPass(const eval_context_t &eval_context, bool no_tmp_terms, bool hessian, bool block, bool bytecode);
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class MacroDriver;
|
|||
|
||||
%}
|
||||
|
||||
%token DEFINE LINE FOR IN IF ELSE ENDIF ECHO_DIR ERROR
|
||||
%token DEFINE LINE FOR IN IF ELSE ENDIF ECHO_DIR ERROR IFDEF
|
||||
%token LPAREN RPAREN LBRACKET RBRACKET EQUAL EOL
|
||||
|
||||
%token <int_val> INTEGER
|
||||
|
@ -117,6 +117,8 @@ statement : expr
|
|||
{ TYPERR_CATCH(driver.init_loop(*$2, $4), @$); delete $2; }
|
||||
| IF expr
|
||||
{ TYPERR_CATCH(driver.begin_if($2), @$); }
|
||||
| IFDEF NAME
|
||||
{ TYPERR_CATCH(driver.begin_ifdef(*$2), @$); delete $2; }
|
||||
| ECHO_DIR expr
|
||||
{ TYPERR_CATCH(driver.echo(@$, $2), @$); }
|
||||
| ERROR expr
|
||||
|
|
|
@ -164,6 +164,24 @@ MacroDriver::begin_if(const MacroValue *value) throw (MacroValue::TypeError)
|
|||
last_if = (bool) ival->value;
|
||||
}
|
||||
|
||||
void
|
||||
MacroDriver::begin_ifdef(const string &name)
|
||||
{
|
||||
try
|
||||
{
|
||||
get_variable(name);
|
||||
const MacroValue *one = new IntMV(*this, 1);
|
||||
begin_if(one);
|
||||
delete one;
|
||||
}
|
||||
catch (UnknownVariable &)
|
||||
{
|
||||
const MacroValue *zero = new IntMV(*this, 0);
|
||||
begin_if(zero);
|
||||
delete zero;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MacroDriver::echo(const Macro::parser::location_type &l, const MacroValue *value) const throw (MacroValue::TypeError)
|
||||
{
|
||||
|
|
|
@ -208,6 +208,9 @@ public:
|
|||
//! Begins an @#if statement
|
||||
void begin_if(const MacroValue *value) throw (MacroValue::TypeError);
|
||||
|
||||
//! Begins an @#ifdef statement
|
||||
void begin_ifdef(const string &name);
|
||||
|
||||
//! Executes @#echo directive
|
||||
void echo(const Macro::parser::location_type &l, const MacroValue *value) const throw (MacroValue::TypeError);
|
||||
|
||||
|
|
|
@ -164,6 +164,8 @@ CONT \\\\
|
|||
<STMT>for { reading_for_statement = true; return token::FOR; }
|
||||
<STMT>endfor { driver.error(*yylloc, "@#endfor is not matched by a @#for statement"); }
|
||||
|
||||
<STMT>ifdef { reading_if_statement = true; return token::IFDEF; }
|
||||
|
||||
<STMT>if { reading_if_statement = true; return token::IF; }
|
||||
<STMT>else { driver.error(*yylloc, "@#else is not matched by an @#if statement"); }
|
||||
<STMT>endif { driver.error(*yylloc, "@#endif is not matched by an @#if statement"); }
|
||||
|
|
|
@ -49,4 +49,7 @@ a(-1) = 0.3;
|
|||
u(-1) = 0.1;
|
||||
end;
|
||||
|
||||
stoch_simul(nograph);
|
||||
stoch_simul(nograph, periods = 200);
|
||||
|
||||
forecast;
|
||||
|
||||
|
|
|
@ -57,10 +57,10 @@ Using Dynare with Octave
|
|||
Dynare is now available for GNU Octave, a free clone of MATLAB (R) (see
|
||||
<http://www.octave.org>).
|
||||
|
||||
The recommended Octave distribution is the Octave/MinGW 3.2.4
|
||||
The recommended Octave distribution is the Octave/MinGW 3.4.3
|
||||
precompiled binaries from Octave Forge, available at:
|
||||
|
||||
http://sourceforge.net/projects/octave/files/Octave_Windows%20-%20MinGW/
|
||||
http://sourceforge.net/projects/octave/files/Octave_Windows%20-%20MinGW/Octave%203.4.3%20for%20Windows%20MinGW%20Installer/
|
||||
|
||||
Every time you run Octave, you should type the two following commands (assuming
|
||||
that you have installed Dynare at the standard location, and replacing '4.x.y'
|
||||
|
|
|
@ -108,7 +108,7 @@ SectionEnd
|
|||
|
||||
SectionGroupEnd
|
||||
|
||||
Section "MEX files for Octave 3.2.4 (MinGW build)"
|
||||
Section "MEX files for Octave 3.4.3 (MinGW build)"
|
||||
SetOutPath $INSTDIR\mex\octave
|
||||
File ..\mex\octave\*.mex ..\mex\octave\*.oct
|
||||
SectionEnd
|
||||
|
|
Loading…
Reference in New Issue