Merge branch 'master' into ecb-master
commit
dcea7514d9
|
@ -45,6 +45,8 @@ testsuite_matlab:
|
|||
- tests/*.m.trs
|
||||
- tests/*/*.m.log
|
||||
- tests/*/*.m.trs
|
||||
- tests/*/*/*.m.log
|
||||
- tests/*/*/*.m.trs
|
||||
- tests/run_test_matlab_output.txt
|
||||
when: always
|
||||
dependencies:
|
||||
|
@ -64,6 +66,8 @@ testsuite_matlab:
|
|||
- tests/*.o.trs
|
||||
- tests/*/*.o.log
|
||||
- tests/*/*.o.trs
|
||||
- tests/*/*/*.o.log
|
||||
- tests/*/*/*.o.trs
|
||||
- tests/run_test_octave_output.txt
|
||||
when: always
|
||||
dependencies:
|
||||
|
|
|
@ -4637,7 +4637,7 @@ The variables are arranged in declaration order.
|
|||
@end defvr
|
||||
|
||||
@defvr {MATLAB/Octave variable} oo_.kurtosis
|
||||
After a run of @code{stoch_simul} contains the kurtosis (standardized fourth moment)
|
||||
After a run of @code{stoch_simul} contains the excess kurtosis (standardized fourth moment)
|
||||
of the simulated variables if the @code{periods} option is present.
|
||||
The variables are arranged in declaration order.
|
||||
@end defvr
|
||||
|
@ -8278,6 +8278,14 @@ variables between the first and last specified period. If an intermediate period
|
|||
is not specified, a value of 0 is assumed. That is, if you specify only
|
||||
values for periods 1 and 3, the values for period 2 will be 0. Currently, it is not
|
||||
possible to have uncontrolled intermediate periods.
|
||||
|
||||
It is however possible to
|
||||
have different number of controlled periods for different variables. In that
|
||||
case, the order of declaration of endogenenous controlled variables and of
|
||||
controlled_varexo matters: if the second endogenous variable is controlled for
|
||||
less periods than the first one, the second controlled_varexo isn't set for
|
||||
the last periods.
|
||||
|
||||
In case of the presence of @code{observation_trends}, the specified controlled path for
|
||||
these variables needs to include the trend component. When using the @ref{loglinear} option,
|
||||
it is necessary to specify the logarithm of the controlled variables.
|
||||
|
|
12
license.txt
12
license.txt
|
@ -1,6 +1,6 @@
|
|||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: Dynare
|
||||
Upstream-Contact: Dynare Team, whose members in 2017 are:
|
||||
Upstream-Contact: Dynare Team, whose members in 2018 are:
|
||||
Stéphane Adjemian <stephane.adjemian@univ-lemans.fr>
|
||||
Houtan Bastani <houtan@dynare.org>
|
||||
Michel Juillard <michel.juillard@mjui.fr>
|
||||
|
@ -13,7 +13,7 @@ Upstream-Contact: Dynare Team, whose members in 2017 are:
|
|||
Source: http://www.dynare.org
|
||||
|
||||
Files: *
|
||||
Copyright: 1996-2017 Dynare Team
|
||||
Copyright: 1996-2018 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/AIM/SP*
|
||||
|
@ -117,8 +117,8 @@ Files: matlab/gsa/cumplot.m
|
|||
matlab/gsa/tcrit.m
|
||||
matlab/gsa/teff.m
|
||||
matlab/gsa/trank.m
|
||||
Copyright: 2011-2017 European Commission
|
||||
2011-2017 Dynare Team
|
||||
Copyright: 2011-2018 European Commission
|
||||
2011-2018 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/gsa/pick.m
|
||||
|
@ -196,7 +196,7 @@ Copyright: 2005-2010 Pascal Getreuer
|
|||
License: BSD-2-clause
|
||||
|
||||
Files: doc/dynare.texi doc/*.tex doc/*.svg doc/*.pdf doc/*.bib
|
||||
Copyright: 1996-2017 Dynare Team
|
||||
Copyright: 1996-2018 Dynare Team
|
||||
License: GFDL-NIV-1.3+
|
||||
|
||||
Files: doc/macroprocessor/*
|
||||
|
@ -204,7 +204,7 @@ Copyright: 2008-2015 Dynare Team
|
|||
License: CC-BY-SA-4.0
|
||||
|
||||
Files: doc/preprocessor/*
|
||||
Copyright: 2007-2017 Dynare Team
|
||||
Copyright: 2007-2018 Dynare Team
|
||||
License: CC-BY-SA-4.0
|
||||
|
||||
Files: doc/dr.tex doc/bvar_a_la_sims.tex
|
||||
|
|
|
@ -22,6 +22,9 @@ AC_REQUIRE([AX_MATLAB])
|
|||
AC_MSG_CHECKING([for MATLAB version])
|
||||
if test "x$MATLAB_VERSION" != "x"; then
|
||||
case $MATLAB_VERSION in
|
||||
*2018b | *2018B)
|
||||
MATLAB_VERSION="9.5"
|
||||
;;
|
||||
*2018a | *2018A)
|
||||
MATLAB_VERSION="9.4"
|
||||
;;
|
||||
|
|
|
@ -1,30 +1,32 @@
|
|||
function imcforecast(constrained_paths, constrained_vars, options_cond_fcst)
|
||||
|
||||
% Computes conditional forecasts.
|
||||
%
|
||||
% INPUTS
|
||||
% o constrained_paths [double] m*p array, where m is the number of constrained endogenous variables and p is the number of constrained periods.
|
||||
% o constrained_vars [char] m*x array holding the names of the controlled endogenous variables.
|
||||
% o options_cond_fcst [structure] containing the options. The fields are:
|
||||
% + replic [integer] scalar, number of monte carlo simulations.
|
||||
% + parameter_set [char] values of the estimated parameters:
|
||||
% "posterior_mode",
|
||||
% "posterior_mean",
|
||||
% "posterior_median",
|
||||
% "prior_mode" or
|
||||
% "prior mean".
|
||||
% [double] np*1 array, values of the estimated parameters.
|
||||
% + controlled_varexo [char] m*x array, list of controlled exogenous variables.
|
||||
% + conf_sig [double] scalar in [0,1], probability mass covered by the confidence bands.
|
||||
% - consnstrained_paths [double] m*p array, where m is the number of constrained endogenous variables and p is the number of constrained periods.
|
||||
% - constrained_vars [integer] m*1 array, indices in M_.endo_names of the constrained variables.
|
||||
% - options_cond_fcst [structure] containing the options. The fields are:
|
||||
%
|
||||
% + replic [integer] scalar, number of monte carlo simulations.
|
||||
% + parameter_set [char] values of the estimated parameters:
|
||||
% 'posterior_mode',
|
||||
% 'posterior_mean',
|
||||
% 'posterior_median',
|
||||
% 'prior_mode' or
|
||||
% 'prior mean'.
|
||||
% [double] np*1 array, values of the estimated parameters.
|
||||
% + controlled_varexo [cell] m*1 cell of row char array, list of controlled exogenous variables.
|
||||
% + conf_sig [double] scalar in [0,1], probability mass covered by the confidence bands.
|
||||
%
|
||||
% OUTPUTS
|
||||
% None.
|
||||
% None.
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% This routine has to be called after an estimation statement or an estimated_params block.
|
||||
% This routine has to be called after an estimation statement or an estimated_params block.
|
||||
%
|
||||
% REMARKS
|
||||
% [1] Results are stored in a structure which is saved in a mat file called conditional_forecasts.mat.
|
||||
% [2] Use the function plot_icforecast to plot the results.
|
||||
% [1] Results are stored in a structure which is saved in a mat file called conditional_forecasts.mat.
|
||||
% [2] Use the function plot_icforecast to plot the results.
|
||||
|
||||
% Copyright (C) 2006-2018 Dynare Team
|
||||
%
|
||||
|
@ -124,7 +126,8 @@ if estimated_model
|
|||
qz_criterium_old=options_.qz_criterium;
|
||||
options_=select_qz_criterium_value(options_);
|
||||
options_smoothed_state_uncertainty_old = options_.smoothed_state_uncertainty;
|
||||
[atT,innov,measurement_error,filtered_state_vector,ys,trend_coeff,aK,T,R,P,PK,decomp,trend_addition,state_uncertainty,M_,oo_,options_,bayestopt_] = DsgeSmoother(xparam,gend,data,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
|
||||
[atT, ~, ~, ~,ys, ~, ~, ~, ~, ~, ~, ~, ~, ~,M_,oo_,options_,bayestopt_] = ...
|
||||
DsgeSmoother(xparam, gend, data, data_index, missing_value, M_, oo_, options_, bayestopt_, estim_params_);
|
||||
options_.smoothed_state_uncertainty = options_smoothed_state_uncertainty_old;
|
||||
%get constant part
|
||||
if options_.noconstant
|
||||
|
@ -146,7 +149,7 @@ if estimated_model
|
|||
end
|
||||
% add trend to constant
|
||||
for obs_iter=1:length(options_.varobs)
|
||||
j = strmatch(options_.varobs{obs_iter}, M_.endo_names, 'exact');
|
||||
j = strcmp(options_.varobs{obs_iter}, M_.endo_names);
|
||||
constant(j,:) = constant(j,:) + trend_addition(obs_iter,:);
|
||||
end
|
||||
trend = constant(oo_.dr.order_var,:);
|
||||
|
@ -168,7 +171,7 @@ if options_.logged_steady_state %if steady state was previously logged, undo thi
|
|||
options_.logged_steady_state=0;
|
||||
end
|
||||
|
||||
[T,R,ys,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
|
||||
[T, R, ys, ~, M_, options_, oo_] = dynare_resolve(M_, options_, oo_);
|
||||
|
||||
if options_.loglinear && isfield(oo_.dr,'ys') && options_.logged_steady_state==0 %log steady state
|
||||
oo_.dr.ys=log_variable(1:M_.endo_nbr,oo_.dr.ys,M_);
|
||||
|
@ -214,25 +217,21 @@ ExoSize = M_.exo_nbr;
|
|||
|
||||
n1 = size(constrained_vars,1);
|
||||
n2 = size(options_cond_fcst.controlled_varexo,1);
|
||||
constrained_vars(:,1)=oo_.dr.inv_order_var(constrained_vars); % must be in decision rule order
|
||||
|
||||
constrained_vars = oo_.dr.inv_order_var(constrained_vars); % must be in decision rule order
|
||||
|
||||
if n1 ~= n2
|
||||
error(['imcforecast:: The number of constrained variables doesn''t match the number of controlled shocks'])
|
||||
error('imcforecast:: The number of constrained variables doesn''t match the number of controlled shocks')
|
||||
end
|
||||
|
||||
idx = [];
|
||||
jdx = [];
|
||||
% Get indices of controlled varexo.
|
||||
[~, controlled_varexo] = ismember(options_cond_fcst.controlled_varexo,M_.exo_names);
|
||||
|
||||
for i = 1:n1
|
||||
idx = [idx ; constrained_vars(i,:)];
|
||||
% idx = [idx ; oo_.dr.inv_order_var(constrained_vars(i,:))];
|
||||
jdx = [jdx ; strmatch(options_cond_fcst.controlled_varexo{i},M_.exo_names,'exact')];
|
||||
end
|
||||
mv = zeros(n1,NumberOfStates);
|
||||
mu = zeros(ExoSize,n2);
|
||||
mv = zeros(n1, NumberOfStates);
|
||||
mu = zeros(ExoSize, n2);
|
||||
for i=1:n1
|
||||
mv(i,idx(i)) = 1;
|
||||
mu(jdx(i),i) = 1;
|
||||
mv(i,constrained_vars(i)) = 1;
|
||||
mu(controlled_varexo(i),i) = 1;
|
||||
end
|
||||
|
||||
% number of periods with constrained values
|
||||
|
@ -241,7 +240,7 @@ cL = size(constrained_paths,2);
|
|||
%transform constrained periods into deviations from steady state; note that
|
||||
%trend includes last actual data point and therefore we need to start in
|
||||
%period 2
|
||||
constrained_paths = bsxfun(@minus,constrained_paths,trend(idx,2:1+cL));
|
||||
constrained_paths = bsxfun(@minus,constrained_paths,trend(constrained_vars,2:1+cL));
|
||||
|
||||
FORCS1_shocks = zeros(n1,cL,options_cond_fcst.replic);
|
||||
|
||||
|
@ -249,7 +248,7 @@ FORCS1_shocks = zeros(n1,cL,options_cond_fcst.replic);
|
|||
|
||||
for b=1:options_cond_fcst.replic %conditional forecast using cL set to constrained values
|
||||
shocks = sQ*randn(ExoSize,options_cond_fcst.periods);
|
||||
shocks(jdx,:) = zeros(length(jdx),options_cond_fcst.periods);
|
||||
shocks(controlled_varexo,:) = zeros(n1, options_cond_fcst.periods);
|
||||
[FORCS1(:,:,b), FORCS1_shocks(:,:,b)] = mcforecast3(cL,options_cond_fcst.periods,constrained_paths,shocks,FORCS1(:,:,b),T,R,mv, mu);
|
||||
FORCS1(:,:,b)=FORCS1(:,:,b)+trend; %add trend
|
||||
end
|
||||
|
@ -281,11 +280,9 @@ clear FORCS1 mFORCS1_shocks;
|
|||
FORCS2 = zeros(NumberOfStates,options_cond_fcst.periods+1,options_cond_fcst.replic);
|
||||
FORCS2(:,1,:) = repmat(InitState,1,options_cond_fcst.replic); %set initial steady state to deviations from steady state in first period
|
||||
|
||||
%randn('state',0);
|
||||
|
||||
for b=1:options_cond_fcst.replic %conditional forecast using cL set to 0
|
||||
shocks = sQ*randn(ExoSize,options_cond_fcst.periods);
|
||||
shocks(jdx,:) = zeros(length(jdx),options_cond_fcst.periods);
|
||||
shocks(controlled_varexo,:) = zeros(n1, options_cond_fcst.periods);
|
||||
FORCS2(:,:,b) = mcforecast3(0,options_cond_fcst.periods,constrained_paths,shocks,FORCS2(:,:,b),T,R,mv, mu)+trend;
|
||||
end
|
||||
|
||||
|
@ -296,8 +293,8 @@ for i = 1:EndoSize
|
|||
tmp = sort(squeeze(FORCS2(i,:,:))');
|
||||
forecasts.uncond.ci.(M_.endo_names{oo_.dr.order_var(i)}) = [tmp(t1,:)' ,tmp(t2,:)' ]';
|
||||
end
|
||||
forecasts.graph.title=graph_title;
|
||||
forecasts.graph.fname=M_.fname;
|
||||
forecasts.graph.title = graph_title;
|
||||
forecasts.graph.fname = M_.fname;
|
||||
|
||||
%reset qz_criterium
|
||||
options_.qz_criterium=qz_criterium_old;
|
||||
|
|
|
@ -27,6 +27,10 @@ function [forcs, e]= mcforecast3(cL,H,mcValue,shocks,forcs,T,R,mv,mu)
|
|||
% This is then solved to get:
|
||||
% shocks_controlled_t=(y_t(controlled_vars_index)-(T*y_{t-1}(controlled_vars_index)+R(controlled_vars_index,uncontrolled_shocks_index)*shocks_uncontrolled_t)/R(controlled_vars_index,controlled_shocks_index)
|
||||
%
|
||||
% Variable number of controlled vars are allowed in different
|
||||
% periods. Missing control information are indicated by NaN in
|
||||
% y_t(controlled_vars_index).
|
||||
%
|
||||
% After obtaining the shocks, and for uncontrolled periods, the state-space representation
|
||||
% y_t=T*y_{t-1}+R*shocks(:,t)
|
||||
% is used for forecasting
|
||||
|
@ -51,8 +55,10 @@ function [forcs, e]= mcforecast3(cL,H,mcValue,shocks,forcs,T,R,mv,mu)
|
|||
if cL
|
||||
e = zeros(size(mcValue,1),cL);
|
||||
for t = 1:cL
|
||||
e(:,t) = inv(mv*R*mu)*(mcValue(:,t)-mv*T*forcs(:,t)-mv*R*shocks(:,t));
|
||||
forcs(:,t+1) = T*forcs(:,t)+R*(mu*e(:,t)+shocks(:,t));
|
||||
% missing conditional values are indicated by NaN
|
||||
k = find(isfinite(mcValue(:,t)));
|
||||
e(k,t) = inv(mv(k,:)*R*mu(:,k))*(mcValue(k,t)-mv(k,:)*T*forcs(:,t)-mv(k,:)*R*shocks(:,t));
|
||||
forcs(:,t+1) = T*forcs(:,t)+R*(mu(:,k)*e(k,t)+shocks(:,t));
|
||||
end
|
||||
end
|
||||
for t = cL+1:H
|
||||
|
|
|
@ -295,14 +295,14 @@ switch minimizer_algorithm
|
|||
case 'InitialSimplexSize'
|
||||
simplexOptions.delta_factor = options_list{i,2};
|
||||
case 'verbosity'
|
||||
simplexOptions.verbose = options_list{i,2};
|
||||
simplexOptions.verbosity = options_list{i,2};
|
||||
otherwise
|
||||
warning(['simplex: Unknown option (' options_list{i,1} ')!'])
|
||||
end
|
||||
end
|
||||
end
|
||||
if options_.silent_optimizer
|
||||
simplexOptions.verbose = options_list{i,2};
|
||||
simplexOptions.verbosity = 0;
|
||||
end
|
||||
[opt_par_values,fval,exitflag] = simplex_optimization_routine(objective_function,start_par_value,simplexOptions,parameter_names,varargin{:});
|
||||
case 9
|
||||
|
|
|
@ -197,8 +197,10 @@ if ~nopenalty
|
|||
error('simplex_optimization_routine:: Initial condition is wrong!')
|
||||
else
|
||||
[v,fv,delta] = simplex_initialization(objective_function,initial_point,initial_score,delta,zero_delta,1,varargin{:});
|
||||
disp('Done!')
|
||||
skipline()
|
||||
if verbose
|
||||
disp('Done!')
|
||||
skipline()
|
||||
end
|
||||
func_count = number_of_variables + 1;
|
||||
iter_count = 1;
|
||||
if verbose
|
||||
|
|
|
@ -146,20 +146,6 @@ public:
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
# define __CROSS_COMPILATION__
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW64__
|
||||
# define __CROSS_COMPILATION__
|
||||
#endif
|
||||
|
||||
#ifdef __CROSS_COMPILATION__
|
||||
# define M_PI 3.14159265358979323846
|
||||
# define M_SQRT2 1.41421356237309504880
|
||||
# define finite(x) !std::isfinite(x)
|
||||
#endif
|
||||
|
||||
//#define DEBUG
|
||||
using namespace std;
|
||||
|
||||
|
|
|
@ -35,21 +35,45 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException)
|
|||
dynamicHinstance = LoadLibrary(fName.c_str());
|
||||
if (dynamicHinstance == NULL)
|
||||
throw 1;
|
||||
Dynamic = (DynamicDLLFn) GetProcAddress(dynamicHinstance, "Dynamic");
|
||||
if (Dynamic == NULL)
|
||||
ntt = (int *) GetProcAddress(dynamicHinstance, "ntt");
|
||||
dynamic_resid_tt = (dynamic_tt_fct) GetProcAddress(dynamicHinstance, "dynamic_resid_tt");
|
||||
dynamic_resid = (dynamic_resid_fct) GetProcAddress(dynamicHinstance, "dynamic_resid");
|
||||
dynamic_g1_tt = (dynamic_tt_fct) GetProcAddress(dynamicHinstance, "dynamic_g1_tt");
|
||||
dynamic_g1 = (dynamic_g1_fct) GetProcAddress(dynamicHinstance, "dynamic_g1");
|
||||
dynamic_g2_tt = (dynamic_tt_fct) GetProcAddress(dynamicHinstance, "dynamic_g2_tt");
|
||||
dynamic_g2 = (dynamic_g2_fct) GetProcAddress(dynamicHinstance, "dynamic_g2");
|
||||
dynamic_g3_tt = (dynamic_tt_fct) GetProcAddress(dynamicHinstance, "dynamic_g3_tt");
|
||||
dynamic_g3 = (dynamic_g3_fct) GetProcAddress(dynamicHinstance, "dynamic_g3");
|
||||
if (ntt == NULL
|
||||
|| dynamic_resid_tt == NULL || dynamic_resid == NULL
|
||||
|| dynamic_g1_tt == NULL || dynamic_g1 == NULL
|
||||
|| dynamic_g2_tt == NULL || dynamic_g2 == NULL
|
||||
|| dynamic_g3_tt == NULL || dynamic_g3 == NULL)
|
||||
{
|
||||
FreeLibrary(dynamicHinstance); // Free the library
|
||||
throw 2;
|
||||
}
|
||||
#else // Linux or Mac
|
||||
dynamicHinstance = dlopen(fName.c_str(), RTLD_NOW);
|
||||
if ((dynamicHinstance == NULL) || dlerror())
|
||||
if (dynamicHinstance == NULL)
|
||||
{
|
||||
cerr << dlerror() << endl;
|
||||
throw 1;
|
||||
}
|
||||
Dynamic = (DynamicDLLFn) dlsym(dynamicHinstance, "Dynamic");
|
||||
if ((Dynamic == NULL) || dlerror())
|
||||
ntt = (int *) dlsym(dynamicHinstance, "ntt");
|
||||
dynamic_resid_tt = (dynamic_tt_fct) dlsym(dynamicHinstance, "dynamic_resid_tt");
|
||||
dynamic_resid = (dynamic_resid_fct) dlsym(dynamicHinstance, "dynamic_resid");
|
||||
dynamic_g1_tt = (dynamic_tt_fct) dlsym(dynamicHinstance, "dynamic_g1_tt");
|
||||
dynamic_g1 = (dynamic_g1_fct) dlsym(dynamicHinstance, "dynamic_g1");
|
||||
dynamic_g2_tt = (dynamic_tt_fct) dlsym(dynamicHinstance, "dynamic_g2_tt");
|
||||
dynamic_g2 = (dynamic_g2_fct) dlsym(dynamicHinstance, "dynamic_g2");
|
||||
dynamic_g3_tt = (dynamic_tt_fct) dlsym(dynamicHinstance, "dynamic_g3_tt");
|
||||
dynamic_g3 = (dynamic_g3_fct) dlsym(dynamicHinstance, "dynamic_g3");
|
||||
if (ntt == NULL
|
||||
|| dynamic_resid_tt == NULL || dynamic_resid == NULL
|
||||
|| dynamic_g1_tt == NULL || dynamic_g1 == NULL
|
||||
|| dynamic_g2_tt == NULL || dynamic_g2 == NULL
|
||||
|| dynamic_g3_tt == NULL || dynamic_g3 == NULL)
|
||||
{
|
||||
dlclose(dynamicHinstance); // Free the library
|
||||
cerr << dlerror() << endl;
|
||||
|
@ -65,13 +89,13 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException)
|
|||
if (i == 1)
|
||||
msg << "can't dynamically load the file";
|
||||
if (i == 2)
|
||||
msg << "can't locate the 'Dynamic' symbol";
|
||||
msg << "can't locate the relevant dynamic symbols within the MEX file";
|
||||
msg << ")";
|
||||
throw DynareException(__FILE__, __LINE__, msg.str());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw DynareException(__FILE__, __LINE__, string("Can't find Dynamic function in ") + fName);
|
||||
throw DynareException(__FILE__, __LINE__, string("Can't find the relevant dynamic symbols in ") + fName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,6 +114,21 @@ void
|
|||
DynamicModelDLL::eval(const Vector &y, const Vector &x, const Vector &modParams, const Vector &ySteady,
|
||||
Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) throw (DynareException)
|
||||
{
|
||||
Dynamic(y.base(), x.base(), 1, modParams.base(), ySteady.base(), 0, residual.base(), g1->base(),
|
||||
g2 == NULL ? NULL : g2->base(), g3 == NULL ? NULL : g3->base());
|
||||
double *T = (double *) malloc(sizeof(double) * (*ntt));
|
||||
dynamic_resid_tt(y.base(), x.base(), 1, modParams.base(), ySteady.base(), 0, T);
|
||||
dynamic_resid(y.base(), x.base(), 1, modParams.base(), ySteady.base(), 0, T, residual.base());
|
||||
if (g1 || g2 || g3)
|
||||
dynamic_g1_tt(y.base(), x.base(), 1, modParams.base(), ySteady.base(), 0, T);
|
||||
if (g1)
|
||||
dynamic_g1(y.base(), x.base(), 1, modParams.base(), ySteady.base(), 0, T, g1->base());
|
||||
if (g2 || g3)
|
||||
dynamic_g2_tt(y.base(), x.base(), 1, modParams.base(), ySteady.base(), 0, T);
|
||||
if (g2)
|
||||
dynamic_g2(y.base(), x.base(), 1, modParams.base(), ySteady.base(), 0, T, g2->base());
|
||||
if (g3)
|
||||
{
|
||||
dynamic_g3_tt(y.base(), x.base(), 1, modParams.base(), ySteady.base(), 0, T);
|
||||
dynamic_g3(y.base(), x.base(), 1, modParams.base(), ySteady.base(), 0, T, g3->base());
|
||||
}
|
||||
free(T);
|
||||
}
|
||||
|
|
|
@ -34,9 +34,11 @@
|
|||
#include "dynamic_abstract_class.hh"
|
||||
#include "dynare_exception.h"
|
||||
|
||||
// <model>_Dynamic DLL pointer
|
||||
typedef void (*DynamicDLLFn)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state,
|
||||
int it_, double *residual, double *g1, double *g2, double *g3);
|
||||
typedef void (*dynamic_tt_fct)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, double *T);
|
||||
typedef void (*dynamic_resid_fct) (const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *residual);
|
||||
typedef void (*dynamic_g1_fct)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *g1);
|
||||
typedef void (*dynamic_g2_fct)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *v2);
|
||||
typedef void (*dynamic_g3_fct)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *v3);
|
||||
|
||||
/**
|
||||
* creates pointer to Dynamic function inside <model>_dynamic.dll
|
||||
|
@ -45,7 +47,12 @@ typedef void (*DynamicDLLFn)(const double *y, const double *x, int nb_row_x, con
|
|||
class DynamicModelDLL : public DynamicModelAC
|
||||
{
|
||||
private:
|
||||
DynamicDLLFn Dynamic; // pointer to the Dynamic function in DLL
|
||||
int *ntt;
|
||||
dynamic_tt_fct dynamic_resid_tt, dynamic_g1_tt, dynamic_g2_tt, dynamic_g3_tt;
|
||||
dynamic_resid_fct dynamic_resid;
|
||||
dynamic_g1_fct dynamic_g1;
|
||||
dynamic_g2_fct dynamic_g2;
|
||||
dynamic_g3_fct dynamic_g3;
|
||||
#if defined(_WIN32) || defined(__CYGWIN32__)
|
||||
HINSTANCE dynamicHinstance; // DLL instance pointer in Windows
|
||||
#else
|
||||
|
|
|
@ -40,18 +40,6 @@ using namespace std;
|
|||
#endif
|
||||
#define DEBUG_OMP 0
|
||||
|
||||
#ifdef __MINGW32__
|
||||
# define __CROSS_COMPILATION__
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW64__
|
||||
# define __CROSS_COMPILATION__
|
||||
#endif
|
||||
|
||||
#ifdef __CROSS_COMPILATION__
|
||||
# define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
T
|
||||
icdf(const T uniform)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 55b625b0168a200ee9ceb7cc7241ef3ed204fc25
|
||||
Subproject commit bef7c2a1938f1201cffbddc8d597b2a486fd36c6
|
|
@ -189,10 +189,12 @@ MODFILES = \
|
|||
simul/simul_ZLB_purely_forward_no_solution.mod \
|
||||
simul/Irreversible_investment.mod \
|
||||
simul/linear_state_space_arma.mod \
|
||||
conditional_forecasts/1/fs2000_cal.mod \
|
||||
conditional_forecasts/2/fs2000_est.mod \
|
||||
conditional_forecasts/3/fs2000_conditional_forecast_initval.mod \
|
||||
conditional_forecasts/4/fs2000_conditional_forecast_histval.mod \
|
||||
conditional_forecasts/5/fs2000_cal.mod \
|
||||
conditional_forecasts/6/fs2000_cal.mod \
|
||||
recursive/ls2003.mod \
|
||||
recursive/ls2003_bayesian.mod \
|
||||
recursive/ls2003_bayesian_xls.mod \
|
||||
|
@ -994,7 +996,7 @@ check-octave: $(O_XFAIL_TRS_FILES) $(O_TRS_FILES)
|
|||
%.m.tls : %.m
|
||||
@echo "`tput bold``tput setaf 8`MATLAB: $(CURDIR)/$*... `tput sgr0`"
|
||||
@TOP_TEST_DIR="$(CURDIR)" FILESTEM="$*" \
|
||||
$(MATLAB)/bin/matlab -nosplash -nodisplay -r run_m_script 2> /dev/null
|
||||
$(MATLAB)/bin/matlab -nosplash -nodisplay -r run_m_script >/dev/null 2>&1
|
||||
@touch $*.m.tls
|
||||
@echo "`tput bold`MATLAB`tput setaf 8`: $(CURDIR)/$* Done!`tput sgr0`"
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ varobs gp_obs gy_obs;
|
|||
|
||||
options_.solve_tolf = 1e-12;
|
||||
|
||||
estimation(order=1,mode_compute=5,analytic_derivation,kalman_algo=1,datafile=fsdat_simul,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8);
|
||||
estimation(order=1,mode_compute=9,analytic_derivation,kalman_algo=1,datafile=fsdat_simul,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8);
|
||||
estimation(order=1,mode_compute=5,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=2,datafile=fsdat_simul,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8);
|
||||
estimation(order=1,mode_compute=4,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=1,datafile=fsdat_simul,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8);
|
||||
estimation(order=1,mode_compute=4,mode_file=fs2000_analytic_derivation_mode,analytic_derivation,kalman_algo=2,datafile=fsdat_simul,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8);
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
// See fs2000.mod in the examples/ directory for details on the model
|
||||
|
||||
var m P c e W R k d n l gy_obs gp_obs y dA;
|
||||
varexo e_a e_m;
|
||||
|
||||
parameters alp bet gam mst rho psi del;
|
||||
|
||||
alp = 0.33;
|
||||
bet = 0.99;
|
||||
gam = 0.003;
|
||||
mst = 1.011;
|
||||
rho = 0.7;
|
||||
psi = 0.787;
|
||||
del = 0.02;
|
||||
|
||||
model;
|
||||
dA = exp(gam+e_a);
|
||||
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
|
||||
-P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
|
||||
W = l/n;
|
||||
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
|
||||
R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
|
||||
1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0;
|
||||
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
|
||||
P*c = m;
|
||||
m-1+d = l;
|
||||
e = exp(e_a);
|
||||
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
|
||||
gy_obs = dA*y/y(-1);
|
||||
gp_obs = (P/P(-1))*m(-1)/dA;
|
||||
end;
|
||||
|
||||
steady_state_model;
|
||||
dA = exp(gam);
|
||||
gst = 1/dA;
|
||||
m = mst;
|
||||
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
|
||||
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
|
||||
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
|
||||
n = xist/(nust+xist);
|
||||
P = xist + nust;
|
||||
k = khst*n;
|
||||
|
||||
l = psi*mst*n/( (1-psi)*(1-n) );
|
||||
c = mst/P;
|
||||
d = l - mst + 1;
|
||||
y = k^alp*n^(1-alp)*gst^alp;
|
||||
R = mst/bet;
|
||||
W = l/n;
|
||||
ist = y-c;
|
||||
q = 1 - d;
|
||||
|
||||
e = 1;
|
||||
|
||||
gp_obs = m/dA;
|
||||
gy_obs = dA;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_a; stderr 0.014;
|
||||
var e_m; stderr 0.005;
|
||||
end;
|
||||
|
||||
steady;
|
||||
|
||||
check;
|
||||
|
||||
stoch_simul(irf=0);
|
||||
|
||||
conditional_forecast_paths;
|
||||
var gy_obs;
|
||||
periods 1 2 3:5;
|
||||
values 0.01 -0.02 0;
|
||||
var gp_obs;
|
||||
periods 1:7;
|
||||
values 0.05;
|
||||
end;
|
||||
|
||||
conditional_forecast(parameter_set=calibration, controlled_varexo=(e_a,e_m));
|
||||
|
||||
plot_conditional_forecast(periods=10) gy_obs gp_obs;
|
||||
|
|
@ -100,6 +100,6 @@ estimation(order=1, datafile='../fsdat_simul', nobs=192, loglinear, mh_replic=20
|
|||
|
||||
mhdata = load('fs2000/metropolis/fs2000_mh_history_0.mat');
|
||||
|
||||
if any(abs(mhdata.record.AcceptanceRatio-options_.mh_tune_jscale.target)>options_.mh_tune_jscale.c1)
|
||||
if any(abs(mhdata.record.AcceptanceRatio-options_.mh_tune_jscale.target)>options_.mh_tune_jscale.c2)
|
||||
error('Automagic tuning of the MCMC proposal scale parameter did not work as expected!')
|
||||
end
|
|
@ -52,15 +52,15 @@ SmoothedShocks(:,:,6)=cell2mat(struct2cell(oo_.SmoothedShocks));
|
|||
SmoothedVariables(:,:,6)=cell2mat(struct2cell(oo_.SmoothedVariables));
|
||||
|
||||
|
||||
if max(max(abs(SmoothedMeasurementErrors-repmat(SmoothedMeasurementErrors(:,:,1),[1,1,6]))))>1e-8
|
||||
if max(max(abs(SmoothedMeasurementErrors-repmat(SmoothedMeasurementErrors(:,:,1),[1,1,6]))))>1e-6
|
||||
error('SmoothedMeasurementErrors do not match')
|
||||
end
|
||||
|
||||
if max(max(abs(SmoothedShocks-repmat(SmoothedShocks(:,:,1),[1,1,6]))))>1e-8
|
||||
if max(max(abs(SmoothedShocks-repmat(SmoothedShocks(:,:,1),[1,1,6]))))>1e-6
|
||||
error('SmoothedShocks do not match')
|
||||
end
|
||||
|
||||
if max(max(abs(SmoothedVariables-repmat(SmoothedVariables(:,:,1),[1,1,6]))))>1e-8
|
||||
if max(max(abs(SmoothedVariables-repmat(SmoothedVariables(:,:,1),[1,1,6]))))>1e-6
|
||||
error('SmoothedVariables do not match')
|
||||
end
|
||||
|
||||
|
|
|
@ -103,9 +103,9 @@ Section "MEX files for MATLAB 64-bit, version 7.8 to 9.3 (R2009a to R2017b)"
|
|||
File ..\mex\matlab\win64-7.8-9.3\*.mexw64
|
||||
SectionEnd
|
||||
|
||||
Section "MEX files for MATLAB 64-bit, version 9.4 (R2018a)"
|
||||
SetOutPath $INSTDIR\mex\matlab\win64-9.4
|
||||
File ..\mex\matlab\win64-9.4\*.mexw64
|
||||
Section "MEX files for MATLAB 64-bit, version 9.4 to 9.5 (R2018a to R2018b)"
|
||||
SetOutPath $INSTDIR\mex\matlab\win64-9.4-9.5
|
||||
File ..\mex\matlab\win64-9.4-9.5\*.mexw64
|
||||
SectionEnd
|
||||
|
||||
SectionGroupEnd
|
||||
|
|
Loading…
Reference in New Issue