Merge branch 'master' into ecb-master

Fixed conflict in dseries submodule.
time-shift
Stéphane Adjemian (Charybdis) 2018-02-10 12:53:34 +01:00
commit 3a052f500c
42 changed files with 462 additions and 262 deletions

61
NEWS
View File

@ -1,3 +1,56 @@
Announcement for Dynare 4.5.4 (on 2018-01-29)
=============================================
We are pleased to announce the release of Dynare 4.5.4.
This is a bugfix release.
The Windows packages are already available for download at:
http://www.dynare.org/download/dynare-stable
The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon.
This release is compatible with MATLAB versions 7.5 (R2007b) to 9.3 (R2017b)
and with GNU Octave versions 4.2.
Here is a list of the problems identified in version 4.5.3 and that have been
fixed in version 4.5.4:
- The `type` option of `plot_shock_decomposition` was always set to `qoq` regardless of what is specified.
- Bug in GSA when no parameter was detected below pvalue threshold.
- Various bug fixes in shock decompositions.
- Bug in reading in macro arrays passed on `dynare` command line via the `-D` option.
- Estimation with missing values was crashing if the `prefilter` option was used.
- Added a workaround for a difference in behaviour between Octave and Matlab regarding the creation
of function handles for functions that do not exist in the path. With Octave 4.2.1, steady state
files did not work if no auxiliary variables were created.
- The `stoch_simul` command was crashing with a cryptic message if option `order=3` was used without
setting `k_order_solver`.
- In cases where the prior bounds are infinite and the mode is estimated at exactly 0, no `mode_check`
graphs were displayed.
- Parallel execution of MCMC was broken in models without auxiliary variables.
- Reading data with column names from Excel might crash.
- The multivariate Kalman smoother was crashing in case of missing data in the observations and
`Finf` became singular.
- The `plot_shock_decomposition` command ignored various user-defined options like `fig_name`,
`use_shock_groups` or `interactive` and instead used the default options.
- Nested `@#ifdef` and `@#ifndef` statements don't work in the macroprocessor.
Announcement for Dynare 4.5.3 (on 2017-10-19) Announcement for Dynare 4.5.3 (on 2017-10-19)
============================================= =============================================
@ -12,7 +65,7 @@ The Windows packages are already available for download at:
The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon. The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon.
This release is compatible with MATLAB versions 7.3 (R2006b) to 9.3 (R2017b) This release is compatible with MATLAB versions 7.5 (R2007b) to 9.3 (R2017b)
and with GNU Octave versions 4.2. and with GNU Octave versions 4.2.
Here is a list of the problems identified in version 4.5.2 and that have been Here is a list of the problems identified in version 4.5.2 and that have been
@ -37,7 +90,7 @@ The Windows packages are already available for download at:
The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon. The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon.
This release is compatible with MATLAB versions 7.3 (R2006b) to 9.3 (R2017b) This release is compatible with MATLAB versions 7.5 (R2007b) to 9.3 (R2017b)
and with GNU Octave versions 4.2. and with GNU Octave versions 4.2.
Here is a list of the problems identified in version 4.5.1 and that have been Here is a list of the problems identified in version 4.5.1 and that have been
@ -116,7 +169,7 @@ The Windows packages are already available for download at:
The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon. The Mac and GNU/Linux packages (for Debian and Ubuntu LTS) should follow soon.
This release is compatible with MATLAB versions 7.3 (R2006b) to 9.2 (R2017a) This release is compatible with MATLAB versions 7.5 (R2007b) to 9.2 (R2017a)
and with GNU Octave versions 4.2. and with GNU Octave versions 4.2.
Here is a list of the problems identified in version 4.5.0 and that have been Here is a list of the problems identified in version 4.5.0 and that have been
@ -162,7 +215,7 @@ The Mac and Debian/Ubuntu packages should follow soon.
All users are strongly encouraged to upgrade. All users are strongly encouraged to upgrade.
This release is compatible with MATLAB versions ranging from 7.3 (R2006b) to This release is compatible with MATLAB versions ranging from 7.5 (R2007b) to
9.2 (R2017a) and with GNU Octave version 4.2. 9.2 (R2017a) and with GNU Octave version 4.2.
Here is the list of major user-visible changes: Here is the list of major user-visible changes:

View File

@ -7602,9 +7602,9 @@ model).
(@xref{plot_shock_decomposition}). (@xref{plot_shock_decomposition}).
@item presample = @var{INTEGER} @item presample = @var{INTEGER}
@anchor{presample_shock_decomposition} First data point from which recursive @anchor{presample_shock_decomposition} Data point above which recursive
realtime shock decompositions are computed, @i{i.e.} for realtime shock decompositions are computed, @i{i.e.} for
@math{T=[@code{presample}@dots{}@code{nobs}]}. @math{T=[@code{presample+1}@dots{}@code{nobs}]}.
@item forecast = @var{INTEGER} @item forecast = @var{INTEGER}
@anchor{forecast_shock_decomposition} Compute shock decompositions up to @anchor{forecast_shock_decomposition} Compute shock decompositions up to
@ -7613,6 +7613,13 @@ realtime shock decompositions are computed, @i{i.e.} for
@item save_realtime = @var{INTEGER_VECTOR} @item save_realtime = @var{INTEGER_VECTOR}
@anchor{save_realtime} Choose for which vintages to save the full realtime @anchor{save_realtime} Choose for which vintages to save the full realtime
shock decomposition. Default: @math{0}. shock decomposition. Default: @math{0}.
@item fast_realtime = @var{INTEGER}
@anchor{fast_realtime} Runs the smoother only twice: once for the last in-sample
and once for the last out-of-sample data point, where the provided integer defines the last observation
(equivalent to @ref{nobs}).
Default: not enabled.
@end table @end table
@outputhead @outputhead

View File

@ -58,7 +58,7 @@ function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK,T,R,P,PK,de
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% None % None
% Copyright (C) 2006-2017 Dynare Team % Copyright (C) 2006-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -183,7 +183,7 @@ elseif options_.lik_init == 3 % Diffuse Kalman filter
Z = [Z, eye(vobs)]; Z = [Z, eye(vobs)];
end end
end end
[Pstar,Pinf] = compute_Pinf_Pstar(mf,T,R,Q,options_.qz_criterium,oo_.dr.restrict_var_list); [Pstar,Pinf] = compute_Pinf_Pstar(mf,T,R,Q,options_.qz_criterium);
elseif options_.lik_init == 4 % Start from the solution of the Riccati equation. elseif options_.lik_init == 4 % Start from the solution of the Riccati equation.
[err, Pstar] = kalman_steady_state(transpose(T),R*Q*transpose(R),transpose(build_selection_matrix(mf,np,vobs)),H); [err, Pstar] = kalman_steady_state(transpose(T),R*Q*transpose(R),transpose(build_selection_matrix(mf,np,vobs)),H);
mexErrCheck('kalman_steady_state',err); mexErrCheck('kalman_steady_state',err);

View File

