Merge branch 'master' into rmExtraExo

time-shift
Houtan Bastani 2015-04-14 11:33:57 +02:00
commit 69ec4bf269
22 changed files with 170 additions and 73 deletions

View File

@ -5221,6 +5221,8 @@ singularity is encountered, Dynare by default automatically switches to the univ
@item kalman_tol = @var{DOUBLE}
@anchor{kalman_tol} Numerical tolerance for determining the singularity of the covariance matrix of the prediction errors during the Kalman filter (minimum allowed reciprocal of the matrix condition number). Default value is @code{1e-10}
@item diffuse_kalman_tol = @var{DOUBLE}
@anchor{diffuse_kalman_tol} Numerical tolerance for determining the singularity of the covariance matrix of the prediction errors (@math{F_{\infty}}) and the rank of the covariance matrix of the state variables (@math{P_{\infty}}) during the Diffuse Kalman filter. Default value is @code{1e-8}
@item filter_covariance
@anchor{filter_covariance} Saves the series of one step ahead error of

View File

@ -39,16 +39,16 @@ License: public-domain
Journal of Economic Dynamics and Control, 2010, vol. 34, issue 3,
pages 472-489
Files: matlab/bfgsi1.m matlab/csolve.m matlab/csminit1.m matlab/numgrad2.m
matlab/numgrad3.m matlab/numgrad3_.m matlab/numgrad5.m
matlab/numgrad5_.m matlab/csminwel1.m matlab/bvar_density.m
Files: matlab/bfgsi1.m matlab/csolve.m matlab/optimization/csminit1.m matlab/optimization/numgrad2.m
matlab/optimization/numgrad3.m matlab/optimization/numgrad3_.m matlab/optimization/numgrad5.m
matlab/optimization/numgrad5_.m matlab/optimization/csminwel1.m matlab/bvar_density.m
matlab/bvar_toolbox.m matlab/partial_information/PI_gensys.m matlab/qzswitch.m
matlab/qzdiv.m
Copyright: 1993-2009 Christopher Sims
2006-2013 Dynare Team
License: GPL-3+
Files: matlab/cmaes.m
Files: matlab/optimization/cmaes.m
Copyright: 2001-2012 Nikolaus Hansen
2012 Dynare Team
License: GPL-3+
@ -63,7 +63,7 @@ Copyright: 2008-2012 VZLU Prague, a.s.
2014 Dynare Team
License: GPL-3+
Files: matlab/simpsa.m matlab/simpsaget.m matlab/simpsaset.m
Files: matlab/optimization/simpsa.m matlab/optimization/simpsaget.m matlab/optimization/simpsaset.m
Copyright: 2005 Henning Schmidt, FCC, henning@fcc.chalmers.se
2006 Brecht Donckels, BIOMATH, brecht.donckels@ugent.be
2013 Dynare Team

View File

@ -69,9 +69,16 @@ M_ = set_all_parameters(xparam1,estim_params_,M_);
%------------------------------------------------------------------------------
% 2. call model setup & reduction program
%------------------------------------------------------------------------------
oldoo.restrict_var_list = oo_.dr.restrict_var_list;
oldoo.restrict_columns = oo_.dr.restrict_columns;
oo_.dr.restrict_var_list = bayestopt_.smoother_var_list;
oo_.dr.restrict_columns = bayestopt_.smoother_restrict_columns;
[T,R,SteadyState,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
oo_.dr.restrict_var_list = oldoo.restrict_var_list;
oo_.dr.restrict_columns = oldoo.restrict_columns;
bayestopt_.mf = bayestopt_.smoother_mf;
if options_.noconstant
constant = zeros(vobs,1);
@ -174,6 +181,7 @@ elseif options_.lik_init == 5 % Old diffuse Kalman filter only for th
Pinf = [];
end
kalman_tol = options_.kalman_tol;
diffuse_kalman_tol = options_.diffuse_kalman_tol;
riccati_tol = options_.riccati_tol;
data1 = Y-trend;
% -----------------------------------------------------------------------------
@ -199,7 +207,7 @@ if kalman_algo == 1 || kalman_algo == 3
[alphahat,epsilonhat,etahat,ahat,P,aK,PK,decomp] = missing_DiffuseKalmanSmootherH1_Z(ST, ...
Z,R1,Q,H,Pinf,Pstar, ...
data1,vobs,np,smpl,data_index, ...
options_.nk,kalman_tol,options_.filter_decomposition);
options_.nk,kalman_tol,diffuse_kalman_tol,options_.filter_decomposition);
if isinf(alphahat)
if kalman_algo == 1
kalman_algo = 2;
@ -226,7 +234,7 @@ if kalman_algo == 2 || kalman_algo == 4
[alphahat,epsilonhat,etahat,ahat,P,aK,PK,decomp] = missing_DiffuseKalmanSmootherH3_Z(ST, ...
Z,R1,Q,diag(H), ...
Pinf,Pstar,data1,vobs,np,smpl,data_index, ...
options_.nk,kalman_tol,...
options_.nk,kalman_tol,diffuse_kalman_tol, ...
options_.filter_decomposition);
end

