Merge branch 'master' of ssh://kirikou.dynare.org/srv/d_kirikou/git/dynare
commit
cf2e477e58
|
@ -1,4 +1,4 @@
|
||||||
dnl Copyright (C) 2009-2011 Dynare Team
|
dnl Copyright (C) 2009-2012 Dynare Team
|
||||||
dnl
|
dnl
|
||||||
dnl This file is part of Dynare.
|
dnl This file is part of Dynare.
|
||||||
dnl
|
dnl
|
||||||
|
@ -62,7 +62,7 @@ case ${MATLAB_ARCH} in
|
||||||
ax_mexopts_ok="yes"
|
ax_mexopts_ok="yes"
|
||||||
;;
|
;;
|
||||||
maci | maci64)
|
maci | maci64)
|
||||||
SDKROOT='/Developer/SDKs/MacOSX10.6.sdk'
|
SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk'
|
||||||
MACOSX_DEPLOYMENT_TARGET='10.6'
|
MACOSX_DEPLOYMENT_TARGET='10.6'
|
||||||
if test "${MATLAB_ARCH}" = "maci"; then
|
if test "${MATLAB_ARCH}" = "maci"; then
|
||||||
ARCHS='i386'
|
ARCHS='i386'
|
||||||
|
|
|
@ -35,7 +35,9 @@ function [fval,grad,hess,exit_flag,info,PHI,SIGMAu,iXX,prior] = DsgeVarLikelihoo
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
% Declaration of the persistent variables.
|
% Declaration of the persistent variables.
|
||||||
persistent penalty dsge_prior_weight_idx
|
persistent dsge_prior_weight_idx
|
||||||
|
|
||||||
|
penalty = BayesInfo.penalty;
|
||||||
|
|
||||||
grad=[];
|
grad=[];
|
||||||
hess=[];
|
hess=[];
|
||||||
|
@ -46,16 +48,6 @@ SIGMAu = [];
|
||||||
iXX = [];
|
iXX = [];
|
||||||
prior = [];
|
prior = [];
|
||||||
|
|
||||||
% Initialization of the penalty
|
|
||||||
if ~nargin || isempty(penalty)
|
|
||||||
penalty = 1e8;
|
|
||||||
if ~nargin, return, end
|
|
||||||
end
|
|
||||||
if nargin==1
|
|
||||||
penalty = xparam1;
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
% Initialization of of the index for parameter dsge_prior_weight in Model.params.
|
% Initialization of of the index for parameter dsge_prior_weight in Model.params.
|
||||||
if isempty(dsge_prior_weight_idx)
|
if isempty(dsge_prior_weight_idx)
|
||||||
dsge_prior_weight_idx = strmatch('dsge_prior_weight',Model.param_names);
|
dsge_prior_weight_idx = strmatch('dsge_prior_weight',Model.param_names);
|
||||||
|
|
|
@ -644,11 +644,11 @@ else % flgresume
|
||||||
end
|
end
|
||||||
|
|
||||||
% initialize random number generator
|
% initialize random number generator
|
||||||
if ischar(opts.Seed)
|
% $$$ if ischar(opts.Seed)
|
||||||
randn('state', eval(opts.Seed)); % random number generator state
|
% $$$ randn('state', eval(opts.Seed)); % random number generator state
|
||||||
else
|
% $$$ else
|
||||||
randn('state', opts.Seed);
|
% $$$ randn('state', opts.Seed);
|
||||||
end
|
% $$$ end
|
||||||
%qqq
|
%qqq
|
||||||
% load(opts.SaveFilename, 'startseed');
|
% load(opts.SaveFilename, 'startseed');
|
||||||
% randn('state', startseed);
|
% randn('state', startseed);
|
||||||
|
|
|
@ -130,22 +130,7 @@ function [fval,DLIK,Hess,exit_flag,ys,trend_coeff,info,Model,DynareOptions,Bayes
|
||||||
|
|
||||||
% AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT FR
|
% AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT FR
|
||||||
|
|
||||||
% Declaration of the penalty as a persistent variable.
|
penalty = BayesInfo.penalty;
|
||||||
|
|
||||||
% Persistent variable 'penalty' is used to compute an endogenous penalty to
|
|
||||||
% the value 'fval' when various conditions are encountered. These conditions
|
|
||||||
% set also 'exit_flag' equal to 0 instead of 1. It is only when
|
|
||||||
% dsge_likelihood() is called by an optimizer called by
|
|
||||||
% dynare_estimation_1() that 'exit_flag' is ignored and penalized 'fval' is
|
|
||||||
% actually used.
|
|
||||||
% In that case, 'penalty' is properly initialized, at the very end of the
|
|
||||||
% present function, by a call to dsge_likelihood() made in
|
|
||||||
% initial_estimation_checks(). If a condition triggers exit_flag ==
|
|
||||||
% 0, initial_estimation_checks() triggers an error.
|
|
||||||
% In summary, an initial call to the present function, without triggering
|
|
||||||
% any condition, guarantees that 'penalty' is properly initialized when needed.
|
|
||||||
|
|
||||||
persistent penalty
|
|
||||||
|
|
||||||
% Initialization of the returned variables and others...
|
% Initialization of the returned variables and others...
|
||||||
fval = [];
|
fval = [];
|
||||||
|
@ -568,16 +553,16 @@ if analytic_derivation,
|
||||||
if full_Hess
|
if full_Hess
|
||||||
DTj = DT(:,:,j+offset);
|
DTj = DT(:,:,j+offset);
|
||||||
DPj = dum;
|
DPj = dum;
|
||||||
for i=1:j,
|
for i=1:j+offset,
|
||||||
DTi = DT(:,:,i+offset);
|
DTi = DT(:,:,i);
|
||||||
DPi = DP(:,:,i+offset);
|
DPi = DP(:,:,i);
|
||||||
D2Tij = D2T(:,:,i,j);
|
D2Tij = D2T(:,:,i,j+offset);
|
||||||
D2Omij = D2Om(:,:,i,j);
|
D2Omij = D2Om(:,:,i,j+offset);
|
||||||
tmp = D2Tij*Pstar*T' + T*Pstar*D2Tij' + DTi*DPj*T' + DTj*DPi*T' + T*DPj*DTi' + T*DPi*DTj' + DTi*Pstar*DTj' + DTj*Pstar*DTi' + D2Omij;
|
tmp = D2Tij*Pstar*T' + T*Pstar*D2Tij' + DTi*DPj*T' + DTj*DPi*T' + T*DPj*DTi' + T*DPi*DTj' + DTi*Pstar*DTj' + DTj*Pstar*DTi' + D2Omij;
|
||||||
dum = lyapunov_symm(T,tmp,DynareOptions.qz_criterium,DynareOptions.lyapunov_complex_threshold);
|
dum = lyapunov_symm(T,tmp,DynareOptions.qz_criterium,DynareOptions.lyapunov_complex_threshold);
|
||||||
dum(abs(dum)<1.e-12) = 0;
|
dum(abs(dum)<1.e-12) = 0;
|
||||||
D2P(:,:,i+offset,j+offset) = dum;
|
D2P(:,:,i,j+offset) = dum;
|
||||||
D2P(:,:,j+offset,i+offset) = dum;
|
D2P(:,:,j+offset,i) = dum;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -771,9 +756,6 @@ end
|
||||||
% Update DynareOptions.kalman_algo.
|
% Update DynareOptions.kalman_algo.
|
||||||
DynareOptions.kalman_algo = kalman_algo;
|
DynareOptions.kalman_algo = kalman_algo;
|
||||||
|
|
||||||
% Update the penalty.
|
|
||||||
penalty = fval;
|
|
||||||
|
|
||||||
if analytic_derivation==0 && nargout==2,
|
if analytic_derivation==0 && nargout==2,
|
||||||
lik=lik(start:end,:);
|
lik=lik(start:end,:);
|
||||||
DLIK=[-lnprior; lik(:)];
|
DLIK=[-lnprior; lik(:)];
|
||||||
|
|
|
@ -159,7 +159,7 @@ for i=1:n1
|
||||||
xx = x(:,m);
|
xx = x(:,m);
|
||||||
y(:,(i-1)*n1*n2+(j-1)*n2+k) = xx;
|
y(:,(i-1)*n1*n2+(j-1)*n2+k) = xx;
|
||||||
if j ~= i
|
if j ~= i
|
||||||
y(:,(j-1)*n1*n2+(i-1)*n2+i) = xx;
|
y(:,(j-1)*n1*n2+(i-1)*n2+k) = xx;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
% [err, g_0, g_1, g_2, g_3, derivs] = k_order_perturbation(dr,DynareModel,DynareOptions)
|
||||||
|
% computes a k_order_petrubation solution for k=1,2,3
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% dr: struct describing the reduced form solution of the model.
|
||||||
|
% DynareModel: struct jobs's parameters
|
||||||
|
% DynareOptions: struct job's options
|
||||||
|
%
|
||||||
|
% OUTPUTS
|
||||||
|
% err: double err code (currently unused)
|
||||||
|
% g_0: vector dynare++ output. Constant effect of future volatility (in
|
||||||
|
% dr.order_var order) on the decision rule
|
||||||
|
% (=ghs2/2). Contains zero when order of
|
||||||
|
% approximation is 1.
|
||||||
|
% g_1: matrix dynare++ output. First order Taylor coefficients
|
||||||
|
% of decision rule. When order of approximation
|
||||||
|
% is 3, the. Contains both the effect of
|
||||||
|
% state endogenous variable and shocks. The rows
|
||||||
|
% are in dr.order_var order. The columns are in
|
||||||
|
% dr.order_var order of state endogenous
|
||||||
|
% variables and shocks
|
||||||
|
% g_2: matrix dynare++ output. Second order Taylor coefficients of decision
|
||||||
|
% rule. Contains both the effect of state endogenous
|
||||||
|
% variable and shocks. The rows are in dr.order_var
|
||||||
|
% order. Each row corresponds to the vectorized
|
||||||
|
% version of the lower triangle of the Hessian
|
||||||
|
% matrix. The Taylor coefficient (1/2) is
|
||||||
|
% included. The columns of the Hessian matrix are in
|
||||||
|
% dr.order_var order of state endogenous variables
|
||||||
|
% and shocks
|
||||||
|
% g_3: matrix dynare++ output. Third order Taylor coefficients of decision
|
||||||
|
% rule. Contains both the effect of state endogenous
|
||||||
|
% variable and shocks. The rows are in dr.order_var
|
||||||
|
% order. Each row corresponds to the vectorized
|
||||||
|
% version of the 3rd order derivatives tensor where each
|
||||||
|
% combination of variables appears only once.
|
||||||
|
% The Taylor coefficient (1/6) is
|
||||||
|
% included. Inside the tensor, the variables are in
|
||||||
|
% dr.order_var order of state endogenous variables
|
||||||
|
% and shocks
|
||||||
|
% derivs struct contains the original derivatives of the
|
||||||
|
% decision function (ghx, ghu, ghxx, ghxu, ghuu,
|
||||||
|
% ghs2, ghxxx, ghxxu, ghxuu,ghuuu, ghxss, ghuss),
|
||||||
|
% keeping the effect of future volatility
|
||||||
|
% separate (in ghs2, ghxss and ghuss). The
|
||||||
|
% derivatives matrices contain full versions of
|
||||||
|
% the Hessian matrices and 3rd order
|
||||||
|
% tensor. Symmetric derivatives are repeated. The
|
||||||
|
% Taylor coefficients (1/2 and 1/6) aren't
|
||||||
|
% included.
|
||||||
|
% k_order_peturbation is a compiled MEX function. It's source code is in
|
||||||
|
% dynare/mex/sources/k_order_perturbation.cc and it uses code provided by
|
||||||
|
% dynare++
|
|
@ -180,9 +180,6 @@ if ~options_.load_mh_file && ~options_.mh_recover
|
||||||
% separate initializaton for each chain
|
% separate initializaton for each chain
|
||||||
JSUM = 0;
|
JSUM = 0;
|
||||||
for j=1:nblck,
|
for j=1:nblck,
|
||||||
JSUM = JSUM + sum(100*clock);
|
|
||||||
randn('state',JSUM);
|
|
||||||
rand('state',JSUM);
|
|
||||||
record.Seeds(j).Normal = randn('state');
|
record.Seeds(j).Normal = randn('state');
|
||||||
record.Seeds(j).Unifor = rand('state');
|
record.Seeds(j).Unifor = rand('state');
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
dnl Copyright (C) 2009-2011 Dynare Team
|
dnl Copyright (C) 2009-2012 Dynare Team
|
||||||
dnl
|
dnl
|
||||||
dnl This file is part of Dynare.
|
dnl This file is part of Dynare.
|
||||||
dnl
|
dnl
|
||||||
|
@ -17,7 +17,7 @@ dnl
|
||||||
dnl You should have received a copy of the GNU General Public License
|
dnl You should have received a copy of the GNU General Public License
|
||||||
dnl along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
dnl along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
AC_PREREQ([2.61])
|
AC_PREREQ([2.62])
|
||||||
AC_INIT([dynare], [4.4-unstable])
|
AC_INIT([dynare], [4.4-unstable])
|
||||||
AC_CONFIG_SRCDIR([configure.ac])
|
AC_CONFIG_SRCDIR([configure.ac])
|
||||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
|
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
dnl Copyright (C) 2009-2011 Dynare Team
|
dnl Copyright (C) 2009-2012 Dynare Team
|
||||||
dnl
|
dnl
|
||||||
dnl This file is part of Dynare.
|
dnl This file is part of Dynare.
|
||||||
dnl
|
dnl
|
||||||
|
@ -17,7 +17,7 @@ dnl
|
||||||
dnl You should have received a copy of the GNU General Public License
|
dnl You should have received a copy of the GNU General Public License
|
||||||
dnl along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
dnl along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
AC_PREREQ([2.61])
|
AC_PREREQ([2.62])
|
||||||
AC_INIT([dynare], [4.4-unstable])
|
AC_INIT([dynare], [4.4-unstable])
|
||||||
AC_CONFIG_SRCDIR([configure.ac])
|
AC_CONFIG_SRCDIR([configure.ac])
|
||||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
|
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
|
||||||
|
|
|
@ -260,8 +260,6 @@ extern "C" {
|
||||||
// run stochastic steady
|
// run stochastic steady
|
||||||
app.walkStochSteady();
|
app.walkStochSteady();
|
||||||
|
|
||||||
app.get_rule_ders()->print();
|
|
||||||
|
|
||||||
/* Write derivative outputs into memory map */
|
/* Write derivative outputs into memory map */
|
||||||
map<string, ConstTwoDMatrix> mm;
|
map<string, ConstTwoDMatrix> mm;
|
||||||
app.getFoldDecisionRule().writeMMap(mm, string());
|
app.getFoldDecisionRule().writeMMap(mm, string());
|
||||||
|
|
Loading…
Reference in New Issue