Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • giovanma/dynare
  • giorgiomas/dynare
  • Vermandel/dynare
  • Dynare/dynare
  • normann/dynare
  • MichelJuillard/dynare
  • wmutschl/dynare
  • FerhatMihoubi/dynare
  • sebastien/dynare
  • lnsongxf/dynare
  • rattoma/dynare
  • CIMERS/dynare
  • FredericKarame/dynare
  • SumuduK/dynare
  • MinjeJeon/dynare
  • camilomrch/dynare
  • DoraK/dynare
  • avtishin/dynare
  • selma/dynare
  • claudio_olguin/dynare
  • jeffjiang07/dynare
  • EthanSystem/dynare
  • stepan-a/dynare
  • wjgatt/dynare
  • JohannesPfeifer/dynare
  • gboehl/dynare
  • chskcau/dynare-doc-fixes
27 results
Select Git revision
Show changes
Commits on Source (92)
Showing
with 1176 additions and 460 deletions
Announcement for Dynare 4.4.0 (on 2013-12-11)
=============================================
We are pleased to announce the release of Dynare 4.4.0.
This major release adds new features and fixes various bugs.
The Windows package is already available for download. The Mac and
Debian/Ubuntu packages should follow soon.
All users are strongly encouraged to upgrade.
This release is compatible with MATLAB versions ranging from 7.3 (R2006b) to
8.2 (R2013b) and with GNU Octave version 3.6.
Here is the list of major user-visible changes:
* New major algorithms:
- Extended path at order 1 and above, also known as “stochastic extended
path”. This method is triggered by setting the `order' option of the
`extended_path' command to a value greater than 0. Dynare will then use a
Gaussian quadrature to take into account the effects of future uncertainty.
The time series for the endogenous variables are generated by assuming that
the agents believe that there will no more shocks after period t+order.
- Alternative algorithms for computing decision rules of a stochastic model,
based on the cycle reduction and logarithmic reduction algorithms. These
methods are respectively triggered by giving `dr = cycle_reduction' or 'dr
= logarithmic_reduction' as an option to the `stoch_simul' command.
- Pruning now works with 3rd order approximation, along the lines of
Andreasen, Fernández-Villaverde and Rubio-Ramírez (2013).
- Computation of conditional forecast using an extended path method. This is
triggered by the new option `simulation_type = deterministic' in the
`conditional_forecast' command. In this case, the `expectation' command in
the `conditional_forecast_paths' block has to be used to indicate the nature
of expectations (whether shocks are a surprise or are perfectly
anticipated).
- Endogenous priors as in Christiano, Trabandt and Walentin (2011). Those are
triggered by the new option `endogenous_prior' of the `estimation' command.
* Other algorithmic improvements:
- New command `model_diagnostics' to perform various sanity checks on the
model. Note: in the past, some users may have used a preliminary MATLAB
function implementing this; the new command has the same syntax, except that
you shouldn't pass any argument to it.
- Terminal conditions of perfect foresight simulations can now be specified in
growth rates. More specifically, the new option `differentiate_forward_vars'
of the `model' block will create auxiliary forward looking variables
expressed in first differences or growth rates of the actual forward looking
variables defined in the model. These new variables have obvious zero
terminal conditions whatever the simulation context and this in many cases
helps convergence of simulations.
- Convergence diagnostics for single chain MCMC à la Geweke (1992, 1999).
- New optimizer for the posterior mode (triggered by `mode_compute=10'): it
uses the simpsa algorithm, based on the combination of the non-linear
simplex and simulated annealing algorithms and proposed by Cardoso, Salcedo
and Feyo de Azevedo (1996).
- The automatic detrending engine has been extended to work on models written
in logs. The corresponding trend variable type is `log_trend_var', and the
corresponding deflator type is `log_deflator'.
* New features in the user interface:
- New set of functions for easily creating PDF reports including figures and
tables. See the “Reporting” section in the reference manual for more
details.
- New MATLAB/Octave classes for handling time series. See the “Time series”
section in the reference manual for more details.
- Datafiles in CSV format can now be used for estimation.
- New macro processor `length' operator, returns the length of an array.
- New option `all_values_required' of `initval' and `endval' blocks: enforces
initialization of all endogenous and exogenous variables within the block.
- Option `ar' can now be given to the `estimation' command.
- New options `nograph', `nointeractive' and `nowarn' to the `dynare' command,
for a better control of what is displayed.
- New option `nostrict' to the `dynare' command, for allowing Dynare to
continue processing when there are more endogenous variables than equations
or when an undeclared symbol is assigned in `initval' or `endval'.
- The information on MCMC acceptance rates, seeds, last log posterior
likelihood, and last parameter draw are now saved on the disk and can
be displayed with `internals --display-mh-history' or loaded into the
workspace with `internals --load-mh-history'.
- New options `mode_check_neighbourhood_size', `mode_check_symmetric_plots'
and `mode_check_number_of_points', for a better control of the diagnostic
plots.
- New option `parallel_local_files' of `model' block, for transferring extra
files during parallel computations.
- New option `clock' of `set_dynare_seed', for setting a different seed at
each run.
- New option `qz_zero_threshold' of the `check', `stoch_simul' and
`estimation' commands, for a better control of the situation where a
generalized eigenvalue is close to 0/0.
- New `verbatim' block for inclusion of text that should pass through the
preprocessor and be placed as is in the `modfile.m' file.
- New option `mcmc_jumping_covariance' of the `estimation' command, for a
better control of the covariance matrix used for the proposal density of the
MCMC sampler.
- New option `use_calibration' of the `estimated_params_init', for using the
calibration of deep parameters and the elements of the covariance matrix
specified in the `shocks' block as starting values for the estimation.
- New option `save_draws' of the `ms_simulation' command.
- New option `irf_plot_threshold' of the `stoch_simul' and `estimation'
commands, for a better control of the display of IRFs which are almost nil.
- New option `long_name' for endogenous, exogenous and parameter declarations,
which can be used to declare a long name for variables. That long name can
be programmatically retrieved in `M_.endo_names_long'.
* Miscellaneous changes
- The deciles of some posterior moments were erroneously saved in a field
`Distribution' under `oo_'. This field is now called `deciles', for
consistency with other posterior moments and with the manual. Similarly, the
fields `Mean', `Median', `HPDsup', `HPDinf', and `Variance' are now
consistently capitalized.
- The console mode now implies the `nodisplay' option.
* Bugs and problems identified in version 4.3.3 and that have been fixed in
version 4.4.0:
- In an `endval' block, auxiliary variables were not given the right value.
This would not result in wrong results, but could prevent convergence of
the steady state computation.
- Deterministic simulations with `stack_solve_algo=0' (the default value) were
crashing if some exogenous had a lag strictly greater than 1.
- When using the `mode_file' option, the initial estimation checks were not
performed for the loaded mode, but for the original starting values. Thus,
potential prior violations by the mode only appeared during estimation,
leading to potentially cryptic crashes and error messages.
- If a shock/measurement error variance was set to 0 in calibration, the
correlation matrix featured a 0 instead of a 1 on the diagonal, leading to
wrong estimation results.
- In the presence of calibrated covariances, estimation did not enforce
positive definiteness of the covariance matrix.
- Estimation using the `diffuse_filter' option together with the univariate
Kalman filter and a diagonal measurement error matrix was broken.
- A purely backward model with `k_order_solver' was leading to crashes of
MATLAB/Octave.
- Non-linear estimation was not skipping the specified presample when
computing the likelihood.
- IRFs and theoretical moments at order > 1 were broken for purely
forward-looking models.
- Simulated moments with constant variables was leading to crashes when
displaying autocorrelations.
- The `osr' command was sometimes crashing with cryptic error messages because
of some unaccounted error codes returned from a deeper routine.
- The check for stochastic singularity during initial estimation checks was
broken.
- Recursive estimation starting with the pathological case of `nobs=1' was
crashing.
- Conditional variance decomposition within or after estimation was crashing
when at least one shock had been calibrated to zero variance.
- The `estimated_params_init' and `estimated_params_bounds' blocks were broken
for correlations.
- The `filter_step_ahead' option was not producing any output in Bayesian
estimation.
- Deterministic simulations were sometimes erroneously indicating convergence
although the residuals were actually NaN or Inf.
- Supplying a user function in the `mode_compute' option was leading to
a crash.
- Deterministic simulation of models without any exogenous variable was
crashing.
- The MS-SBVAR code was not updating files between runs on Windows. This means
that if a MOD file was updated between runs in the same folder and a
`file_tag' was not changed, then the results would not change.
- The `ramsey_policy' command was not putting in `oo_.planner_objective_value'
the value of the planner objective at the optimum.
* References:
- Andreasen, Martin M., Jesús Fernández-Villaverde, and Juan Rubio-Ramírez
(2013): “The Pruned State-Space System for Non-Linear DSGE Models: Theory
and Empirical Applications,” NBER Working Paper, 18983
- Cardoso, Margarida F., R. L. Salcedo and S. Feyo de Azevedo (1996): “The
simplex simulated annealing approach to continuous non-linear optimization,”
Computers chem. Engng, 20(9), 1065-1080
- Christiano, Lawrence J., Mathias Trabandt and Karl Walentin (2011):
“Introducing financial frictions and unemployment into a small open economy
model,” Journal of Economic Dynamics and Control, 35(12), 1999-2041
- Geweke, John (1992): “Evaluating the accuracy of sampling-based approaches
to the calculation of posterior moments,” in J.O. Berger, J.M. Bernardo,
A.P. Dawid, and A.F.M. Smith (eds.) Proceedings of the Fourth Valencia
International Meeting on Bayesian Statistics, pp. 169-194, Oxford University
Press
- Geweke, John (1999): “Using simulation methods for Bayesian econometric
models: Inference, development and communication,” Econometric Reviews,
18(1), 1-73
Announcement for Dynare 4.3.3 (on 2013-04-12)
=============================================
......
......@@ -78,9 +78,8 @@ If you have downloaded the sources from an official source archive or the source
If you want to use Git, do the following from a terminal:
git clone http://github.com/DynareTeam/dynare.git
git clone --recursive http://github.com/DynareTeam/dynare.git
cd dynare
git submodule update --init
autoreconf -si
The last line runs Autoconf and Automake in order to prepare the build environment (this is not necessary if you got the sources from an official source archive or the source snapshot).
......
......@@ -18,7 +18,7 @@ dnl You should have received a copy of the GNU General Public License
dnl along with Dynare. If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ([2.62])
AC_INIT([dynare], [4.4-unstable])
AC_INIT([dynare], [4.4.0])
AC_CONFIG_SRCDIR([preprocessor/DynareMain.cc])
AM_INIT_AUTOMAKE([1.11 -Wall -Wno-portability foreign no-dist-gzip dist-xz tar-pax])
......@@ -83,10 +83,6 @@ CPPFLAGS="$CPPFLAGS_SAVED"
# Don't use deprecated hash structures
AC_DEFINE([BOOST_NO_HASH], [], [Don't use deprecated STL hash structures])
# Check for dlopen(), needed by tests for estimation DLL
AC_CHECK_LIB([dl], [dlopen], [LIBADD_DLOPEN="-ldl"], [])
AC_SUBST([LIBADD_DLOPEN])
# Check for libmatio, needed by Dynare++
AX_MATIO
AM_CONDITIONAL([HAVE_MATIO], [test "x$has_matio" = "xyes"])
......@@ -192,10 +188,6 @@ AC_CONFIG_FILES([Makefile
dynare++/kord/Makefile
dynare++/src/Makefile
mex/sources/Makefile
mex/sources/estimation/Makefile
mex/sources/estimation/tests/Makefile
mex/sources/estimation/libmat/Makefile
mex/sources/estimation/libmat/tests/Makefile
])
AC_ARG_ENABLE([matlab], AS_HELP_STRING([--disable-matlab], [disable compilation of MEX files for MATLAB]), [], [enable_matlab=yes])
......
switch_dw @ abb30501
Subproject commit 29c446f7fe8a773860ebee347662c4ae2494c5e9
Subproject commit abb3050121bb92b63e665f697930cdf11fe018f5
utilities_dw @ 216abedb
Subproject commit b388d5eac8c8d092088db5ef805584ae4dd2d952
Subproject commit 216abedb9ab4df5dd4dca07c721f7c07392801e9
This diff is collapsed.
......@@ -15,7 +15,14 @@
* equations. Moreover, it makes use of a steady state file to i) set
* parameters that depend on other parameters that are potentially estimated
* and ii) solve a nonlinear equation using a numerical solver to find the steady
* state of labor.
* state of labor. It provides an example on how the steady state file can be used
* to circumvent some of the limitation of Dynare mod-file by accessing an external
* file that allows calling general Matlab routines. These capacities will mostly be
* interesting for power users. If one just wants to provide analytical steady state
* values and update parameters, the steady_state_model-block allows an easy and convenient
* alternative. It even allows calling numerical solvers like fsolve. For an example, see
* example3.mod
*
* The model is written in the beginning of period stock notation. To make the model
* conform with Dynare's end of period stock notation, we use the
* predetermined_variables-command.
......
function [ys,check] = NK_baseline_steadystate(ys,exe)
global M_ lgy_
if isfield(M_,'param_nbr') == 1
function [ys,check] = NK_baseline_steadystate(ys,exo)
% function [ys,check] = NK_baseline_steadystate(ys,exo)
% computes the steady state for the NK_baseline.mod and uses a numerical
% solver to do so
% Inputs:
% - ys [vector] vector of initial values for the steady state of
% the endogenous variables
% - exo [vector] vector of values for the exogenous variables
%
% Output:
% - ys [vector] vector of steady state values fpr the the endogenous variables
% - check [scalar] set to 0 if steady state computation worked and to
% 1 of not (allows to impos restriction on parameters)
global M_
% read out parameters to access them with their name
NumberOfParameters = M_.param_nbr;
for i = 1:NumberOfParameters
paramname = deblank(M_.param_names(i,:));
eval([ paramname ' = M_.params(' int2str(i) ');']);
for ii = 1:NumberOfParameters
paramname = deblank(M_.param_names(ii,:));
eval([ paramname ' = M_.params(' int2str(ii) ');']);
end
% initialize indicator
check = 0;
end
%% Enter model equations here
......@@ -32,6 +45,11 @@ Lambdax=mu_z;
%set the parameter gammma1
gammma1=mu_z*mu_I/betta-(1-delta);
if gammma1<0 % parameter violates restriction; Preventing this cannot be implemented via prior restriction as it is a composite of different parameters and the valid prior region has unknown form
check=1; %set failure indicator
return; %return without updating steady states
end
r=1*gammma1;
R=1+(PI*mu_z/betta-1);
......@@ -49,9 +67,17 @@ vp=(1-thetap)/(1-thetap*PI^((1-chi)*epsilon))*PIstar^(-epsilon);
vw=(1-thetaw)/(1-thetaw*PI^((1-chiw)*eta)*mu_z^eta)*PIstarw^(-eta);
tempvaromega=alppha/(1-alppha)*w/r*mu_z*mu_I;
ld=fsolve(@(ld)(1-betta*thetaw*mu_z^(eta-1)*PI^(-(1-chiw)*(1-eta)))/(1-betta*thetaw*mu_z^(eta*(1+gammma))*PI^(eta*(1-chiw)*(1+gammma)))...
[ld,fval,exitflag]=fsolve(@(ld)(1-betta*thetaw*mu_z^(eta-1)*PI^(-(1-chiw)*(1-eta)))/(1-betta*thetaw*mu_z^(eta*(1+gammma))*PI^(eta*(1-chiw)*(1+gammma)))...
-(eta-1)/eta*wstar/(varpsi*PIstarw^(-eta*gammma)*ld^gammma)*((1-h*mu_z^(-1))^(-1)-betta*h*(mu_z-h)^(-1))*...
((mu_A*mu_z^(-1)*vp^(-1)*tempvaromega^alppha-tempvaromega*(1-(1-delta)*(mu_z*mu_I)^(-1)))*ld-vp^(-1)*Phi)^(-1),0.25,options);
if exitflag <1
%indicate the SS computation was not sucessful; this would also be detected by Dynare
%setting the indicator here shows how to use this functionality to
%filter out parameter draws
check=1; %set failure indicator
return; %return without updating steady states
end
l=vw*ld;
k=tempvaromega*ld;
......@@ -68,27 +94,12 @@ g2=epsilon/(epsilon-1)*g1;
%% end own model equations
for iter = 1:length(M_.params)
for iter = 1:length(M_.params) %update parameters set in the file
eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names(iter,:) ';' ])
end
if isfield(M_,'param_nbr') == 1
if isfield(M_,'orig_endo_nbr') == 1
NumberOfEndogenousVariables = M_.orig_endo_nbr;
else
NumberOfEndogenousVariables = M_.endo_nbr;
end
ys = zeros(NumberOfEndogenousVariables,1);
for i = 1:NumberOfEndogenousVariables
varname = deblank(M_.endo_names(i,:));
eval(['ys(' int2str(i) ') = ' varname ';']);
end
else
ys=zeros(length(lgy_),1);
for i = 1:length(lgy_)
ys(i) = eval(lgy_(i,:));
end
check = 0;
NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables
varname = deblank(M_.endo_names(ii,:));
eval(['ys(' int2str(ii) ') = ' varname ';']);
end
/*
* Example 1 from F. Collard (2001): "Stochastic simulations with DYNARE:
* A practical guide" (see "guide.pdf" in the documentation directory).
*
* This file uses the steady_state_model-block to provide analytical steady state values.
* To do so, the equations of the model have been transformed into a non-linear equation in
* labor h. Within the steady_state_model-block, a helper function is called that uses fsolve
* to solve this non-linear equation. The use of the helper function is necessary to avoid
* interference of the Matlab syntax with Dynare's preprocessor. A more complicated alternative
* that provides more flexibility in the type of commands executed and functions called is the use
* of an explicit steady state file. See the NK_baseline.mod in the Examples Folder.
*
* This mod-file also shows how to use Dynare's capacities to generate TeX-files of the model equations.
* If you want to see the model equations belonging to this mod-file, run it using Dynare
* and then use a TeX-editor to compile the TeX-files generated.
*/
/*
* Copyright (C) 2013 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
var y, c, k, a, h, b;
varexo e, u;
parameters beta $\beta$
rho $\rho$
alpha $\alpha$
delta $\delta$
theta $\theta$
psi $\psi$
tau $\tau$;
alpha = 0.36;
rho = 0.95;
tau = 0.025;
beta = 0.99;
delta = 0.025;
psi = 0;
theta = 2.95;
phi = 0.1;
model;
c*theta*h^(1+psi)=(1-alpha)*y;
k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1)))
*(exp(b(+1))*alpha*y(+1)+(1-delta)*k));
y = exp(a)*(k(-1)^alpha)*(h^(1-alpha));
k = exp(b)*(y-c)+(1-delta)*k(-1);
a = rho*a(-1)+tau*b(-1) + e;
b = tau*a(-1)+rho*b(-1) + u;
end;
steady_state_model;
h=example3_steady_state_helper(alpha,beta,delta,psi,theta);
k=((1/beta-(1-delta))/alpha)^(1/(alpha-1))*h;
y = k^alpha*h^(1-alpha);
c=(1-alpha)*y/(theta*h^(1+psi));
a=0;
b=0;
end;
shocks;
var e; stderr 0.009;
var u; stderr 0.009;
var e, u = phi*0.009*0.009;
end;
//use command to generate TeX-Files with dynamic and static model equations
write_latex_dynamic_model;
write_latex_static_model;
stoch_simul;
function h=example3_steady_state_helper(alpha,beta,delta,psi,theta)
options=optimset('Display','Final','TolX',1e-10,'TolFun',1e-10);
h=fsolve(@(h)1- ((((((1/beta-(1-delta))/alpha)^(1/(alpha-1))*h)^(alpha-1))*(h^(1-alpha))-(((1-alpha)*((((1/beta-(1-delta))/alpha)^(1/(alpha-1)))^alpha))/(theta*h^psi))/(((1/beta-(1-delta))/alpha)^(1/(alpha-1))*h))+(1-delta)),0.2,options);
......@@ -87,6 +87,32 @@ var e_a; stderr 0.014;
var e_m; stderr 0.005;
end;
steady_state_model;
dA = exp(gam);
gst = 1/dA;
m = mst;
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
n = xist/(nust+xist);
P = xist + nust;
k = khst*n;
l = psi*mst*n/( (1-psi)*(1-n) );
c = mst/P;
d = l - mst + 1;
y = k^alp*n^(1-alp)*gst^alp;
R = mst/bet;
W = l/n;
ist = y-c;
q = 1 - d;
e = 1;
gp_obs = m/dA;
gy_obs = dA;
end;
steady;
check;
......
......@@ -23,7 +23,7 @@ separator = repmat(' | ',A.nobs+1,1);
vspace = ' ';
TABLE = ' ';
for t=1:A.nobs
TABLE = char(TABLE, format(A.dates(t)));
TABLE = char(TABLE, date2string(A.dates(t)));
end
for i = 1:A.vobs
TABLE = horzcat(TABLE,separator);
......
function A = mpower(B,C) % --*-- Unitary tests --*--
%@info:
%! @deftypefn {Function File} {@var{A} =} mpower (@var{B},@var{C})
%! @anchor{@dseries/mpower}
%! @sp 1
%! Overloads the mpower method for the Dynare time series class (@ref{dseries}).
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item B
%! Dynare time series object instantiated by @ref{dseries}, with T observations and N variables.
%! @item C
%! Real scalar or a dseries object with T observations and N variables.
%! @end table
%! @sp 1
%! @strong{Outputs}
%! @sp 1
%! @table @ @var
%! @item A
%! dseries object with T observations and N variables.
%! @end deftypefn
%@eod:
% Copyright (C) 2013 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if isdseries(B) && isnumeric(C) && isreal(C) && isscalar(C)
A = dseries();
A.freq = B.freq;
A.init = B.init;
A.dates = B.dates;
A.nobs = B.nobs;
A.vobs = B.vobs;
A.name = cell(A.vobs,1);
A.tex = cell(A.vobs,1);
for i=1:A.vobs
A.name(i) = {['power(' B.name{i} ',' num2str(C) ')']};
A.tex(i) = {[B.tex{i} '^' num2str(C) ]};
end
A.data = B.data.^C;
return
end
if isdseries(B) && isdseries(C)
if isequal(B.nobs,C.nobs) && isequal(B.vobs,C.vobs) && isequal(B.freq,C.freq)
A = dseries();
A.freq = B.freq;
A.init = B.init;
A.dates = B.dates;
A.nobs = B.nobs;
A.vobs = B.vobs;
A.name = cell(A.vobs,1);
A.tex = cell(A.vobs,1);
for i=1:A.vobs
A.name(i) = {['power(' B.name{i} ',' C.name{i} ')']};
A.tex(i) = {[B.tex{i} '^{' C.tex{i} '}']};
end
A.data = B.data.^C.data;
else
error('dseries::mpower: If both input arguments are dseries objects, they must have the same numbers of variables and observations and common frequency!')
end
return
end
error(['dseries::mpower: Wrong calling sequence!'])
%@test:1
%$ % Define a datasets.
%$ A = rand(10,2); B = randn(10,2);
%$
%$ % Define names
%$ A_name = {'A1';'A2'}; B_name = {'B1';'B2'};
%$
%$
%$ % Instantiate a time series object.
%$ try
%$ ts1 = dseries(A,[],A_name,[]);
%$ ts2 = dseries(B,[],B_name,[]);
%$ ts3 = ts1^ts2;
%$ t = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dyn_assert(ts3.vobs,2);
%$ t(3) = dyn_assert(ts3.nobs,10);
%$ t(4) = dyn_assert(ts3.data,A.^B,1e-15);
%$ t(5) = dyn_assert(ts3.name,{'power(A1,B1)';'power(A2,B2)'});
%$ t(6) = dyn_assert(ts3.tex,{'A1^{B1}';'A2^{B2}'});
%$ end
%$ T = all(t);
%@eof:1
%@test:2
%$ % Define a datasets.
%$ A = rand(10,2);
%$
%$ % Define names
%$ A_name = {'A1';'A2'};
%$
%$
%$ % Instantiate a time series object.
%$ try
%$ ts1 = dseries(A,[],A_name,[]);
%$ ts3 = ts1^2;
%$ t = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dyn_assert(ts3.vobs,2);
%$ t(3) = dyn_assert(ts3.nobs,10);
%$ t(4) = dyn_assert(ts3.data,A.^2,1e-15);
%$ t(5) = dyn_assert(ts3.name,{'power(A1,2)';'power(A2,2)'});
%$ t(6) = dyn_assert(ts3.tex,{'A1^2';'A2^2'});
%$ end
%$ T = all(t);
%@eof:2
\ No newline at end of file
......@@ -56,6 +56,7 @@ switch ndseries
end
hh = plot(ts.data);
end
axis tight;
id = get(gca,'XTick');
if isequal(id(1),0)
dates = strings([ts.dates(1)-1,ts.dates(id(2:end))]);
......
function DirectoryName = CheckPath(type,dname)
function [DirectoryName, info] = CheckPath(type,dname)
% Creates the subfolder "./M_.dname/type" if it does not exist yet.
%
% INPUTS
......@@ -6,12 +6,13 @@ function DirectoryName = CheckPath(type,dname)
% dname [string] Name of the directory
%
% OUTPUTS
% none.
% DirectoryName string, name of the directory (with path).
% info integer scalar, equal to 1 if the routine creates directory dname/type, zero otherwise.
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2005-2012 Dynare Team
% Copyright (C) 2005-2013 Dynare Team
%
% This file is part of Dynare.
%
......@@ -28,6 +29,8 @@ function DirectoryName = CheckPath(type,dname)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
info = 0;
DirectoryName = [ dname '/' type ];
if ~isdir(dname)
......@@ -44,4 +47,5 @@ if ~isdir(DirectoryName)
delete(DirectoryName)
end
mkdir('.',DirectoryName);
info = 1;
end
......@@ -107,7 +107,7 @@ if options.noprint == 0
if result
disp('The rank condition is verified.')
else
disp('The rank conditions ISN''T verified!')
disp('The rank condition ISN''T verified!')
end
skipline()
end
......@@ -22,16 +22,19 @@ if nargout>1
description = '';
end
%% Get informations about mcmc files.
if ~exist([ M_.dname '/metropolis'],'dir')
[MetropolisFolder, info] = CheckPath('metropolis',M_.dname);
% Get informations about mcmc files.
if info
disp('check_posterior_analysis_data:: Can''t find any mcmc file!')
return
end
mhname = get_name_of_the_last_mh_file(M_);
mhdate = get_date_of_a_file(mhname);
mhdate = get_date_of_a_file([MetropolisFolder filesep mhname]);
%% Get informations about _posterior_draws files.
drawsinfo = dir([ M_.dname '/metropolis/' M_.fname '_posterior_draws*.mat']);
% Get informations about _posterior_draws files.
drawsinfo = dir([ MetropolisFolder filesep M_.fname '_posterior_draws*.mat']);
if isempty(drawsinfo)
info = 1; % select_posterior_draws has to be called first.
if nargout>1
......@@ -40,8 +43,7 @@ if isempty(drawsinfo)
return
else
number_of_last_posterior_draws_file = length(drawsinfo);
pddate = get_date_of_a_file([ M_.dname '/metropolis/' M_.fname '_posterior_draws'...
int2str(number_of_last_posterior_draws_file) '.mat']);
pddate = get_date_of_a_file([ MetropolisFolder filesep M_.fname '_posterior_draws' int2str(number_of_last_posterior_draws_file) '.mat']);
if pddate<mhdate
info = 2; % _posterior_draws files have to be updated.
if nargout>1
......@@ -56,7 +58,7 @@ else
end
end
%% Get informations about posterior data files.
% Get informations about posterior data files.
switch type
case 'variance'
generic_post_data_file_name = 'Posterior2ndOrderMoments';
......@@ -69,7 +71,7 @@ switch type
otherwise
disp('This feature is not yest implemented!')
end
pdfinfo = dir([ M_.dname '/metropolis/' M_.fname '_' generic_post_data_file_name '*']);
pdfinfo = dir([ MetropolisFolder filesep M_.fname '_' generic_post_data_file_name '*']);
if isempty(pdfinfo)
info = 4; % posterior draws have to be processed.
if nargout>1
......@@ -79,8 +81,7 @@ if isempty(pdfinfo)
else
number_of_the_last_post_data_file = length(pdfinfo);
name_of_the_last_post_data_file = ...
[ pwd filesep M_.dname ...
filesep 'metropolis' filesep ...
[ pwd filesep MetropolisFolder filesep ...
M_.fname '_' ...
generic_post_data_file_name ...
int2str(number_of_the_last_post_data_file) ...
......
......@@ -130,13 +130,18 @@ if ~isempty(estim_params_) && ~isempty(options_.mode_file) && ~options_.mh_poste
number_of_estimated_parameters = length(xparam1);
mode_file = load(options_.mode_file);
if number_of_estimated_parameters>length(mode_file.xparam1)
% More estimated parameters than parameters in the mode file.
skipline()
disp(['The posterior mode file ' options_.mode_file ' has been generated using another specification of the model or another model!'])
disp(['Your mode file contains estimates for ' int2str(length(mode_file.xparam1)) ' parameters, while you are attempting to estimate ' int2str(number_of_estimated_parameters) ' parameters:'])
md = []; xd = [];
for i=1:number_of_estimated_parameters
id = strmatch(deblank(bayestopt_.name(i,:)),mode_file.parameter_names,'exact');
if isempty(id)
disp(['--> Estimated parameter ' bayestopt_.name{i} ' is not present in the loaded mod_file.'])
disp(['--> Estimated parameter ' bayestopt_.name{i} ' is not present in the loaded mode file (prior mean will be used, if possible).'])
else
xd = [xd; i];
md = [md; id];
end
end
for i=1:length(mode_file.xparam1)
......@@ -145,20 +150,30 @@ if ~isempty(estim_params_) && ~isempty(options_.mode_file) && ~options_.mh_poste
disp(['--> Parameter ' mode_file.parameter_names{i} ' is not estimated according to the current mod file.'])
end
end
error('Please change the mode_file option or the list of estimated parameters.')
if ~options_.mode_compute
% The posterior mode is not estimated.
error('Please change the mode_file option, the list of estimated parameters or set mode_compute>0.')
else
% The posterior mode is estimated, the Hessian evaluated at the mode is not needed so we set values for the parameters missing in the mode file using the prior mean.
if ~isempty(xd)
xparam1(xd) = mode_file.xparam1(md);
else
error('Please remove the mode_file option.')
end
end
elseif number_of_estimated_parameters<length(mode_file.xparam1)
% Less estimated parameters than parameters in the mode file.
skipline()
disp(['The posterior mode file ' options_.mode_file ' has been generated using another specification of the model or another model!'])
disp(['Your mode file contains estimates for ' int2str(length(mode_file.xparam1)) ' parameters, while you are attempting to estimate only ' int2str(number_of_estimated_parameters) ' parameters:'])
Id = [];
md = []; xd = [];
for i=1:number_of_estimated_parameters
id = strmatch(deblank(bayestopt_.name(i,:)),mode_file.parameter_names,'exact');
if isempty(id)
disp(['--> Estimated parameter ' deblank(bayestopt_.name(i,:)) ' is not present in the loaded mode file.'])
Id = [];
break
disp(['--> Estimated parameter ' deblank(bayestopt_.name(i,:)) ' is not present in the loaded mode file (prior mean will be used, if possible).'])
else
Id = [Id; id];
xd = [xd; i];
md = [md; id];
end
end
for i=1:length(mode_file.xparam1)
......@@ -167,59 +182,72 @@ if ~isempty(estim_params_) && ~isempty(options_.mode_file) && ~options_.mh_poste
disp(['--> Parameter ' mode_file.parameter_names{i} ' is not estimated according to the current mod file.'])
end
end
if isempty(Id)
% None of the estimated parameters are present in the mode_file.
error('Please change the mode_file option or the list of estimated parameters.')
else
% If possible, fix the mode_file.
if isequal(length(Id),number_of_estimated_parameters)
if ~options_.mode_compute
% The posterior mode is not estimated. If possible, fix the mode_file.
if isequal(length(xd),number_of_estimated_parameters)
disp('==> Fix mode file (remove unused parameters).')
mode_file.parameter_names = mode_file.parameter_names(Id,:);
mode_file.xparam1 = mode_file.xparam1(Id);
xparam1 = mode_file.xparam1(md);
if isfield(mode_file,'hh')
mode_file.hh = mode_file.hh(Id,Id);
hh = mode_file.hh(md,md);
end
else
error('Please change the mode_file option, the list of estimated parameters or set mode_compute>0.')
end
else
% The posterior mode is estimated, the Hessian evaluated at the mode is not needed so we set values for the parameters missing in the mode file using the prior mean.
if ~isempty(xd)
xparam1(xd) = mode_file.xparam1(md);
else
% None of the estimated parameters are present in the mode_file.
error('Please remove the mode_file option.')
end
end
else
% The number of declared estimated parameters match the number of parameters in the mode file.
% Check that the parameters in the mode file and according to the current mod file are identical.
if isequal(mode_file.parameter_names, bayestopt_.name)
% Ok! Nothing to do here.
xparam1 = mode_file.xparam1;
if isfield(mode_file,'hh')
hh = mode_file.hh;
end
else
skipline()
disp(['The posterior mode file ' options_.mode_file ' has been generated using another specification of the model or another model!'])
% Check if this only an ordering issue.
Id = [];
% Check if this only an ordering issue or if the missing parameters can be initialized with the prior mean.
md = []; xd = [];
for i=1:number_of_estimated_parameters
id = strmatch(deblank(bayestopt_.name(i,:)), mode_file.parameter_names,'exact');
if isempty(id)
disp(['--> Estimated parameter ' bayestopt_.name{i} ' is not present in the loaded mode file.'])
Id = [];
break
else
Id = [Id; id];
xd = [xd; i];
md = [md; id];
end
end
if isempty(Id)
% None of the estimated parameters are present in the mode_file.
error('Please change the mode_file option or the list of estimated parameters.')
else
% If possible, fix the mode_file.
if isequal(length(Id),number_of_estimated_parameters)
disp('==> Fix mode file (reorder the parameters).')
mode_file.parameter_names = mode_file.parameter_names(Id,:);
mode_file.xparam1 = mode_file.xparam1(Id);
if ~options_.mode_compute
% The posterior mode is not estimated
if isequal(length(xd), number_of_estimated_parameters)
% This is an ordering issue.
xparam1 = mode_file.xparam1(md);
if isfield(mode_file,'hh')
mode_file.hh = mode_file.hh(Id,Id);
hh = mode_file.hh(md,md);
end
else
error('Please change the mode_file option, the list of estimated parameters or set mode_compute>0.')
end
else
% The posterior mode is estimated, the Hessian evaluated at the mode is not needed so we set values for the parameters missing in the mode file using the prior mean.
if ~isempty(xd)
xparam1(xd) = mode_file.xparam1(md);
if isfield(mode_file,'hh')
hh(xd,xd) = mode_file.hh(md,md);
end
else
% None of the estimated parameters are present in the mode_file.
error('Please remove the mode_file option.')
end
end
end
xparam1 = mode_file.xparam1;
if isfield(mode_file,'hh')
hh = mode_file.hh;
end
skipline()
end
......
......@@ -207,15 +207,23 @@ else
name_tex = [cellstr(M_.exo_names_tex); cellstr(M_.param_names_tex)];
end
skipline()
disp(['==== Identification analysis ====' ]),
skipline()
if nparam<2,
options_ident.advanced=0;
advanced = options_ident.advanced;
disp('There is only one parameter to study for identitification.')
disp('The advanced option is re-set to 0.')
skipline()
end
options_ident = set_default_option(options_ident,'max_dim_cova_group',min([2,nparam-1]));
options_ident.max_dim_cova_group = min([options_ident.max_dim_cova_group,nparam-1]);
MaxNumberOfBytes=options_.MaxNumberOfBytes;
store_options_ident = options_ident;
skipline()
disp(['==== Identification analysis ====' ]),
skipline()
if iload <=0,
......@@ -326,6 +334,8 @@ if iload <=0,
disp('----------- ')
skipline()
return
else
parameters = 'Random_prior_params';
end
else
idehess_point.params=params;
......@@ -336,6 +346,7 @@ if iload <=0,
% normJ = max(abs(siJ)')';
% normLRE = max(abs(siLRE)')';
save([IdentifDirectoryName '/' M_.fname '_identif.mat'], 'idehess_point', 'idemoments_point','idemodel_point', 'idelre_point','store_options_ident')
save([IdentifDirectoryName '/' M_.fname '_' parameters '_identif.mat'], 'idehess_point', 'idemoments_point','idemodel_point', 'idelre_point','store_options_ident')
disp_identification(params, idemodel_point, idemoments_point, name, advanced);
if ~options_.nograph,
plot_identification(params,idemoments_point,idehess_point,idemodel_point,idelre_point,advanced,parameters,name,IdentifDirectoryName);
......
......@@ -281,10 +281,12 @@ if options_gsa.redform && ~isempty(options_gsa.namendo),% ...
% check existence of the SS_ANOVA toolbox
if isempty(options_gsa.threshold_redform) && ...
~(exist('gsa_sdp','file')==6 || exist('gsa_sdp','file')==2),
disp('Download Mapping routines at:')
disp('http://eemc.jrc.ec.europa.eu/softwareDYNARE-Dowload.htm')
disp(' ' )
error('Mapping routines missing!')
fprintf('\nThe "SS-ANOVA-R: MATLAB Toolbox for the estimation of Smoothing Spline ANOVA models with Recursive algorithms" is missing.\n')
fprintf('To obtain it, go to:\n\n')
fprintf('http://ipsc.jrc.ec.europa.eu/?id=790 \n\n')
fprintf('and follow the instructions there.\n')
fprintf('After obtaining the files, you need to unpack them and set a Matlab Path to those files.\n')
error('SS-ANOVA-R Toolbox missing!')
end
redform_map(OutputDirectoryName,options_gsa);
......