View File

@ -631,7 +631,7 @@ if analytic_derivation,
analytic_deriv_info={analytic_derivation,DT,DYss,DOm,DH,DP,asy_Hess};
else
analytic_deriv_info={analytic_derivation,DT,DYss,DOm,DH,DP,D2T,D2Yss,D2Om,D2H,D2P};
clear DT DYss DOm DH DP D2T D2Yss D2Om D2H D2P,
clear DT DYss DOm DP D2T D2Yss D2Om D2H D2P,
end
else
analytic_deriv_info={0};

View File

@ -442,6 +442,9 @@ else
end;
if options_.analytic_derivation,
if options_.lik_init == 3,
error('analytic derivation is incompatible with diffuse filter')
end
options_.analytic_derivation = 1;
if ~(exist('sylvester3','file')==2),
dynareroot = strrep(which('dynare'),'dynare.m','');

View File

@ -387,6 +387,7 @@ options_.nobs = NaN;
options_.kalman_algo = 0;
options_.fast_kalman = 0;
options_.kalman_tol = 1e-10;
options_.diffuse_kalman_tol = 1e-8;
options_.use_univariate_filters_if_singularity_is_detected = 1;
options_.riccati_tol = 1e-6;
options_.lik_algo = 1;

View File

@ -89,8 +89,14 @@ if any(BayesInfo.pshape) % if Bayesian estimation
end
end
%% display warning if some parameters are still NaN
% display warning if some parameters are still NaN
test_for_deep_parameters_calibration(Model);
[lnprior, junk1,junk2,info]= priordens(xparam1,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4);
if info
fprintf('The prior density evaluated at the initial values is Inf for the following parameters: %s\n',BayesInfo.name{info,1})
error('The initial value of the prior is -Inf')
end
% Evaluate the likelihood.
ana_deriv = DynareOptions.analytic_derivation;

View File

@ -59,8 +59,9 @@ dlik = zeros(smpl,1); % Initialization of the vector gathering the densitie
dLIK = Inf; % Default value of the log likelihood.
oldK = Inf;
s = 0;
crit1=1.e-6;
while rank(Pinf,kalman_tol) && (t<=last)
while rank(Pinf,crit1) && (t<=last)
s = t-start+1;
v = Y(:,t)-Z*a;
Finf = Z*Pinf*Z';

View File

@ -66,13 +66,14 @@ t = start; % Initialization of the time index.
dlik = zeros(smpl,1); % Initialization of the vector gathering the densities.
dLIK = Inf; % Default value of the log likelihood.
oldK = Inf;
crit1=1.e-6;
if isequal(H,0)
H = zeros(pp,pp);
end
s = 0;
while rank(Pinf,kalman_tol) && (t<=last)
while rank(Pinf,crit1) && (t<=last)
s = t-start+1;
d_index = data_index{t};
if isempty(d_index)

View File

@ -110,7 +110,8 @@ dLIK = Inf; % Default value of the log likelihood.
oldK = Inf;
llik = zeros(smpl,pp);
newRank = rank(Pinf,kalman_tol);
crit1 = 1.e-6;
newRank = rank(Pinf,crit1);
l2pi = log(2*pi);
while newRank && (t<=last)
@ -138,7 +139,7 @@ while newRank && (t<=last)
end
end
if newRank
oldRank = rank(Pinf,kalman_tol);
oldRank = rank(Pinf,crit1);
else
oldRank = 0;
end
@ -146,7 +147,7 @@ while newRank && (t<=last)
Pstar = T*Pstar*T'+QQ;
Pinf = T*Pinf*T';
if newRank
newRank = rank(Pinf,kalman_tol);
newRank = rank(Pinf,crit1);
end
if oldRank ~= newRank
disp('univariate_diffuse_kalman_filter:: T does influence the rank of Pinf!')