@ -31,8 +31,7 @@ function varlist = check_list_of_variables(options_, M_, varlist)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
%get uniques % Get uniques
[junk1, junk2, index_uniques] = varlist_indices(varlist, M_.endo_names); [junk1, junk2, index_uniques] = varlist_indices(varlist, M_.endo_names);
varlist = varlist(index_uniques); varlist = varlist(index_uniques);
@ -130,7 +129,7 @@ elseif isempty(varlist) && isempty(options_.endo_vars_for_moment_computations_in
elseif choice==2 elseif choice==2
varlist = options_.varobs; varlist = options_.varobs;
elseif choice==3 elseif choice==3
varlist = NaN; varlist = cell(0);
else else
skipline() skipline()
disp('YOU HAVE TO ANSWER 1, 2 or 3!') disp('YOU HAVE TO ANSWER 1, 2 or 3!')
@ -138,7 +137,7 @@ elseif isempty(varlist) && isempty(options_.endo_vars_for_moment_computations_in
end end
end end
end end
if isnan(varlist) if isempty(varlist)
edit([M_.fname '.mod']) edit([M_.fname '.mod'])
end end
skipline() skipline()

View File

@ -30,7 +30,7 @@ function [Pstar,Pinf] = compute_Pinf_Pstar(mf,T,R,Q,qz_criterium, restrict_colum
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% None % None
% Copyright (C) 2006-2017 Dynare Team % Copyright (C) 2006-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -48,8 +48,22 @@ function [Pstar,Pinf] = compute_Pinf_Pstar(mf,T,R,Q,qz_criterium, restrict_colum
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
np = size(T,1); np = size(T,1);
if nargin == 6
indx = restrict_columns;
indx0=find(~ismember([1:np],indx));
else
indx=(find(max(abs(T))>=1.e-10));
indx0=(find(max(abs(T))<1.e-10));
end
np0=length(indx0);
Tbkp = T;
T0=T(indx0,indx); % static variables vs. dynamic ones
R0=R(indx0,:); % matrix of shocks for static variables
% perform Kitagawa transformation % 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); [QT,ST] = schur(T);
e1 = abs(ordeig(ST)) > 2-qz_criterium; e1 = abs(ordeig(ST)) > 2-qz_criterium;
[QT,ST] = ordschur(QT,ST,e1); [QT,ST] = ordschur(QT,ST,e1);
@ -59,7 +73,6 @@ nk1 = nk+1;
Pstar = zeros(np,np); Pstar = zeros(np,np);
R1 = QT'*R; R1 = QT'*R;
B = R1*Q*R1'; B = R1*Q*R1';
% computes variance of stationary block (lower right)
i = np; i = np;
while i >= nk+2 while i >= nk+2
if ST(i,i-1) == 0 if ST(i,i-1) == 0
@ -100,13 +113,64 @@ if i == nk+1
Pstar(nk1,nk1)=(B(nk1,nk1)+c)/(1-ST(nk1,nk1)*ST(nk1,nk1)); Pstar(nk1,nk1)=(B(nk1,nk1)+c)/(1-ST(nk1,nk1)*ST(nk1,nk1));
end end
if np0
ST1=ST;
% Now I recover stationarized static variables using
% ss = s-A*z
% and
% z-z(-1) (growth rates of unit roots) only depends on stationary variables
Pstar = blkdiag(zeros(np0),Pstar);
ST = [zeros(length(Pstar),length(indx0)) [T0*QT ;ST]];
R1 = [R0; R1];
% Build the matrix for stationarized variables
STinf = ST(np0+1:np0+nk,np0+1:np0+nk);
iSTinf = inv(STinf);
ST0=ST;
ST0(:,1:np0+nk)=0; % stationarized static + 1st difference only respond to lagged stationary states
ST00 = ST(1:np0,np0+1:np0+nk);
% A\B is the matrix division of A into B, which is roughly the
% same as INV(A)*B
ST0(1:np0,np0+nk+1:end) = ST(1:np0,np0+nk+1:end)-ST00*(iSTinf*ST(np0+1:np0+nk,np0+nk+1:end)); % snip non-stationary part
R10 = R1;
R10(1:np0,:) = R1(1:np0,:)-ST00*(iSTinf*R1(np0+1:np0+nk,:)); % snip non-stationary part
% Kill non-stationary part before projecting Pstar
ST0(np0+1:np0+nk,:)=0;
R10(np0+1:np0+nk,:)=0; % is this questionable???? IT HAS TO in order to match Michel's version!!!
% project Pstar onto static x
Pstar = ST0*Pstar*ST0'+R10*Q*R10';
% QT(1:np0,np0+1:np0+nk) = QT(1:np0,np0+1:np0+nk)+ST(1:np0,np0+1:np0+nk); %%% is this questionable ????
% reorder QT entries
else
STinf = ST(np0+1:np0+nk,np0+1:np0+nk);
end
% stochastic trends with no influence on observed variables are % stochastic trends with no influence on observed variables are
% arbitrarily initialized to zero % arbitrarily initialized to zero
Pinf = zeros(np,np); Pinf = zeros(np,np);
Pinf(1:nk,1:nk) = eye(nk); Pinf(1:nk,1:nk) = eye(nk);
for k = 1:nk if np0
if norm(QT(mf,:)*ST(:,k)) < 1e-8 STtriu = STinf-eye(nk);
Pinf(k,k) = 0; % A\B is the matrix division of A into B, which is roughly the
% same as INV(A)*B
STinf0 = ST00*(eye(nk)-iSTinf*STtriu);
Pinf = blkdiag(zeros(np0),Pinf);
QT = blkdiag(eye(np0),QT);
QTinf = QT;
QTinf(1:np0,np0+1:np0+nk) = STinf0;
QTinf([indx0(:); indx(:)],:) = QTinf;
STinf1 = [zeros(np0+np,np0) [STinf0; eye(nk); zeros(np-nk,nk)] zeros(np0+np,np-nk)];
for k = 1:nk
if norm(QTinf(mf,:)*ST([indx0(:); indx(:)],k+np0)) < 1e-8
Pinf(k+np0,k+np0) = 0;
end
end
Pinf = STinf1*Pinf*STinf1';
QT([indx0(:); indx(:)],:) = QT;
else
for k = 1:nk
if norm(QT(mf,:)*ST(:,k)) < 1e-8
Pinf(k+np0,k+np0) = 0;
end
end end
end end

View File

@ -48,7 +48,7 @@ function [H,G,retcode]=discretionary_policy_engine(AAlag,AA0,AAlead,BB,bigw,inst
% Dennis, Richard (2007): Optimal policy in rational expectations models: new solution algorithms, % Dennis, Richard (2007): Optimal policy in rational expectations models: new solution algorithms,
% Macroeconomic Dynamics, 11, 31–55. % Macroeconomic Dynamics, 11, 31–55.
% Copyright (C) 2007-2017 Dynare Team % Copyright (C) 2007-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -112,9 +112,9 @@ F1=F10;
while 1 while 1
iter=iter+1; iter=iter+1;
P=SylvesterDoubling(W+beta*F1'*Q*F1,beta*H1',H1,discretion_tol,solve_maxit); P=SylvesterDoubling(W+beta*F1'*Q*F1,beta*H1',H1,discretion_tol,solve_maxit);
if any(any(isnan(P))) if any(any(isnan(P))) || any(any(isinf(P)))
P=SylvesterHessenbergSchur(W+beta*F1'*Q*F1,beta*H1',H1); P=SylvesterHessenbergSchur(W+beta*F1'*Q*F1,beta*H1',H1);
if any(any(isnan(P))) if any(any(isnan(P))) || any(any(isinf(P)))
retcode=2; retcode=2;
return return
end end

View File

@ -32,9 +32,9 @@ function disp_steady_state(M,oo)
skipline() skipline()
disp('STEADY-STATE RESULTS:') disp('STEADY-STATE RESULTS:')
skipline() skipline()
endo_names = M.endo_names; endo_names = char(M.endo_names);
steady_state = oo.steady_state; steady_state = oo.steady_state;
for i = 1:M.orig_endo_nbr for i = 1:M.orig_endo_nbr
disp(sprintf('%s \t\t %g', endo_names{i}, steady_state(i))); fprintf('%s \t\t %g\n', endo_names(i,:), steady_state(i));
end end

View File

@ -115,7 +115,7 @@ function [fval,info,exit_flag,DLIK,Hess,SteadyState,trend_coeff,Model,DynareOpti
%! @end deftypefn %! @end deftypefn
%@eod: %@eod:
% Copyright (C) 2004-2017 Dynare Team % Copyright (C) 2004-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -372,7 +372,7 @@ switch DynareOptions.lik_init
error(['The model requires Diffuse filter, but you specified a different Kalman filter. You must set options_.kalman_algo ' ... error(['The model requires Diffuse filter, but you specified a different Kalman filter. You must set options_.kalman_algo ' ...
'to 0 (default), 3 or 4']) 'to 0 (default), 3 or 4'])
end end
[Pstar,Pinf] = compute_Pinf_Pstar(Z,T,R,Q,DynareOptions.qz_criterium,[1:length(T)]); [Pstar,Pinf] = compute_Pinf_Pstar(Z,T,R,Q,DynareOptions.qz_criterium);
Z =zeros(length(BayesInfo.mf),size(T,1)); Z =zeros(length(BayesInfo.mf),size(T,1));
for i = 1:length(BayesInfo.mf) for i = 1:length(BayesInfo.mf)
Z(i,BayesInfo.mf(i))=1; Z(i,BayesInfo.mf(i))=1;

View File

@ -422,6 +422,7 @@ end
if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ... if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ...
(any(bayestopt_.pshape >0 ) && options_.load_mh_file) %% not ML estimation (any(bayestopt_.pshape >0 ) && options_.load_mh_file) %% not ML estimation
bounds = prior_bounds(bayestopt_, options_.prior_trunc); %reset bounds as lb and ub must only be operational during mode-finding
outside_bound_pars=find(xparam1 < bounds.lb | xparam1 > bounds.ub); outside_bound_pars=find(xparam1 < bounds.lb | xparam1 > bounds.ub);
if ~isempty(outside_bound_pars) if ~isempty(outside_bound_pars)
for ii=1:length(outside_bound_pars) for ii=1:length(outside_bound_pars)

View File

@ -70,7 +70,14 @@ else
updated_params_flag = 0; updated_params_flag = 0;
end end
h_set_auxiliary_variables = str2func([M.fname '_set_auxiliary_variables']); if M.set_auxiliary_variables
% Define function handle for the function setting the auxiliary
% variables only if the model has auxiliary variables. Otherwise
% Octave may crash (see https://savannah.gnu.org/bugs/?52568) because
% the function does not exist in the path.
h_set_auxiliary_variables = str2func([M.fname '_set_auxiliary_variables']);
end
if isnan(updated_params_flag) || (updated_params_flag && any(isnan(params(~isnan(params))-params1(~isnan(params))))) %checks if new NaNs were added if isnan(updated_params_flag) || (updated_params_flag && any(isnan(params(~isnan(params))-params1(~isnan(params))))) %checks if new NaNs were added
info(1) = 24; info(1) = 24;
info(2) = NaN; info(2) = NaN;

View File

@ -34,16 +34,19 @@ mydata=get(findobj(gcf,'tag',['group' int2str(ic)]),'userdata');
if isfield(mydata,'shock_decomp') if isfield(mydata,'shock_decomp')
options.shock_decomp=mydata.shock_decomp; options.shock_decomp=mydata.shock_decomp;
end end
options.plot_shock_decomp=mydata.plot_shock_decomp;
options.first_obs=mydata.first_obs;
options.nobs=mydata.nobs;
% define expanded group % define expanded group
label = mydata.shock_group.label; label = mydata.shock_group.label;
shocks = mydata.shock_group.shocks; shocks = mydata.shock_group.shocks;
options.shock_decomp.fig_name = [mydata.fig_name '. Expand']; options.plot_shock_decomp.fig_name = [mydata.fig_name '. Expand'];
options.use_shock_groups = strrep(label,' ','_'); %[use_shock_groups_old int2str(ic)]; options.plot_shock_decomp.use_shock_groups = strrep(label,' ','_'); %[use_shock_groups_old int2str(ic)];
for j=1:length(shocks) for j=1:length(shocks)
M.shock_groups.(options.use_shock_groups).(['group' int2str(j)]).label=shocks{j}; M.shock_groups.(options.plot_shock_decomp.use_shock_groups).(['group' int2str(j)]).label=shocks{j};
M.shock_groups.(options.use_shock_groups).(['group' int2str(j)]).shocks=shocks(j); M.shock_groups.(options.plot_shock_decomp.use_shock_groups).(['group' int2str(j)]).shocks=shocks(j);
end end
options.shock_decomp.interactive=0; options.plot_shock_decomp.interactive=0;
options.shock_decomp.expand=1; options.plot_shock_decomp.expand=1;
plot_shock_decomposition(M,oo,options,var_list_); plot_shock_decomposition(M,oo,options,var_list_);

View File

@ -193,12 +193,15 @@ for j=1:nvar
mydata.fig_name = DynareOptions.plot_shock_decomp.fig_name(2:end); mydata.fig_name = DynareOptions.plot_shock_decomp.fig_name(2:end);
mydata.use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups; mydata.use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups;
mydata.shock_group = shock_groups.(shock_ind{i}); mydata.shock_group = shock_groups.(shock_ind{i});
mydata.shock_decomp = DynareOptions.plot_shock_decomp; mydata.shock_decomp = DynareOptions.shock_decomp;
if ~isempty(mydata.shock_group.shocks{1}) mydata.plot_shock_decomp = DynareOptions.plot_shock_decomp;
mydata.first_obs = DynareOptions.first_obs;
mydata.nobs = DynareOptions.nobs;
if ~isempty(mydata.shock_group.shocks)
c = uicontextmenu; c = uicontextmenu;
hl.UIContextMenu=c; hl.UIContextMenu=c;
browse_menu = uimenu(c,'Label','Browse group'); browse_menu = uimenu(c,'Label','Browse group');
expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.use_shock_groups ''',''' deblank(mydata.shock_decomp.orig_varlist(j,:)) ''',' int2str(i) ')']); expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.plot_shock_decomp.use_shock_groups ''',''' deblank(mydata.plot_shock_decomp.orig_varlist{j}) ''',' int2str(i) ')']);
set(expand_menu,'UserData',mydata,'Tag',['group' int2str(i)]); set(expand_menu,'UserData',mydata,'Tag',['group' int2str(i)]);
for jmember = mydata.shock_group.shocks for jmember = mydata.shock_group.shocks
uimenu('parent',browse_menu,'Label',char(jmember)) uimenu('parent',browse_menu,'Label',char(jmember))

View File

@ -195,12 +195,15 @@ for j=1:nvar
mydata.fig_name = DynareOptions.plot_shock_decomp.fig_name(2:end); mydata.fig_name = DynareOptions.plot_shock_decomp.fig_name(2:end);
mydata.use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups; mydata.use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups;
mydata.shock_group = shock_groups.(shock_ind{ic}); mydata.shock_group = shock_groups.(shock_ind{ic});
mydata.shock_decomp = DynareOptions.plot_shock_decomp; mydata.shock_decomp = DynareOptions.shock_decomp;
mydata.plot_shock_decomp = DynareOptions.plot_shock_decomp;
mydata.first_obs = DynareOptions.first_obs;
mydata.nobs = DynareOptions.nobs;
if ~isempty(mydata.shock_group.shocks) if ~isempty(mydata.shock_group.shocks)
c = uicontextmenu; c = uicontextmenu;
hax.UIContextMenu=c; hax.UIContextMenu=c;
browse_menu = uimenu(c,'Label','Browse group'); browse_menu = uimenu(c,'Label','Browse group');
expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.use_shock_groups ''',''' deblank(mydata.shock_decomp.orig_varlist(j,:)) ''',' int2str(ic) ')']); expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.plot_shock_decomp.use_shock_groups ''',''' deblank(mydata.plot_shock_decomp.orig_varlist{j}) ''',' int2str(ic) ')']);
set(expand_menu,'UserData',mydata,'Tag',['group' int2str(ic)]); set(expand_menu,'UserData',mydata,'Tag',['group' int2str(ic)]);
for jmember = mydata.shock_group.shocks for jmember = mydata.shock_group.shocks
uimenu('parent',browse_menu,'Label',char(jmember)) uimenu('parent',browse_menu,'Label',char(jmember))

View File

@ -232,10 +232,27 @@ for j = 1:length(anamendo)
istable=[1:length(iy)]; istable=[1:length(iy)];
save([xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namexo '_threshold' ],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc') save([xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namexo '_threshold' ],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc')
lpmat=[]; lpmat0=[]; istable=[]; lpmat=[]; lpmat0=[]; istable=[];
if length(iy)<=10 || length(iyc)<=10
icheck = []; % do the generic plot in any case
end
else else
icheck=[]; icheck=[];
end end
if isempty(icheck) if isempty(icheck)
if length(iy)<=10
if isempty(iy)
disp(['There are NO MC samples in the desired range [' num2str(threshold) ']!'])
else
disp(['There are TOO FEW (<=10) MC samples in the desired range [' num2str(threshold) ']!'])
end
elseif length(iyc)<=10
if isempty(iyc)
disp(['ALL MC samples are in the desired range [' num2str(threshold) ']!'])
else
disp(['Almost ALL MC samples are in the desired range [' num2str(threshold) ']!'])
disp('There are TOO FEW (<=10) MC samples OUTSIDE the desired range!')
end
end
atitle0=['Monte Carlo Filtering for ',namendo,' vs ', namexo]; atitle0=['Monte Carlo Filtering for ',namendo,' vs ', namexo];
options_mcf.title = atitle0; options_mcf.title = atitle0;
indmcf = redform_mcf(y0, x0, options_mcf, options_); indmcf = redform_mcf(y0, x0, options_mcf, options_);
@ -280,6 +297,8 @@ for j = 1:length(anamendo)
end end
end end
else
disp(['This entry in the shock matrix is CONSTANT = ' num2str(mean(y0),3)])
end end
end end
end end
@ -369,11 +388,28 @@ for j = 1:length(anamendo)
istable=[1:length(iy)]; istable=[1:length(iy)];
save([xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namlagendo '_threshold' ],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc') save([xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namlagendo '_threshold' ],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc')
lpmat=[]; lpmat0=[]; istable=[]; lpmat=[]; lpmat0=[]; istable=[];
if length(iy)<=10 || length(iyc)<=10,
icheck = []; % do the generic plot in any case
end
else else
icheck = []; icheck = [];
end end
if isempty(icheck) if isempty(icheck)
if length(iy)<=10
if isempty(iy)
disp(['There are NO MC samples in the desired range [' num2str(threshold) ']!'])
else
disp(['There are TOO FEW (<=10) MC samples in the desired range [' num2str(threshold) ']!'])
end
elseif length(iyc)<=10
if isempty(iyc)
disp(['ALL MC samples are in the desired range [' num2str(threshold) ']!'])
else
disp(['Almost ALL MC samples are in the desired range [' num2str(threshold) ']!'])
disp('There are TOO FEW (<=10) MC samples OUTSIDE the desired range!')
end
end
atitle0=['Monte Carlo Filtering for ',namendo,' vs ', namlagendo]; atitle0=['Monte Carlo Filtering for ',namendo,' vs ', namlagendo];
options_mcf.title = atitle0; options_mcf.title = atitle0;
indmcf = redform_mcf(y0, x0, options_mcf, options_); indmcf = redform_mcf(y0, x0, options_mcf, options_);
@ -417,6 +453,8 @@ for j = 1:length(anamendo)
end end
end end
else
disp(['This entry in the transition matrix is CONSTANT = ' num2str(mean(y0),3)])
end end
end end
end end
@ -736,6 +774,11 @@ for jt=1:10
end end
[proba, dproba] = stab_map_1(x0, indy{1}, indy{end}, [],0); [proba, dproba] = stab_map_1(x0, indy{1}, indy{end}, [],0);
indmcf=find(proba<options_mcf.pvalue_ks); indmcf=find(proba<options_mcf.pvalue_ks);
if isempty(indmcf)
[tmp,jtmp] = sort(proba,2,'ascend');
indmcf = jtmp(1);
% indmcf = jtmp(1:min(2,length(proba)));
end
[tmp,jtmp] = sort(proba(indmcf),2,'ascend'); [tmp,jtmp] = sort(proba(indmcf),2,'ascend');
indmcf = indmcf(jtmp); indmcf = indmcf(jtmp);
nbr_par = length(indmcf); nbr_par = length(indmcf);

View File

@ -28,7 +28,7 @@ function [ide_hess, ide_moments, ide_model, ide_lre, derivatives_info, info, opt
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% None % None
% Copyright (C) 2008-2017 Dynare Team % Copyright (C) 2008-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -152,10 +152,10 @@ if info(1)==0
end end
analytic_derivation = options_.analytic_derivation; analytic_derivation = options_.analytic_derivation;
options_.analytic_derivation = -2; options_.analytic_derivation = -2;
info = stoch_simul(char(options_.varobs)); info = stoch_simul(options_.varobs);
dataset_ = dseries(oo_.endo_simul(options_.varobs_id,100+1:end)',dates('1Q1'), options_.varobs); dataset_ = dseries(oo_.endo_simul(options_.varobs_id,100+1:end)',dates('1Q1'), options_.varobs);
derivatives_info.no_DLIK=1; derivatives_info.no_DLIK=1;
%bounds = prior_bounds(bayestopt_, options_.prior_trunc); bounds = prior_bounds(bayestopt_, options_.prior_trunc); %reset bounds as lb and ub must only be operational during mode-finding
[fval,info,cost_flag,DLIK,AHess,ys,trend_coeff,M_,options_,bayestopt_,oo_] = dsge_likelihood(params',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_,derivatives_info); [fval,info,cost_flag,DLIK,AHess,ys,trend_coeff,M_,options_,bayestopt_,oo_] = dsge_likelihood(params',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_,derivatives_info);
% fval = DsgeLikelihood(xparam1,data_info,options_,M_,estim_params_,bayestopt_,oo_); % fval = DsgeLikelihood(xparam1,data_info,options_,M_,estim_params_,bayestopt_,oo_);
options_.analytic_derivation = analytic_derivation; options_.analytic_derivation = analytic_derivation;

View File

@ -128,6 +128,11 @@ M_.exo_nbr = M_.endo_nbr;
options_.plot_shock_decomp.realtime=0; options_.plot_shock_decomp.realtime=0;
options_.plot_shock_decomp.screen_shocks=1; options_.plot_shock_decomp.screen_shocks=1;
options_.plot_shock_decomp.use_shock_groups = ''; options_.plot_shock_decomp.use_shock_groups = '';
options_.plot_shock_decomp.fig_names='initval'; fig_name = options_.plot_shock_decomp.fig_name;
plot_shock_decomposition(M_, oo, options_, varlist); if ~isempty(fig_name)
options_.plot_shock_decomp.fig_name=[fig_name '_initval'];
else
options_.plot_shock_decomp.fig_name='initval';
end
plot_shock_decomposition(M_,oo,options_,varlist);
% end % end

View File

@ -36,7 +36,7 @@ function [dLIK,dlik,a,Pstar] = kalman_filter_d(Y, start, last, a, Pinf, Pstar, k
% Durbin/Koopman (2012): "Time Series Analysis by State Space Methods", Oxford University Press, % Durbin/Koopman (2012): "Time Series Analysis by State Space Methods", Oxford University Press,
% Second Edition, Ch. 5 and 7.2 % Second Edition, Ch. 5 and 7.2
% Copyright (C) 2004-2017 Dynare Team % Copyright (C) 2004-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -65,7 +65,7 @@ dLIK = Inf; % Default value of the log likelihood.
oldK = Inf; oldK = Inf;
s = 0; s = 0;
while rank(Pinf,diffuse_kalman_tol) && (t<=last) while rank(Z*Pinf*Z',diffuse_kalman_tol) && (t<=last)
s = t-start+1; s = t-start+1;
v = Y(:,t)-Z*a; %get prediction error v^(0) in (5.13) DK (2012) v = Y(:,t)-Z*a; %get prediction error v^(0) in (5.13) DK (2012)
Finf = Z*Pinf*Z'; % (5.7) in DK (2012) Finf = Z*Pinf*Z'; % (5.7) in DK (2012)

View File

@ -87,7 +87,7 @@ function [dLIK, dlikk, a, Pstar, llik] = univariate_kalman_filter_d(data_index,
% Series Analysis by State Space Methods", Oxford University Press, % Series Analysis by State Space Methods", Oxford University Press,
% Second Edition, Ch. 5, 6.4 + 7.2.5 % Second Edition, Ch. 5, 6.4 + 7.2.5
% Copyright (C) 2004-2017 Dynare Team % Copyright (C) 2004-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -154,7 +154,7 @@ while newRank && (t<=last)
end end
end end
if newRank if newRank
oldRank = rank(Pinf,diffuse_kalman_tol); oldRank = rank(Z*Pinf*Z',diffuse_kalman_tol);
else else
oldRank = 0; oldRank = 0;
end end
@ -162,10 +162,11 @@ while newRank && (t<=last)
Pstar = T*Pstar*T'+QQ; Pstar = T*Pstar*T'+QQ;
Pinf = T*Pinf*T'; Pinf = T*Pinf*T';
if newRank if newRank
newRank = rank(Pinf,diffuse_kalman_tol); newRank = rank(Z*Pinf*Z',diffuse_kalman_tol);
end end
if oldRank ~= newRank if oldRank ~= newRank
disp('univariate_diffuse_kalman_filter:: T does influence the rank of Pinf!') disp('univariate_diffuse_kalman_filter:: T does influence the rank of Pinf!')
disp('This may happen for models with order of integration >1.')
end end
t = t+1; t = t+1;
end end

View File

@ -1,36 +1,20 @@
function y = nanmean(x) function y = nanmean(x, dim)
% Computes the mean of each column of a matrix with some NaNs.
%@info: % Returns the mean of a matrix with some NaNs.
%! @deftypefn {Function File} {@var{y} =} nanmean (@var{x}) %
%! @anchor{nanmean} % INPUTS
%! @sp 1 % - x [double] m*n matrix
%! Computes the mean of each column of a matrix with some NaNs. % - dim [integer] scalar, dimension along which the mean has to be computed.
%! @sp 2 %
%! @strong{Inputs} % OUTPUTS
%! @table @ @var % - y [double] 1*n vector (if dim=1) or m*1 vector (if dim=2).
%! @item x %
%! Matlab matrix (T-by-N). % REMARKS
%! @end table % (1) Default value for dim is the first non singleton dimension.
%! @sp 2 % (2) Works with vector and matrices, not implemented for arrays with more
%! @strong{Outputs} % than two dimensions.
%! @table @ @var
%! @item y
%! Matlab vector (1-by-N), the mean.
%! @end table
%! @sp 2
%! @strong{This function is called by:}
%! @sp 1
%! @ref{compute_cova}, @ref{compute_acov}, @ref{compute_std}, @ref{nandemean}
%! @sp 2
%! @strong{This function calls:}
%! @sp 1
%! @ref{ndim}
%!
%! @end deftypefn
%@eod:
% Copyright (C) 2011 Dynare Team % Copyright (C) 2011-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -47,16 +31,39 @@ function y = nanmean(x)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT fr if nargin<2
% By default dim is the first non singleton dimension
nonsingletondims = find(find(size(x)>1));
if ~isempty(nonsingletondims)
dim = nonsingletondims(1);
else
dim = NaN;
end
end
switch ndim(x) switch ndims(x)
case 1 case 1
y = mean(x(find(~isnan(x)))); if isnan(dim)
y = x;
else
y = mean(x(find(~isnan(x))), dim);
end
case 2 case 2
y = NaN(1,size(x,2)); if isnan(dim)
for i = 1:size(x,2) y = x;
y(i) = mean(x(find(~isnan(x(:,i))),i)); else
if isequal(dim, 1)
y = NaN(1, size(x, 2));
for i = 1:size(x, 2)
y(i) = mean(x(find(~isnan(x(:,i))),i));
end
else
y = NaN(size(x, 1), 1);
for i = 1:size(x, 1)
y(i) = mean(x(i, find(~isnan(x(i,:)))));
end
end
end end
otherwise otherwise
error('descriptive_statistics::nanmean:: This function is not implemented for arrays with dimension greater than two!') error('This function is not implemented for arrays with dimension greater than two!')
end end

View File

@ -49,7 +49,7 @@ function [alphahat,epsilonhat,etahat,atilde,P,aK,PK,decomp,V] = missing_DiffuseK
% Durbin/Koopman (2012): "Time Series Analysis by State Space Methods", Oxford University Press, % Durbin/Koopman (2012): "Time Series Analysis by State Space Methods", Oxford University Press,
% Second Edition, Ch. 5 % Second Edition, Ch. 5
% Copyright (C) 2004-2017 Dynare Team % Copyright (C) 2004-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -134,9 +134,9 @@ while rank(Pinf(:,:,t+1),diffuse_kalman_tol) && t<smpl
return return
else %rank of F_{\infty,t} is 0 else %rank of F_{\infty,t} is 0
Finf_singular(1,t) = 1; Finf_singular(1,t) = 1;
Fstar(:,:,t) = ZZ*Pstar(:,:,t)*ZZ' + H(di,di); % (5.7) in DK (2012) Fstar(di,di,t) = ZZ*Pstar(:,:,t)*ZZ' + H(di,di); % (5.7) in DK (2012)
if rcond(Fstar(:,:,t)) < kalman_tol %F_{*} is singular if rcond(Fstar(di,di,t)) < kalman_tol %F_{*} is singular
if ~all(abs(Fstar(:,:,t))<kalman_tol) if ~all(all(abs(Fstar(di,di,t))<kalman_tol))
% The univariate diffuse kalman filter should be used. % The univariate diffuse kalman filter should be used.
alphahat = Inf; alphahat = Inf;
return return
@ -146,12 +146,12 @@ while rank(Pinf(:,:,t+1),diffuse_kalman_tol) && t<smpl
Pinf(:,:,t+1) = T*Pinf(:,:,t)*transpose(T); Pinf(:,:,t+1) = T*Pinf(:,:,t)*transpose(T);
end end
else else
iFstar(:,:,t) = inv(Fstar(:,:,t)); iFstar(di,di,t) = inv(Fstar(di,di,t));
Kstar(:,:,t) = Pstar(:,:,t)*ZZ'*iFstar(:,:,t); %(5.15) of DK (2012) with Kstar=T^{-1}*K^(0) Kstar(:,di,t) = Pstar(:,:,t)*ZZ'*iFstar(di,di,t); %(5.15) of DK (2012) with Kstar=T^{-1}*K^(0)
Pinf(:,:,t+1) = T*Pinf(:,:,t)*transpose(T); % DK (2012), 5.16 Pinf(:,:,t+1) = T*Pinf(:,:,t)*transpose(T); % DK (2012), 5.16
Lstar(:,:,t) = T - T*Kstar(:,di,t)*ZZ; %L^(0) in DK (2012), eq. 5.12 Lstar(:,:,t) = T - T*Kstar(:,di,t)*ZZ; %L^(0) in DK (2012), eq. 5.12
Pstar(:,:,t+1) = T*Pstar(:,:,t)*Lstar(:,:,t)'+QQ; % (5.17) DK (2012) Pstar(:,:,t+1) = T*Pstar(:,:,t)*Lstar(:,:,t)'+QQ; % (5.17) DK (2012)
a(:,t+1) = T*(a(:,t)+Kstar(:,:,t)*v(:,t)); % (5.13) DK (2012) a(:,t+1) = T*(a(:,t)+Kstar(:,di,t)*v(di,t)); % (5.13) DK (2012)
end end
end end
else else

View File

@ -56,7 +56,7 @@ function [alphahat,epsilonhat,etahat,a,P,aK,PK,decomp,V] = missing_DiffuseKalman
% Models", S.J. Koopman and J. Durbin (2003), in Journal of Time Series % Models", S.J. Koopman and J. Durbin (2003), in Journal of Time Series
% Analysis, vol. 24(1), pp. 85-98. % Analysis, vol. 24(1), pp. 85-98.
% Copyright (C) 2004-2017 Dynare Team % Copyright (C) 2004-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -184,6 +184,7 @@ while newRank && t < smpl
end end
if oldRank ~= newRank if oldRank ~= newRank
disp('univariate_diffuse_kalman_filter:: T does influence the rank of Pinf!') disp('univariate_diffuse_kalman_filter:: T does influence the rank of Pinf!')
disp('This may happen for models with order of integration >1.')
end end
end end

View File

@ -111,14 +111,22 @@ for plt = 1:nbplt
end end
end end
xx = x; xx = x;
if x(kk)~=0 if x(kk)~=0 || ~isinf(BoundsInfo.lb(kk)) || ~isinf(BoundsInfo.lb(kk))
l1 = max(BoundsInfo.lb(kk),(1-sign(x(kk))*ll)*x(kk)); m1 = 0; %lower bound l1 = max(BoundsInfo.lb(kk),(1-sign(x(kk))*ll)*x(kk)); m1 = 0; %lower bound
l2 = min(BoundsInfo.ub(kk),(1+sign(x(kk))*ll)*x(kk)); %upper bound l2 = min(BoundsInfo.ub(kk),(1+sign(x(kk))*ll)*x(kk)); %upper bound
else else
%size info for 0 parameter is missing, use prior standard %size info for 0 parameter is missing, use prior standard
%deviation %deviation
l1 = max(BoundsInfo.lb(kk),-BayesInfo.p2(kk)); m1 = 0; %lower bound upper_bound=BoundsInfo.lb(kk);
l2 = min(BoundsInfo.ub(kk),BayesInfo.p2(kk)); %upper bound if isinf(upper_bound)
upper_bound=-1e-6*DynareOptions.huge_number;
end
lower_bound=BoundsInfo.ub(kk);
if isinf(lower_bound)
lower_bound=-1e-6*DynareOptions.huge_number;
end
l1 = max(lower_bound,-BayesInfo.p2(kk)); m1 = 0; %lower bound
l2 = min(upper_bound,BayesInfo.p2(kk)); %upper bound
end end
binding_lower_bound=0; binding_lower_bound=0;
binding_upper_bound=0; binding_upper_bound=0;

View File

@ -154,7 +154,7 @@ for b=1:nb
break break
end end
end end
disp(endo_names{k}) fprintf('%s\n',endo_names{k})
end end
neq = null(jacob'); neq = null(jacob');
n_rel = size(neq,2); n_rel = size(neq,2);

@ -1 +1 @@
Subproject commit cad90545bd355f671c112fd072b9be1545cbb2c4 Subproject commit 656e63e360d9fa979f932b601c46b1c1ea8aa1a4

View File

@ -251,10 +251,7 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
% computer! % computer!
if Environment if Environment
% This check can be removed ... according to the dynare parser strategy.
% This check can be removed ... according to the dynare parser
% strategy.
if isempty(DataInput(Node).RemoteDirectory) if isempty(DataInput(Node).RemoteDirectory)
disp('The field RemoteDirectory is empty!') disp('The field RemoteDirectory is empty!')
skipline() skipline()
@ -263,10 +260,7 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
ErrorCode=5; ErrorCode=5;
return return
end end
% This check can be removed ... according to the dynare parser strategy.
% This check can be removed ... according to the dynare parser
% strategy.
if (~isempty(DataInput(Node).RemoteDrive)) if (~isempty(DataInput(Node).RemoteDrive))
disp('[WARNING] The fields RemoteDrive should be empty under unix or mac!') disp('[WARNING] The fields RemoteDrive should be empty under unix or mac!')
skipline() skipline()
@ -276,35 +270,14 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
skipline(2) skipline(2)
ErrorCode=5; ErrorCode=5;
end end
si2=[];
de2=[];
if ~isempty(DataInput(Node).Port) if ~isempty(DataInput(Node).Port)
ssh_token = ['-p ',DataInput(Node).Port]; ssh_token = ['-p ',DataInput(Node).Port];
else else
ssh_token = ''; ssh_token = '';
end end
command_string = ['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' ls ',DataInput(Node).RemoteDirectory,'/',RemoteTmpFolder,'/'];
[si2 de2]=system(['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' ls ',DataInput(Node).RemoteDirectory,'/',RemoteTmpFolder,'/']);
if (si2)
disp ('Remote Directory does not exist or is not reachable!')
skipline()
disp('ErrorCode 5.')
skipline(2)
ErrorCode=5;
return
end
disp('Check on RemoteDirectory Variable ..... Ok!')
skipline(2)
disp('Check on RemoteDrive Variable ..... Ok!')
skipline(2)
else else
% This check can be removed ... according to the dynare parser % This check can be removed ... according to the dynare parser strategy.
% strategy.
if (isempty(DataInput(Node).RemoteDrive)||isempty(DataInput(Node).RemoteDirectory)) if (isempty(DataInput(Node).RemoteDrive)||isempty(DataInput(Node).RemoteDirectory))
disp('Remote RemoteDrive and/or RemoteDirectory is/are empty!') disp('Remote RemoteDrive and/or RemoteDirectory is/are empty!')
skipline() skipline()
@ -313,32 +286,31 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
ErrorCode=5; ErrorCode=5;
return return
end end
command_string = ['dir \\',DataInput(Node).ComputerName,'\',DataInput(Node).RemoteDrive,'$\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder];
si2=[];
de2=[];
[si2 de2]=system(['dir \\',DataInput(Node).ComputerName,'\',DataInput(Node).RemoteDrive,'$\',DataInput(Node).RemoteDirectory,'\',RemoteTmpFolder]);
if (si2)
disp ('Remote Directory does not exist or it is not reachable!')
skipline()
disp('ErrorCode 5.')
skipline(2)
ErrorCode=5;
return
end
disp('Check on RemoteDirectory Variable ..... Ok!')
skipline(2)
disp('Check on RemoteDrive Variable ..... Ok!')
skipline(2)
end end
[si2, de2] = system(command_string);
% Now we verify if it possible to exchange data with the remote if (si2)
% computer: disp ('Remote Directory does not exist or is not reachable!')
skipline()
disp('ErrorCode 5.')
skipline(2)
disp('The command causing the error was:')
disp(command_string)
disp('The system returned:')
disp(de2)
skipline(2)
ErrorCode=5;
return
end
disp('Check on RemoteDirectory Variable ..... Ok!')
skipline(2)
disp('Check on RemoteDrive Variable ..... Ok!')
skipline(2)
% Now we verify if it possible to exchange data with the remote computer.
% Build a command file to test the matlab execution and dynare path ... % Build a command file to test the matlab execution and dynare path ...
@ -506,13 +478,8 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
% Now we verify if it is possible delete remote computational traces! % Now we verify if it is possible delete remote computational traces!
dynareParallelRmDir(RemoteTmpFolder,DataInput(Node)); dynareParallelRmDir(RemoteTmpFolder,DataInput(Node));
si3 = dynareParallelDir('Tracing.m', RemoteTmpFolder,DataInput(Node));
si3=[];
si3=dynareParallelDir('Tracing.m', RemoteTmpFolder,DataInput(Node));
if (isempty(si3)) if (isempty(si3))
disp ('Check on Delete Remote Computational Traces ..... Ok!') disp ('Check on Delete Remote Computational Traces ..... Ok!')
skipline(2) skipline(2)
@ -550,22 +517,18 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
% We look for the information on local computer hardware. % We look for the information on local computer hardware.
Environment1 = Environment;
si0=[];
de0=[];
Environment1=Environment;
disp('Checking Hardware please wait ...'); disp('Checking Hardware please wait ...');
if (DataInput(Node).Local == 1) if (DataInput(Node).Local == 1)
if Environment if Environment
if ~ismac if ~ismac
[si0 de0]=system('grep processor /proc/cpuinfo'); [si0, de0] = system('grep processor /proc/cpuinfo');
else else
[si0 de0]=system('sysctl -n hw.ncpu'); [si0, de0] = system('sysctl -n hw.ncpu');
Environment1=2; Environment1 = 2;
end end
else else
[si0 de0]=system(['psinfo \\']); [si0, de0] = system(['psinfo \\']);
end end
else else
if Environment if Environment
@ -576,19 +539,27 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
end end
if OStargetUnix if OStargetUnix
if RemoteEnvironment ==1 if RemoteEnvironment ==1
[si0 de0]=system(['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' grep processor /proc/cpuinfo']); command_string = ['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' grep processor /proc/cpuinfo'];
else % it is MAC else % it is MAC
[si0 de0]=system(['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' sysctl -n hw.ncpu']); command_string = ['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' sysctl -n hw.ncpu'];
Environment1=2; Environment1 = 2;
end end
else else
[si0 de0]=system(['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' psinfo']); command_string = ['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' psinfo'];
end end
else else
[si0 de0]=system(['psinfo \\',DataInput(Node).ComputerName,' -u ',DataInput(Node).UserName,' -p ',DataInput(Node).Password]); command_string = ['psinfo \\',DataInput(Node).ComputerName,' -u ',DataInput(Node).UserName,' -p ',DataInput(Node).Password];
end end
[si0, de0] = system(command_string);
end end
if (si0)
disp('The command causing the error was:')
disp(command_string)
disp('The system returned:')
disp(de0)
skipline(2)
end
RealCPUnbr=''; RealCPUnbr='';
% keyboard; % keyboard;

View File

@ -347,9 +347,9 @@ for j=1:totCPU
end end
else % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa! else % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
command1=['psexec -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"']; command1=['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
else else
command1=['psexec -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"']; command1=['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
end end
end end
else % 0.2 Parallel(indPC).Local==0: Run using network on remote machine or also on local machine. else % 0.2 Parallel(indPC).Local==0: Run using network on remote machine or also on local machine.
@ -387,20 +387,20 @@ for j=1:totCPU
if ~strcmpi(Parallel(indPC).ComputerName,MasterName) % 0.3 Run on a remote machine! if ~strcmpi(Parallel(indPC).ComputerName,MasterName) % 0.3 Run on a remote machine!
% Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa! % Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa!
if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ... command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"']; ' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
else else
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ... command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"']; ' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
end end
else % 0.4 Run on the local machine via the network else % 0.4 Run on the local machine via the network
% Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa! % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ... command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"']; ' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
else else
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ... command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"']; ' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
end end
end end
@ -418,9 +418,9 @@ for j=1:totCPU
end end
else % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa! else % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
command1=['psexec -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7'');addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"']; command1=['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7'');addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
else else
command1=['psexec -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"']; command1=['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
end end
end end
elseif Parallel(indPC).Local==0 % 1.2 Run using network on remote machine or also on local machine. elseif Parallel(indPC).Local==0 % 1.2 Run using network on remote machine or also on local machine.
@ -462,19 +462,19 @@ for j=1:totCPU
if ~strcmpi(Parallel(indPC).ComputerName,MasterName) % 1.3 Run on a remote machine. if ~strcmpi(Parallel(indPC).ComputerName,MasterName) % 1.3 Run on a remote machine.
% Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa! % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ... command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7'');addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"']; ' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7'');addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
else else
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ... command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"']; ' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
end end
else % 1.4 Run on the local machine via the network. else % 1.4 Run on the local machine via the network.
% Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa! % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ... command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"']; ' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
else else
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ... command1=['psexec \\',Parallel(indPC).ComputerName,' -accepteula -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"']; ' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
end end
end end

View File

@ -116,7 +116,7 @@ x = repmat(transpose(steadystate_x), 1+M.maximum_exo_lag+M.maximum_exo_lead, 1);
[d1, jacobian] = dynamicmodel(z, x, params, steadystate_y, M.maximum_exo_lag+1); [d1, jacobian] = dynamicmodel(z, x, params, steadystate_y, M.maximum_exo_lag+1);
% Check that the dynamic model was evaluated at the steady state. % Check that the dynamic model was evaluated at the steady state.
if max(abs(d1))>1e-12 if max(abs(d1))>options.solve_tolf
error('Jacobian is not evaluated at the steady state!') error('Jacobian is not evaluated at the steady state!')
end end

View File

@ -127,7 +127,7 @@ else
% which files have to be copied to run remotely % which files have to be copied to run remotely
NamFileInput(1,:) = {'',[ModelName '_static.m']}; NamFileInput(1,:) = {'',[ModelName '_static.m']};
NamFileInput(2,:) = {'',[ModelName '_dynamic.m']}; NamFileInput(2,:) = {'',[ModelName '_dynamic.m']};
if M.set_auxiliary_variables if M_.set_auxiliary_variables
NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']}; NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']};
end end
if options_.steadystate_flag if options_.steadystate_flag

View File

@ -91,7 +91,7 @@ switch (extension)
case { '.xls', '.xlsx' } case { '.xls', '.xlsx' }
[freq,init,data,varlist] = load_xls_file_data(fullname,xls_sheet,xls_range); [freq,init,data,varlist] = load_xls_file_data(fullname,xls_sheet,xls_range);
for dyn_i_01=1:var_size_01 for dyn_i_01=1:var_size_01
iv = strmatch(strtrim(var_names_01(dyn_i_01,:)),varlist,'exact'); iv = strmatch(strtrim(var_names_01{dyn_i_01}),varlist,'exact');
if ~isempty(iv) if ~isempty(iv)
dyn_tmp_01 = [data(:,iv)]'; dyn_tmp_01 = [data(:,iv)]';
if length(dyn_tmp_01) > dyn_size_01 && dyn_size_01 > 0 if length(dyn_tmp_01) > dyn_size_01 && dyn_size_01 > 0
@ -101,7 +101,7 @@ switch (extension)
dyn_data_01(:,dyn_i_01) = dyn_tmp_01; dyn_data_01(:,dyn_i_01) = dyn_tmp_01;
else else
cd(old_pwd) cd(old_pwd)
error([strtrim(var_names_01(dyn_i_01,:)) ' not found in ' fullname]) error([strtrim(var_names_01{dyn_i_01}) ' not found in ' fullname])
end end
end end
case '.csv' case '.csv'

View File

@ -193,36 +193,38 @@ end
% Handle auxiliary variables for lags (both on endogenous and exogenous) % Handle auxiliary variables for lags (both on endogenous and exogenous)
for i = 1:length(M_.aux_vars) for i = 1:length(M_.aux_vars)
if M_.aux_vars(i).type ~= 1 && M_.aux_vars(i).type ~= 3 if ~ ismember(M_.endo_names{M_.aux_vars(i).endo_index},invars)
continue if M_.aux_vars(i).type ~= 1 && M_.aux_vars(i).type ~= 3
end continue
if M_.aux_vars(i).type == 1
% Endogenous
orig_var = M_.endo_names{M_.aux_vars(i).orig_index};
else
% Exogenous
orig_var = M_.exo_names{M_.aux_vars(i).orig_index};
end
[m, k] = ismember(orig_var, outvars);
if m
if ~isempty(strmatch(invars{k}, M_.endo_names))
s = getfield(smoothedvars, invars{k});
else
s = getfield(smoothedshocks, invars{k});
end end
l = M_.aux_vars(i).orig_lead_lag; if M_.aux_vars(i).type == 1
if period-M_.maximum_endo_lag+1+l < 1 % Endogenous
error('The period that you indicated is too small to construct initial conditions') orig_var = M_.endo_names{M_.aux_vars(i).orig_index};
end
j = M_.aux_vars(i).endo_index;
v = s((period-M_.maximum_endo_lag+1+l):(period+l)); %+steady_state(j);
if ~isfield(opts, 'outfile')
M_.endo_histval(j, :) = v;
else else
% When saving to a file, x(-2) is in the variable called "x_l2" % Exogenous
lead_lag = num2str(l); orig_var = M_.exo_names{M_.aux_vars(i).orig_index};
lead_lag = regexprep(lead_lag, '-', 'l'); end
o = setfield(o, [ orig_var '_' lead_lag ], v); [m, k] = ismember(orig_var, outvars);
if m
if ~isempty(strmatch(invars{k}, M_.endo_names))
s = getfield(smoothedvars, invars{k});
else
s = getfield(smoothedshocks, invars{k});
end
l = M_.aux_vars(i).orig_lead_lag;
if period-M_.maximum_endo_lag+1+l < 1
error('The period that you indicated is too small to construct initial conditions')
end
j = M_.aux_vars(i).endo_index;
v = s((period-M_.maximum_endo_lag+1+l):(period+l)); %+steady_state(j);
if ~isfield(opts, 'outfile')
M_.endo_histval(j, :) = v;
else
% When saving to a file, x(-2) is in the variable called "x_l2"
lead_lag = num2str(l);
lead_lag = regexprep(lead_lag, '-', 'l');
o = setfield(o, [ orig_var '_' lead_lag ], v);
end
end end
end end
end end

View File

@ -29,7 +29,7 @@ function [dr,info] = stochastic_solvers(dr,task,M_,options_,oo_)
% none. % none.
% %
% Copyright (C) 1996-2017 Dynare Team % Copyright (C) 1996-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -57,6 +57,9 @@ if M_.hessian_eq_zero && local_order~=1
local_order = 1; local_order = 1;
warning('stochastic_solvers: using order = 1 because Hessian is equal to zero'); warning('stochastic_solvers: using order = 1 because Hessian is equal to zero');
end end
if options_.order>2 && ~options_.k_order_solver
error('You need to set k_order_solver for order>2')
end
if (options_.aim_solver == 1) && (local_order > 1) if (options_.aim_solver == 1) && (local_order > 1)
error('Option "aim_solver" is incompatible with order >= 2') error('Option "aim_solver" is incompatible with order >= 2')

View File

@ -24,7 +24,7 @@ function [DynareDataset, DatasetInfo, newdatainterface] = makedataset(DynareOpti
% %
% See also dynare_estimation_init % See also dynare_estimation_init
% Copyright (C) 2014-2017 Dynare Team % Copyright (C) 2014-2018 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -81,7 +81,7 @@ elseif isempty(DynareOptions.datafile) && ~isempty(DynareOptions.dataset.series)
elseif ~isempty(DynareOptions.datafile) && isempty(DynareOptions.dataset.file) elseif ~isempty(DynareOptions.datafile) && isempty(DynareOptions.dataset.file)
datafile = DynareOptions.datafile; datafile = DynareOptions.datafile;
newdatainterface = 0; newdatainterface = 0;
elseif isempty(DynareOptions.datafile) && ~isempty(DynareOptions.dataset.file) elseif ~isempty(DynareOptions.datafile) && ~isempty(DynareOptions.dataset.file)
error('makedataset: You cannot simultaneously use the data command and the datafile option (in the estimation command)!') error('makedataset: You cannot simultaneously use the data command and the datafile option (in the estimation command)!')
else else
error('makedataset: You have to specify the datafile!') error('makedataset: You have to specify the datafile!')
@ -267,7 +267,7 @@ else
end end
% Compute the empirical mean of the observed variables. % Compute the empirical mean of the observed variables.
DatasetInfo.descriptive.mean = nanmean(DynareDataset.data); DatasetInfo.descriptive.mean = nanmean(DynareDataset.data,1);
% Compute the empirical covariance matrix of the observed variables. % Compute the empirical covariance matrix of the observed variables.
DatasetInfo.descriptive.covariance = nancovariance(DynareDataset.data); DatasetInfo.descriptive.covariance = nancovariance(DynareDataset.data);

View File

@ -51,7 +51,7 @@ function CovarianceMatrix = nancovariance(data)
CovarianceMatrix = zeros(size(data,2)); CovarianceMatrix = zeros(size(data,2));
if isanynan(data) if isanynan(data)
data = bsxfun(@minus,data,nanmean(data)); data = bsxfun(@minus,data,nanmean(data,1));
for i=1:size(data,2) for i=1:size(data,2)
for j=i:size(data,2) for j=i:size(data,2)
CovarianceMatrix(i,j) = nanmean(data(:,i).*data(:,j)); CovarianceMatrix(i,j) = nanmean(data(:,i).*data(:,j));
@ -61,7 +61,7 @@ if isanynan(data)
end end
end end
else else
data = bsxfun(@minus,data,mean(data)); data = bsxfun(@minus,data,mean(data,1));
CovarianceMatrix = (transpose(data)*data)/size(data,1); CovarianceMatrix = (transpose(data)*data)/size(data,1);
end end

View File

@ -14,6 +14,7 @@ function [ya, yass, gya, gyass] = quarterly2annual(y,yss,GYTREND0,type,islog,aux
% 5 annual price as quantity weighted average % 5 annual price as quantity weighted average
% 6 annual quantity from average price % 6 annual quantity from average price
% 7 annual nominal from Q real and deflator % 7 annual nominal from Q real and deflator
% 8 annual ratio [e.g. trade balance to GDP]
% islog 0 level (default) % islog 0 level (default)
% 1 log-level % 1 log-level
% 2 growth rate Q frequency % 2 growth rate Q frequency
@ -120,6 +121,19 @@ switch type
yn = (y+yss).*(yaux+yauxss) - yss.*yauxss; yn = (y+yss).*(yaux+yauxss) - yss.*yauxss;
[ya, yass] = quarterly2annual(yn,yss.*yauxss,GYTREND0+GYTREND0aux,typeaux,0,0); [ya, yass] = quarterly2annual(yn,yss.*yauxss,GYTREND0+GYTREND0aux,typeaux,0,0);
GYTREND0=GYTREND0+GYTREND0aux; GYTREND0=GYTREND0+GYTREND0aux;
case 8
% numerator
yn = y;
[yna, ynass] = quarterly2annual(yn,yss,GYTREND0,typeaux(1),0,0);
% denominator
yd = yaux;
[yda, ydass] = quarterly2annual(yd,yauxss,GYTREND0aux,typeaux(2),0,0);
% ratio
yass = ynass/ydass;
ya = (yna+ynass)./(yda+ydass)-yass;
GYTREND0 = GYTREND0 - GYTREND0aux;
otherwise otherwise
error('Wrong type input') error('Wrong type input')
end end

View File

@ -1,33 +1,14 @@
function c = demean(x) function c = demean(x)
% Removes the mean of each column of a matrix. % Removes the mean of each column of a matrix.
%
% INPUTS
% - x [double] T*N matrix of data.
%
% OUTPUTS
% - c [double] T*N matrix of demeaned data.
%@info: % Copyright (C) 2011-2018 Dynare Team
%! @deftypefn {Function File} {@var{c} =} demean (@var{x})
%! @anchor{demean}
%! This function removes the mean of each column of a matrix.
%!
%! @strong{Inputs}
%! @table @var
%! @item x
%! Matlab matrix (T-by-N).
%! @end table
%!
%! @strong{Outputs}
%! @table @var
%! @item c
%! Matlab matrix (T-by-N). The demeaned x matrix.
%! @end table
%!
%! @strong{This function is called by:}
%! @ref{compute_cova}, @ref{compute_acov}, @ref{compute_std}.
%!
%! @strong{This function calls:}
%! @ref{ndim},
%!
%! @end deftypefn
%@eod:
% Copyright (C) 2011-2017 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -44,12 +25,8 @@ function c = demean(x)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% Original author: stephane DOT adjemian AT univ DASH lemans DOT fr if ndim(x)>2
error('This function is not implemented for arrays with dimension greater than two!')
end
if ndim(x)==1 c = bsxfun(@minus, x, nanmean(x));
c = x-mean(x);
elseif ndim(x)==2
c = bsxfun(@minus,x,mean(x));
else
error('descriptive_statistics::demean:: This function is not implemented for arrays with dimension greater than two!')
end

View File

@ -2686,7 +2686,7 @@ InitialConditionDecompositionStatement::writeOutput(ostream &output, const strin
output << "options_ = set_default_initial_condition_decomposition_options(options_);" << endl; output << "options_ = set_default_initial_condition_decomposition_options(options_);" << endl;
options_list.writeOutput(output); options_list.writeOutput(output);
symbol_list.writeOutput("var_list_", output); symbol_list.writeOutput("var_list_", output);
output << "initial_condition_decomposition(M_, oo_, options_, var_list_, bayestopt_, estim_params_);" << endl; output << "oo_ = initial_condition_decomposition(M_, oo_, options_, var_list_, bayestopt_, estim_params_);" << endl;
} }
ConditionalForecastStatement::ConditionalForecastStatement(const OptionsList &options_list_arg) : ConditionalForecastStatement::ConditionalForecastStatement(const OptionsList &options_list_arg) :

View File

@ -114,7 +114,7 @@ class ParsingDriver;
%token CPF_WEIGHTS AMISANOTRISTANI MURRAYJONESPARSLOW WRITE_EQUATION_TAGS METHOD %token CPF_WEIGHTS AMISANOTRISTANI MURRAYJONESPARSLOW WRITE_EQUATION_TAGS METHOD
%token NONLINEAR_FILTER_INITIALIZATION FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION %token NONLINEAR_FILTER_INITIALIZATION FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION
%token <string_val> NAME %token <string_val> NAME
%token USE_PENALIZED_OBJECTIVE_FOR_HESSIAN INIT_STATE RESCALE_PREDICTION_ERROR_COVARIANCE GENERATE_IRFS %token USE_PENALIZED_OBJECTIVE_FOR_HESSIAN INIT_STATE FAST_REALTIME RESCALE_PREDICTION_ERROR_COVARIANCE GENERATE_IRFS
%token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS NO_HOMOTOPY %token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS NO_HOMOTOPY
%token NOGRAPH POSTERIOR_NOGRAPH POSTERIOR_GRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS MODEL_NAME STDERR_MULTIPLES DIAGONAL_ONLY %token NOGRAPH POSTERIOR_NOGRAPH POSTERIOR_GRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS MODEL_NAME STDERR_MULTIPLES DIAGONAL_ONLY
%token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED OUTFILE OUTVARS OVERWRITE %token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED OUTFILE OUTVARS OVERWRITE
@ -2827,6 +2827,7 @@ realtime_shock_decomposition_option : o_parameter_set
| o_shock_decomposition_presample | o_shock_decomposition_presample
| o_shock_decomposition_forecast | o_shock_decomposition_forecast
| o_save_realtime | o_save_realtime
| o_fast_realtime
; ;
plot_shock_decomposition_options_list : plot_shock_decomposition_option COMMA plot_shock_decomposition_options_list plot_shock_decomposition_options_list : plot_shock_decomposition_option COMMA plot_shock_decomposition_options_list
@ -2860,6 +2861,9 @@ initial_condition_decomposition_option : o_icd_type
| o_icd_write_xls | o_icd_write_xls
| o_icd_plot_init_date | o_icd_plot_init_date
| o_icd_plot_end_date | o_icd_plot_end_date
| o_nodisplay
| o_graph_format
| o_psd_fig_name
; ;
homotopy_setup: HOMOTOPY_SETUP ';' homotopy_list END ';' homotopy_setup: HOMOTOPY_SETUP ';' homotopy_list END ';'
@ -3240,6 +3244,7 @@ o_init_state : INIT_STATE EQUAL INT_NUMBER { driver.option_num("shock_decomp.ini
o_shock_decomposition_presample : PRESAMPLE EQUAL INT_NUMBER { driver.option_num("shock_decomp.presample", $3); }; o_shock_decomposition_presample : PRESAMPLE EQUAL INT_NUMBER { driver.option_num("shock_decomp.presample", $3); };
o_shock_decomposition_forecast : FORECAST EQUAL INT_NUMBER { driver.option_num("shock_decomp.forecast", $3); }; o_shock_decomposition_forecast : FORECAST EQUAL INT_NUMBER { driver.option_num("shock_decomp.forecast", $3); };
o_save_realtime : SAVE_REALTIME EQUAL vec_int { driver.option_vec_int("shock_decomp.save_realtime", $3); }; o_save_realtime : SAVE_REALTIME EQUAL vec_int { driver.option_vec_int("shock_decomp.save_realtime", $3); };
o_fast_realtime : FAST_REALTIME EQUAL INT_NUMBER { driver.option_num("shock_decomp.fast_realtime", $3); };
o_nodisplay : NODISPLAY { driver.option_num("nodisplay","1"); }; o_nodisplay : NODISPLAY { driver.option_num("nodisplay","1"); };
o_psd_nodisplay : NODISPLAY { driver.option_num("plot_shock_decomp.nodisplay","1"); }; o_psd_nodisplay : NODISPLAY { driver.option_num("plot_shock_decomp.nodisplay","1"); };
o_graph_format : GRAPH_FORMAT EQUAL allowed_graph_formats o_graph_format : GRAPH_FORMAT EQUAL allowed_graph_formats

View File

@ -594,6 +594,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>controlled_varexo {return token::CONTROLLED_VAREXO; } <DYNARE_STATEMENT>controlled_varexo {return token::CONTROLLED_VAREXO; }
<DYNARE_STATEMENT>parameter_set {return token::PARAMETER_SET; } <DYNARE_STATEMENT>parameter_set {return token::PARAMETER_SET; }
<DYNARE_STATEMENT>init_state {return token::INIT_STATE; } <DYNARE_STATEMENT>init_state {return token::INIT_STATE; }
<DYNARE_STATEMENT>fast_realtime {return token::FAST_REALTIME; }
<DYNARE_STATEMENT>save_realtime {return token::SAVE_REALTIME;} <DYNARE_STATEMENT>save_realtime {return token::SAVE_REALTIME;}
<DYNARE_STATEMENT>detail_plot {return token::DETAIL_PLOT;} <DYNARE_STATEMENT>detail_plot {return token::DETAIL_PLOT;}
<DYNARE_STATEMENT>interactive {return token::INTERACTIVE;} <DYNARE_STATEMENT>interactive {return token::INTERACTIVE;}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2008-2017 Dynare Team * Copyright (C) 2008-2018 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -60,7 +60,11 @@ MacroDriver::parse(const string &f, const string &fb, const string &modfiletxt,
} }
catch (boost::bad_lexical_cast &) catch (boost::bad_lexical_cast &)
{ {
file_with_endl << "@#define " << it->first << " = \"" << it->second << "\"" << endl; if (!it->second.empty() && it->second.at(0) == '[' && it->second.at(it->second.length()-1) == ']')
// If the input is an array. Issue #1578
file_with_endl << "@#define " << it->first << " = " << it->second << endl;
else
file_with_endl << "@#define " << it->first << " = \"" << it->second << "\"" << endl;
} }
file_with_endl << modfiletxt << endl; file_with_endl << modfiletxt << endl;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2008-2017 Dynare Team * Copyright (C) 2008-2018 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -71,6 +71,8 @@ CONT \\\\
yylloc->step(); yylloc->step();
%} %}
<STMT,EXPR,FOR_BODY,THEN_BODY,ELSE_BODY>["/"]["/"].*
<INITIAL>^{SPC}*@#{SPC}*includepath{SPC}+\"([^\"\r\n:;|<>]*){1}(:[^\"\r\n:;|<>]*)*\"{SPC}*{EOL} { <INITIAL>^{SPC}*@#{SPC}*includepath{SPC}+\"([^\"\r\n:;|<>]*){1}(:[^\"\r\n:;|<>]*)*\"{SPC}*{EOL} {
yylloc->lines(1); yylloc->lines(1);
yylloc->step(); yylloc->step();
@ -303,6 +305,16 @@ CONT \\\\
then_body_tmp.append(yytext); then_body_tmp.append(yytext);
yylloc->step(); yylloc->step();
} }
<THEN_BODY>^{SPC}*@#{SPC}*ifdef({SPC}|{CONT}) {
nested_if_nb++;
then_body_tmp.append(yytext);
yylloc->step();
}
<THEN_BODY>^{SPC}*@#{SPC}*ifndef({SPC}|{CONT}) {
nested_if_nb++;
then_body_tmp.append(yytext);
yylloc->step();
}
<THEN_BODY>. { then_body_tmp.append(yytext); yylloc->step(); } <THEN_BODY>. { then_body_tmp.append(yytext); yylloc->step(); }
<THEN_BODY><<EOF>> { driver.error(if_stmt_loc_tmp, "@#if/@#ifdef/@#ifndef not matched by an @#endif or file does not end with a new line (unexpected end of file)"); } <THEN_BODY><<EOF>> { driver.error(if_stmt_loc_tmp, "@#if/@#ifdef/@#ifndef not matched by an @#endif or file does not end with a new line (unexpected end of file)"); }
<THEN_BODY>^{SPC}*@#{SPC}*else{SPC}*(\/\/.*)?{EOL} { <THEN_BODY>^{SPC}*@#{SPC}*else{SPC}*(\/\/.*)?{EOL} {

View File

@ -129,6 +129,12 @@ close all
plot_shock_decomposition(detail_plot, interactive, use_shock_groups = row, type = qoq); plot_shock_decomposition(detail_plot, interactive, use_shock_groups = row, type = qoq);
plot_shock_decomposition(detail_plot, interactive, realtime = 3, vintage = 29); plot_shock_decomposition(detail_plot, interactive, realtime = 3, vintage = 29);
close all,
// testing realtime decomposition with fast_realtime option
realtime_shock_decomposition(fast_realtime=75);
collect_latex_files; collect_latex_files;
if system(['pdflatex -halt-on-error -interaction=batchmode ' M_.fname '_TeX_binder.tex']) if system(['pdflatex -halt-on-error -interaction=batchmode ' M_.fname '_TeX_binder.tex'])
error('TeX-File did not compile.') error('TeX-File did not compile.')

View File

@ -61,7 +61,7 @@ This version of Dynare is compiled for Octave 4.2.1 (MinGW, 32bit and 64bit), an
with other versions of Octave. The recommended version of Octave can be with other versions of Octave. The recommended version of Octave can be
downloaded at: downloaded at:
http://www.dynare.org/download/octave/windows https://www.gnu.org/software/octave/download.html
Every time you run Octave, you should type the two following commands (assuming 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' that you have installed Dynare at the standard location, and replacing '4.x.y'