View File

@ -1,6 +1,6 @@
function [alphahat,epsilonhat,etahat,atilde,P,aK,PK,decomp] = missing_DiffuseKalmanSmootherH1_Z(T,Z,R,Q,H,Pinf1,Pstar1,Y,pp,mm,smpl,data_index,nk,kalman_tol,decomp_flag)
function [alphahat,epsilonhat,etahat,atilde,P,aK,PK,decomp] = missing_DiffuseKalmanSmootherH1_Z(T,Z,R,Q,H,Pinf1,Pstar1,Y,pp,mm,smpl,data_index,nk,kalman_tol,diffuse_kalman_tol,decomp_flag)
% function [alphahat,epsilonhat,etahat,a,aK,PK,decomp] = DiffuseKalmanSmoother1(T,Z,R,Q,H,Pinf1,Pstar1,Y,pp,mm,smpl,data_index,nk,kalman_tol,decomp_flag)
% function [alphahat,epsilonhat,etahat,a,aK,PK,decomp] = DiffuseKalmanSmoother1(T,Z,R,Q,H,Pinf1,Pstar1,Y,pp,mm,smpl,data_index,nk,kalman_tol,diffuse_kalman_tol,decomp_flag)
% Computes the diffuse kalman smoother without measurement error, in the case of a non-singular var-cov matrix
%
% INPUTS
@ -18,6 +18,7 @@ function [alphahat,epsilonhat,etahat,atilde,P,aK,PK,decomp] = missing_DiffuseKal
% data_index [cell] 1*smpl cell of column vectors of indices.
% nk number of forecasting periods
% kalman_tol tolerance for reciprocal condition number
% diffuse_kalman_tol tolerance for reciprocal condition number (for Finf) and the rank of Pinf
% decomp_flag if true, compute filter decomposition
%
% OUTPUTS
@ -38,7 +39,7 @@ function [alphahat,epsilonhat,etahat,atilde,P,aK,PK,decomp] = missing_DiffuseKal
% Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series
% Analysis, vol. 24(1), pp. 85-98).
% Copyright (C) 2004-2011 Dynare Team
% Copyright (C) 2004-2015 Dynare Team
%
% This file is part of Dynare.
%
@ -80,7 +81,6 @@ Kstar = zeros(mm,pp,smpl);
P = zeros(mm,mm,smpl+1);
Pstar = zeros(spstar(1),spstar(2),smpl+1); Pstar(:,:,1) = Pstar1;
Pinf = zeros(spinf(1),spinf(2),smpl+1); Pinf(:,:,1) = Pinf1;
crit1 = 1.e-8;
steady = smpl;
rr = size(Q,1);
QQ = R*Q*transpose(R);
@ -91,7 +91,7 @@ epsilonhat = zeros(rr,smpl);
r = zeros(mm,smpl+1);
t = 0;
while rank(Pinf(:,:,t+1),crit1) && t<smpl
while rank(Pinf(:,:,t+1),diffuse_kalman_tol) && t<smpl
t = t+1;
di = data_index{t};
if isempty(di)
@ -103,8 +103,8 @@ while rank(Pinf(:,:,t+1),crit1) && t<smpl
ZZ = Z(di,:);
v(di,t)= Y(di,t) - ZZ*a(:,t);
Finf = ZZ*Pinf(:,:,t)*ZZ';
if rcond(Finf) < kalman_tol
if ~all(abs(Finf(:)) < kalman_tol)
if rcond(Finf) < diffuse_kalman_tol
if ~all(abs(Finf(:)) < diffuse_kalman_tol)
% The univariate diffuse kalman filter should be used.
alphahat = Inf;
return
@ -170,7 +170,7 @@ while notsteady && t<smpl
F = ZZ*P(:,:,t)*ZZ' + H(di,di);
if rcond(F) < kalman_tol
alphahat = Inf;
return
return
end
iF(di,di,t) = inv(F);
PZI = P(:,:,t)*ZZ'*iF(di,di,t);

View File

@ -1,4 +1,4 @@
function [alphahat,epsilonhat,etahat,a,P,aK,PK,decomp] = missing_DiffuseKalmanSmootherH3_Z(T,Z,R,Q,H,Pinf1,Pstar1,Y,pp,mm,smpl,data_index,nk,kalman_tol,decomp_flag)
function [alphahat,epsilonhat,etahat,a,P,aK,PK,decomp] = missing_DiffuseKalmanSmootherH3_Z(T,Z,R,Q,H,Pinf1,Pstar1,Y,pp,mm,smpl,data_index,nk,kalman_tol,diffuse_kalman_tol,decomp_flag)
% function [alphahat,epsilonhat,etahat,a1,P,aK,PK,d,decomp] = missing_DiffuseKalmanSmootherH3_Z(T,Z,R,Q,H,Pinf1,Pstar1,Y,pp,mm,smpl,data_index,nk,kalman_tol,decomp_flag)
% Computes the diffuse kalman smoother without measurement error, in the case of a singular var-cov matrix.
% Univariate treatment of multivariate time series.
@ -17,7 +17,8 @@ function [alphahat,epsilonhat,etahat,a,P,aK,PK,decomp] = missing_DiffuseKalmanSm
% smpl: sample size
% data_index [cell] 1*smpl cell of column vectors of indices.
% nk number of forecasting periods
% kalman_tol tolerance for zero divider
% kalman_tol tolerance for zero divider
% diffuse_kalman_tol tolerance for zero divider
% decomp_flag if true, compute filter decomposition
%
% OUTPUTS
@ -38,7 +39,7 @@ function [alphahat,epsilonhat,etahat,a,P,aK,PK,decomp] = missing_DiffuseKalmanSm
% Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series
% Analysis, vol. 24(1), pp. 85-98).
% Copyright (C) 2004-2011 Dynare Team
% Copyright (C) 2004-2015 Dynare Team
%
% This file is part of Dynare.
%
@ -80,7 +81,6 @@ Pstar = zeros(spstar(1),spstar(2),smpl); Pstar(:,:,1) = Pstar1;
Pinf = zeros(spinf(1),spinf(2),smpl); Pinf(:,:,1) = Pinf1;
Pstar1 = Pstar;
Pinf1 = Pinf;
crit1 = 1.e-6;
steady = smpl;
rr = size(Q,1); % number of structural shocks
QQ = R*Q*transpose(R);
@ -92,7 +92,7 @@ r = zeros(mm,smpl);
t = 0;
icc=0;
newRank = rank(Pinf(:,:,1),crit1);
newRank = rank(Pinf(:,:,1),diffuse_kalman_tol);
while newRank && t < smpl
t = t+1;
a(:,t) = a1(:,t);
@ -121,7 +121,7 @@ while newRank && t < smpl
end
end
if newRank
oldRank = rank(Pinf(:,:,t),crit1);
oldRank = rank(Pinf(:,:,t),diffuse_kalman_tol);
else
oldRank = 0;
end
@ -134,7 +134,7 @@ while newRank && t < smpl
Pinf(:,:,t+1) = T*Pinf(:,:,t)*T';
P0=Pinf(:,:,t+1);
if newRank,
newRank = rank(Pinf(:,:,t+1),crit1);
newRank = rank(Pinf(:,:,t+1),diffuse_kalman_tol);
end
if oldRank ~= newRank
disp('univariate_diffuse_kalman_filter:: T does influence the rank of Pinf!')

View File

@ -149,7 +149,7 @@ for plt = 1:nbplt,
y(i,2) = (y(i,1)+lnprior-dy);
end
end
plot(z,-y);
fighandle=plot(z,-y);
hold on
yl=get(gca,'ylim');
plot( [x(kk) x(kk)], yl, 'c', 'LineWidth', 1)
@ -173,8 +173,9 @@ for plt = 1:nbplt,
else
axes('position',[0.3 0.01 0.42 0.05],'box','on'),
end
plot([0.48 0.68],[0.5 0.5],'color',[0 0.5 0])
hold on, plot([0.04 0.24],[0.5 0.5],'b')
line_color=get(fighandle,'color');
plot([0.48 0.68],[0.5 0.5],'color',line_color{2})
hold on, plot([0.04 0.24],[0.5 0.5],'color',line_color{1})
set(gca,'xlim',[0 1],'ylim',[0 1],'xtick',[],'ytick',[])
text(0.25,0.5,'log-post')
text(0.69,0.5,'log-lik kernel')

View File

@ -178,9 +178,6 @@ switch minimizer_algorithm
end
[opt_par_values,hessian_mat,gg,fval,invhess] = newrat(objective_function,start_par_value,analytic_grad,crit,nit,0,varargin{:});
%hessian_mat is the plain outer product gradient Hessian
if options_.analytic_derivation %Hessian is already analytic one, reset option
options_.analytic_derivation = ana_deriv;
end
case 6
[opt_par_values, hessian_mat, Scale, fval] = gmhmaxlik(objective_function, start_par_value, ...
Initial_Hessian, options_.mh_jscale, bounds, prior_information.p2, options_.gmhmaxlik, options_.optim_opt, varargin{:});

View File

@ -98,13 +98,13 @@ MAX_ninno = min(B,ceil(MaxNumberOfBytes/(exo_nbr*gend)/8));
MAX_nerro = min(B,ceil(MaxNumberOfBytes/(size(options_.varobs,1)*gend)/8));
if naK
MAX_naK = min(B,ceil(MaxNumberOfBytes/(length(options_.varobs)* ...
length(options_.filter_step_ahead)*gend)/8));
MAX_naK = min(B,ceil(MaxNumberOfBytes/(endo_nbr* ...
length(options_.filter_step_ahead)*(gend+max(options_.filter_step_ahead)))/8));
end
if horizon
MAX_nforc1 = min(B,ceil(MaxNumberOfBytes/((endo_nbr)*horizon)/8));
MAX_nforc2 = min(B,ceil(MaxNumberOfBytes/((endo_nbr)*horizon)/ ...
MAX_nforc1 = min(B,ceil(MaxNumberOfBytes/((endo_nbr)*(horizon+maxlag))/8));
MAX_nforc2 = min(B,ceil(MaxNumberOfBytes/((endo_nbr)*(horizon+maxlag))/ ...
8));
IdObs = bayestopt_.mfys;

View File

@ -1,4 +1,4 @@
function [logged_prior_density, dlprior, d2lprior] = priordens(x, pshape, p6, p7, p3, p4,initialization)
function [logged_prior_density, dlprior, d2lprior, info] = priordens(x, pshape, p6, p7, p3, p4,initialization)
% Computes a prior density for the structural parameters of DSGE models
%
% INPUTS
@ -12,6 +12,7 @@ function [logged_prior_density, dlprior, d2lprior] = priordens(x, pshape, p6, p7
%
% OUTPUTS
% logged_prior_density [double] scalar, log of the prior density evaluated at x.
% info [double] error code for index of Inf-prior parameter
%
% Copyright (C) 2003-2012 Dynare Team
@ -34,6 +35,8 @@ function [logged_prior_density, dlprior, d2lprior] = priordens(x, pshape, p6, p7
persistent id1 id2 id3 id4 id5 id6
persistent tt1 tt2 tt3 tt4 tt5 tt6
info=0;
if nargin > 6 && initialization == 1
% Beta indices.
tt1 = 1;
@ -81,6 +84,9 @@ d2lprior = 0.0;
if tt1
logged_prior_density = logged_prior_density + sum(lpdfgbeta(x(id1),p6(id1),p7(id1),p3(id1),p4(id1))) ;
if isinf(logged_prior_density)
if nargout ==4
info=id1(isinf(lpdfgbeta(x(id1),p6(id1),p7(id1),p3(id1),p4(id1))));
end
return
end
if nargout == 2,
@ -93,6 +99,9 @@ end
if tt2
logged_prior_density = logged_prior_density + sum(lpdfgam(x(id2)-p3(id2),p6(id2),p7(id2))) ;
if isinf(logged_prior_density)
if nargout ==4
info=id2(isinf(lpdfgam(x(id2)-p3(id2),p6(id2),p7(id2))));
end
return
end
if nargout == 2,
@ -114,6 +123,9 @@ end
if tt4
logged_prior_density = logged_prior_density + sum(lpdfig1(x(id4)-p3(id4),p6(id4),p7(id4))) ;
if isinf(logged_prior_density)
if nargout ==4
info=id4(isinf(lpdfig1(x(id4)-p3(id4),p6(id4),p7(id4))));
end
return
end
if nargout == 2,
@ -126,6 +138,9 @@ end
if tt5
if any(x(id5)-p3(id5)<0) || any(x(id5)-p4(id5)>0)
logged_prior_density = -Inf ;
if nargout ==4
info=id5((x(id5)-p3(id5)<0) || (x(id5)-p4(id5)>0));
end
return
end
logged_prior_density = logged_prior_density + sum(log(1./(p4(id5)-p3(id5)))) ;
@ -140,6 +155,9 @@ end
if tt6
logged_prior_density = logged_prior_density + sum(lpdfig2(x(id6)-p3(id6),p6(id6),p7(id6))) ;
if isinf(logged_prior_density)
if nargout ==4
info=id6(isinf(lpdfig2(x(id6)-p3(id6),p6(id6),p7(id6))));
end
return
end
if nargout == 2,

View File

@ -1,8 +1,15 @@
function [Z,ST,R1,QT,Pstar,Pinf] = schur_statespace_transformation(mf,T,R,Q,qz_criterium)
% function [Z,ST,QT,R1,Pstar,Pinf] = schur_statespace(mf,T,R,Q,qz_criterium)
function [Z,ST,R1,QT,Pstar,Pinf] = schur_statespace_transformation(mf,T,R,Q,qz_criterium, restrict_columns)
% function [Z,ST,QT,R1,Pstar,Pinf] = schur_statespace_transformation(mf,T,R,Q,qz_criterium, restrict_columns)
% Kitagawa transformation of state space system with a quasi-triangular
% transition matrix with unit roots at the top. Computation of Pstar and
% Pinf for Durbin and Koopman Diffuse filter
% transition matrix with unit roots at the top, but excluding zero columns of the transition matrix.
% Computation of Pstar and Pinf for Durbin and Koopman Diffuse filter
%
% The transformed state space is
% y = [ss; z; x];
% s = static variables (zero columns of T)
% z = unit roots
% x = stable roots
% ss = s - z = stationarized static variables
%
% INPUTS
% mf [integer] vector of indices of observed variables in
@ -44,6 +51,20 @@ function [Z,ST,R1,QT,Pstar,Pinf] = schur_statespace_transformation(mf,T,R,Q,qz_c
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
np = size(T,1);
if nargin == 6,
indx = restrict_columns;
indx0=find(~ismember([1:np],indx));
else
indx=(find(max(abs(T))>0));
indx0=(find(max(abs(T))==0));
end
T0=T(indx0,indx); %static variables vs. dynamic ones
R0=R(indx0,:); % matrix of shocks for static variables
% perform Kitagawa transformation only for non-zero columns of T
T=T(indx,indx);
R=R(indx,:);
np = size(T,1);
[QT,ST] = schur(T);
e1 = abs(ordeig(ST)) > 2-qz_criterium;
@ -93,14 +114,40 @@ if i == nk+1
Pstar(nk1,nk1)=(B(nk1,nk1)+c)/(1-ST(nk1,nk1)*ST(nk1,nk1));
end
Z = QT(mf,:);
R1 = QT'*R;
ST1=ST;
% now I recover stationarized static variables
% using
% ss = s-z and
% z-z(-1) (growth rates of unit roots) only depends on stationary variables
np0=length(indx0);
Pstar = blkdiag(zeros(np0),Pstar);
ST = [zeros(length(Pstar),length(indx0)) [T0*QT ;ST]];
R1 = [R0; R1];
ST0=ST;
ST0(:,1:np0+nk)=0;
ST0(np0+1:np0+nk,:)=0;
ST0(1:np0,np0+nk+1:end) = ST(1:np0,np0+nk+1:end)-ST(1:np0,np0+1:np0+nk)*ST(np0+1:np0+nk,np0+nk+1:end);
R10 = R1;
R10(np0+1:np0+nk,:)=0;
R10(1:np0,:) = R1(1:np0,:)-ST(1:np0,np0+1:np0+nk)*R1(np0+1:np0+nk,:);
Pstar = ...
ST0*Pstar*ST0'+ ...
R10*Q*R10';
QT = blkdiag(eye(np0),QT);
QT(1:np0,np0+1:np0+nk) = QT(1:np0,np0+1:np0+nk)+ST(1:np0,np0+1:np0+nk);
% reorder QT entries
QT([indx0(:); indx(:)],:) = QT;
Z = QT(mf,:);
ST(1:np0,:) = ST0(1:np0,:);
R1(1:np0,:) = R10(1:np0,:);
% stochastic trends with no influence on observed variables are
% arbitrarily initialized to zero
Pinf = zeros(np,np);
Pinf(1:nk,1:nk) = eye(nk);
[QQ,RR,EE] = qr(Z*ST(:,1:nk),0);
[QQ,RR,EE] = qr(Z*ST(:,1+np0:nk+np0),0);
k = find(abs(diag([RR; zeros(nk-size(Z,1),size(RR,2))])) < 1e-8);
if length(k) > 0
k1 = EE(:,k);
@ -108,3 +155,5 @@ if length(k) > 0
dd(k1) = zeros(length(k1),1);
Pinf(1:nk,1:nk) = diag(dd);
end
Pinf = blkdiag(zeros(np0),Pinf);

View File

@ -155,6 +155,12 @@ end
bayestopt_.p6 = NaN(size(bayestopt_.p1)) ;
bayestopt_.p7 = bayestopt_.p6 ;
%% check for point priors and disallow them as they do not work with MCMC
if any(bayestopt_.p2 ==0)
error(sprintf(['Error in prior for %s: you cannot use a point prior in estimation. Either increase the prior standard deviation',...
' or fix the parameter completely.'], bayestopt_.name{bayestopt_.p2 ==0}))
end
% generalized location parameters by default for beta distribution
k = find(bayestopt_.pshape == 1);
k1 = find(isnan(bayestopt_.p3(k)));

View File

@ -2528,8 +2528,6 @@ void
EstimationDataStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output, "options_.dataset");
//if (options_list.date_options.find("first_obs") == options_list.date_options.end())
// output << "options_.dataset.first_obs = options_.initial_period;" << endl;
}
SubsamplesStatement::SubsamplesStatement(const string &name1_arg,
@ -3091,27 +3089,6 @@ CorrPriorStatement::writeOutput(ostream &output, const string &basename) const
writePriorOutput(output, lhs_field, name1);
}
PriorEqualStatement::PriorEqualStatement(const string &to_declaration_type_arg,
const string &to_name1_arg,
const string &to_name2_arg,
const string &to_subsample_name_arg,
const string &from_declaration_type_arg,
const string &from_name1_arg,
const string &from_name2_arg,
const string &from_subsample_name_arg,
const SymbolTable &symbol_table_arg) :
to_declaration_type(to_declaration_type_arg),
to_name1(to_name1_arg),
to_name2(to_name2_arg),
to_subsample_name(to_subsample_name_arg),
from_declaration_type(from_declaration_type_arg),
from_name1(from_name1_arg),
from_name2(from_name2_arg),
from_subsample_name(from_subsample_name_arg),
symbol_table(symbol_table_arg)
{
}
void
CorrPriorStatement::writeCOutput(ostream &output, const string &basename)
{
@ -3144,6 +3121,27 @@ CorrPriorStatement::writeCOutput(ostream &output, const string &basename)
output << endl <<" index, index1, shape, mean, mode, stdev, variance, domain));" << endl;
}
PriorEqualStatement::PriorEqualStatement(const string &to_declaration_type_arg,
const string &to_name1_arg,
const string &to_name2_arg,
const string &to_subsample_name_arg,
const string &from_declaration_type_arg,
const string &from_name1_arg,
const string &from_name2_arg,
const string &from_subsample_name_arg,
const SymbolTable &symbol_table_arg) :
to_declaration_type(to_declaration_type_arg),
to_name1(to_name1_arg),
to_name2(to_name2_arg),
to_subsample_name(to_subsample_name_arg),
from_declaration_type(from_declaration_type_arg),
from_name1(from_name1_arg),
from_name2(from_name2_arg),
from_subsample_name(from_subsample_name_arg),
symbol_table(symbol_table_arg)
{
}
void
PriorEqualStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
{

View File

@ -101,7 +101,7 @@ class ParsingDriver;
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE BOUNDS JSCALE INIT INFILE INVARS
%token <string_val> INT_NUMBER
%token INV_GAMMA_PDF INV_GAMMA1_PDF INV_GAMMA2_PDF IRF IRF_SHOCKS IRF_PLOT_THRESHOLD IRF_CALIBRATION
%token KALMAN_ALGO KALMAN_TOL SUBSAMPLES OPTIONS TOLF
%token KALMAN_ALGO KALMAN_TOL DIFFUSE_KALMAN_TOL SUBSAMPLES OPTIONS TOLF
%token LAPLACE LIK_ALGO LIK_INIT LINEAR LOAD_IDENT_FILES LOAD_MH_FILE LOAD_PARAMS_AND_STEADY_STATE LOGLINEAR LOGDATA LYAPUNOV
%token LYAPUNOV_FIXED_POINT_TOL LYAPUNOV_DOUBLING_TOL LYAPUNOV_SQUARE_ROOT_SOLVER_TOL LOG_DEFLATOR LOG_TREND_VAR LOG_GROWTH_FACTOR MARKOWITZ MARGINAL_DENSITY MAX MAXIT
%token MFS MH_CONF_SIG MH_DROP MH_INIT_SCALE MH_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER POSTERIOR_MAX_SUBSAMPLE_DRAWS MIN MINIMAL_SOLVING_PERIODS
@ -1664,6 +1664,7 @@ estimation_options : o_datafile
| o_filtered_vars
| o_kalman_algo
| o_kalman_tol
| o_diffuse_kalman_tol
| o_xls_sheet
| o_xls_range
| o_filter_step_ahead
@ -2643,6 +2644,7 @@ o_filtered_vars : FILTERED_VARS { driver.option_num("filtered_vars", "1"); };
o_relative_irf : RELATIVE_IRF { driver.option_num("relative_irf", "1"); };
o_kalman_algo : KALMAN_ALGO EQUAL INT_NUMBER { driver.option_num("kalman_algo", $3); };
o_kalman_tol : KALMAN_TOL EQUAL non_negative_number { driver.option_num("kalman_tol", $3); };
o_diffuse_kalman_tol : DIFFUSE_KALMAN_TOL EQUAL non_negative_number { driver.option_num("diffuse_kalman_tol", $3); };
o_marginal_density : MARGINAL_DENSITY EQUAL LAPLACE
{ driver.option_str("mc_marginal_density", "laplace"); }
| MARGINAL_DENSITY EQUAL MODIFIEDHARMONICMEAN

View File

@ -288,6 +288,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<DYNARE_STATEMENT>nodiagnostic {return token::NODIAGNOSTIC;}
<DYNARE_STATEMENT>kalman_algo {return token::KALMAN_ALGO;}
<DYNARE_STATEMENT>kalman_tol {return token::KALMAN_TOL;}
<DYNARE_STATEMENT>diffuse_kalman_tol {return token::DIFFUSE_KALMAN_TOL;}
<DYNARE_STATEMENT>forecast {return token::FORECAST;}
<DYNARE_STATEMENT>smoother {return token::SMOOTHER;}
<DYNARE_STATEMENT>bayesian_irf {return token::BAYESIAN_IRF;}

View File

@ -61,7 +61,7 @@ alp, beta_pdf, 0.356, 0.02;
bet, beta_pdf, 0.993, 0.002;
gam, normal_pdf, 0.0085, 0.003;
mst, normal_pdf, 1.0002, 0.007;
rho, beta_pdf, 0.129, 0.223;
rho, beta_pdf, 0.129, 0.1;
psi, beta_pdf, 0.65, 0.05;
del, beta_pdf, 0.01, 0.005;
stderr e_a, inv_gamma_pdf, 0.035449, inf;
@ -74,5 +74,7 @@ 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=5,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=5,analytic_derivation,kalman_algo=3,datafile=fsdat_simul,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8);
estimation(order=1,mode_compute=5,analytic_derivation,kalman_algo=4,datafile=fsdat_simul,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8);
estimation(order=1,mode_compute=4,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,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=5,analytic_derivation,kalman_algo=3,datafile=fsdat_simul,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8);
//estimation(order=1,mode_compute=5,analytic_derivation,kalman_algo=4,datafile=fsdat_simul,nobs=192,mh_replic=0,mh_nblocks=2,mh_jscale=0.8);