diff --git a/Archive.bat b/Archive.bat index fe97bea..360479e 100644 --- a/Archive.bat +++ b/Archive.bat @@ -1,10 +1,11 @@ del *.zip :: Create dolo-matlab executable for Windows -pyinstaller.py --onefile --out=pyinstaller --paths=.\Python\dolo .\Python\dolo\bin\dolo-matlab -copy /Y pyinstaller\dist\dolo-matlab.exe Python\dolo\bin -rmdir /S /Q pyinstaller -del *.log +pyinstaller --onefile --clean --paths=.\Python\dolo .\Python\dolo\bin\dolo-matlab +copy /Y dist\dolo-matlab.exe Python\dolo\bin +rmdir /S /Q dist +rmdir /S /Q build +del *.spec :: Create empty folders md recs-archive @@ -12,21 +13,23 @@ md recs-archive\private md recs-archive\html md recs-archive\demos md recs-archive\Python +md recs-archive\recipes :: Generate RECS documentation cd html -matlab -wait -nosplash -r addpath('%1');startup;Publish_recs_help;exit +matlab -wait -nosplash -r addpath('%1');startup;Publish_recs_help;clear;Publish_recs_help(1);exit cd .. :: Convert README.md to html -Markdown.pl README.md > README.html +pandoc README.md -s -o README.html :: Copy all files copy /Y . recs-archive copy /Y private recs-archive\private robocopy html recs-archive\html /E copy /Y demos recs-archive\demos -robocopy Python recs-archive\Python /E +robocopy Python\dolo recs-archive\Python\dolo /E +copy /Y recipes recs-archive\recipes :: Clean the files and compress cd recs-archive diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..35829aa --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,32 @@ +# Changelog + +## [0.7] + +### Added +- Extract information about variable names to be used in tables and figures. +- Length of burn-in period can be chosen by the user. +- New model type with subperiods (not yet documented). +- New mcp solver: `mcpsolve` + +### Changed +- Change the convention for YAML files. +- Change the structure of recsmodel objects. +- Update installation instructions for Python dependencies. +- Use MATLAB table for display. + +### Removed +- Remove small-country storage example (sto5). + +## Older versions + +See [release notes](https://github.com/christophe-gouel/RECS/wiki/Release-Notes) +for older versions or refer to commit messages for more information: + +[0.6]: https://github.com/christophe-gouel/RECS/compare/v0.5.1...v0.6 +[0.5.1]: https://github.com/christophe-gouel/RECS/compare/v0.5...v0.5.1 +[0.5]: https://github.com/christophe-gouel/RECS/compare/v0.4...v0.5 +[0.4]: https://github.com/christophe-gouel/RECS/compare/v0.3.2...v0.4 +[0.3.2]: https://github.com/christophe-gouel/RECS/compare/v0.3.1...v0.3.2 +[0.3.1]: https://github.com/christophe-gouel/RECS/compare/v0.3...v0.3.1 +[0.3]: https://github.com/christophe-gouel/RECS/compare/v0.2...v0.3 +[0.2]: https://github.com/christophe-gouel/RECS/compare/v0.1...v0.2 diff --git a/Contents.m b/Contents.m index aaaa719..49ff2fe 100644 --- a/Contents.m +++ b/Contents.m @@ -1,28 +1,37 @@ % RECS Toolbox -% Version 0.7-beta (R2016a) 2-Jun-2016 +% Version 0.7 (R2017b) 4-Jan-2018 % % RECS functions % recsAccuracy - Evaluate accuracy of a RECS solution. +% recsAccuracySP - Evaluate accuracy of a RECS solution for models with subperiods. +% recsAuxiliary - Calculates auxiliary variables not included in the core model. % recsCheck - Check analytical derivatives against numerical ones. % recsConvert - Convert the interpolation structure of a model to another form. -% recsDecisionRules - Plot a model decision rules +% recsDecisionRules - Plot a model decision rules. % recsdemos - Run all RECS demonstration files. -% recsFirstGuess - Find a first guess using the perfect foresight solution or the first-order approximation of the model +% recsFirstGuess - Find a first guess using the perfect foresight solution or the first-order approximation of the model. +% recsFirstGuessSP - Find a first guess for models with subperiods. % recsinterpinit - Prepare a RECS interpolation structure. % recsmodel - Prepare a RECS model object. +% recsmodelsp - Prepare a RECS model object for models with subperiods. % recsSimul - Simulate a model. +% recsSimulSP - Simulate a model with subperiods. % recsSolveDeterministicPb - Solve a perfect foresight problem. -% recsSolveLocal - Calculate the first-order perturbation solution +% recsFirstGuessSP - Find a first guess for models with subperiods. +% recsSolveLocal - Calculate the first-order perturbation solution. % recsSolveREE - Find the rational expectations equilibrium (REE) of a model. +% recsSolveREESP - Find the rational expectations equilibrium (REE) of a model with subperiods. % recsSolveREEFiniteHorizon - Solve a finite horizon rational expectations problem. % recsSS - Solve for the deterministic steady state of a model. +% recsSSSP - Solve for the deterministic steady state of a model with subperiods. % % Nonlinear equations and MCP solvers included in RECS % lmmcp - Solve mixed complementarity problems. +% mcpsolve - Solve mixed complementarity problems. % nsoli - Solve system of nonlinear equations by a Jacobian-free Newton-Krylov solver. % recspathmcp - Solve mixed complementarity problems (require the installation of Path). % SA - Solve a system of equations by successive approximation. -% SCP - Solve a problem through simple continuation method (homotopy) +% SCP - Solve a problem through simple continuation method (homotopy). -% Copyright (C) 2011-2016 Christophe Gouel +% Copyright (C) 2011-2018 Christophe Gouel % Licensed under the Expat license, see LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt index 08e33fd..e698209 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,8 +1,8 @@ Format: http://dep.debian.net/deps/dep5/ -Upstream-Contact: Christophe Gouel +Upstream-Contact: Christophe Gouel Files: * -Copyright: 2011-2016, Christophe Gouel +Copyright: 2011-2018, Christophe Gouel License: Expat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the diff --git a/Python/dolo b/Python/dolo index 9087806..d9aef6d 160000 --- a/Python/dolo +++ b/Python/dolo @@ -1 +1 @@ -Subproject commit 90878064a8dd3f88d6f75713d8ffff1169080656 +Subproject commit d9aef6d78d19899e2669e49ee6b7ad9aacf0e35d diff --git a/README.md b/README.md index 39693ab..393e2c6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -RECS toolbox Version 0.7-beta -============================= +RECS toolbox Version 0.7 +======================== A MATLAB solver for nonlinear, dynamic, stochastic, rational expectations equilibrium models. RECS stands for "Rational Expectations Complementarity @@ -7,16 +7,16 @@ Solver". This name emphasizes that RECS has been developed specifically to solve models that include complementarity equations, also known as models with occasionally binding constraints. -[Christophe Gouel](http://www.christophegouel.com) () +[Christophe Gouel](http://www.christophegouel.com) () **Main page is at**: [www.recs-solver.org](http://www.recs-solver.org). ## Download RECS Toolbox zip archives are available at -[https://github.com/christophe-gouel/RECS/releases](https://github.com/christophe-gouel/RECS/releases). +. -Why is this archive 12 MB? Much of this size is due to an executable for +Why is this archive 20 MB? Much of this size is due to an executable for Windows. The executable file includes a complete Python distribution necessary to parse RECS model files. diff --git a/demos/Contents.m b/demos/Contents.m index bc13a06..0f1ce7b 100644 --- a/demos/Contents.m +++ b/demos/Contents.m @@ -14,6 +14,7 @@ % STO4 Competitive storage with price-band backed by public storage % STO5 Two-country storage-trade model % STO6 Quarterly storage model with annual inelastic supply +% STO6SP Variant of STO6: Quarterly storage model with informational subperiods and annual inelastic supply -% Copyright (C) 2011-2013 Christophe Gouel +% Copyright (C) 2011-2018 Christophe Gouel % Licensed under the Expat license, see LICENSE.txt diff --git a/demos/sto1sp.m b/demos/sto1sp.m deleted file mode 100644 index 9ad5e9f..0000000 --- a/demos/sto1sp.m +++ /dev/null @@ -1,26 +0,0 @@ -model = recsmodelsp({'sto1sp.yaml'}); - -params = num2cell(model.params); -[k, delta, r, h, mu, elastD, elastS] = params{:}; - -sigma = {0.05}; -n = {40}; -smin = {0.7}; -smax = {1.5}; -for iperiod=1:model.nperiods - %% Shocks - [model.shocks(iperiod).e,model.shocks(iperiod).w] = qnwnorm(5,1,sigma{iperiod}); - model.shocks(iperiod).funrand = @(nrep) randn(nrep,1)*sigma{1}; - - %% Interpolation structure - interp.fspace{iperiod} = fundefn('spli',n{iperiod},smin{iperiod},smax{iperiod}); - interp.Phi{iperiod} = funbasx(interp.fspace{iperiod}); - interp.s{iperiod} = gridmake(funnode(interp.fspace{iperiod})); -end - -s = interp.s{1}; -x = [zeros(size(s,1),1) ones(size(s,1),1) s.^(1/elastD)]; - -X = {x}; - -[interp,X] = recsSolveREESP(model,interp,X) \ No newline at end of file diff --git a/demos/sto1sp.yaml b/demos/sto1sp.yaml deleted file mode 100644 index 2babb6c..0000000 --- a/demos/sto1sp.yaml +++ /dev/null @@ -1,60 +0,0 @@ -model_type: fghp - -declarations: - - states: [A] - - controls: [S, H, P] - - expectations: [EP, EPe] - - statesnext: [An] - - controlsnext: [Sn, Hn, Pn] - - shocks: [e] - - parameters: [k, delta, r, h, mu, elastD, elastS] - - -equations: - - arbitrage: - - - P+k-EP*(1-delta)/(1+r) | 0 <= S <= inf - - EPe/(1+r) = h*H^mu | -inf <= H <= inf - - A = P^elastD+S | -inf <= P <= inf - - transition: - - - An = (1-delta)*S(-1)+H(-1)*e - - expectation: - - - EP = Pn(1) - - EPe = Pn(1)*e(1) - - -calibration: - - parameters: - - k : 0.06 - delta : 0.02 - r : 0.03 - elastS : 0.2 - h : 1/(1+r) - mu : 1/elastS - elastD : -0.2 - - steady_state: - - A : 1 - S : 0 - H : 1 - P : 1 - An : 1 - Sn : 0 - Hn : 1 - Pn : 1 - diff --git a/demos/sto6SP.m b/demos/sto6SP.m index 2125644..cb8eea6 100644 --- a/demos/sto6SP.m +++ b/demos/sto6SP.m @@ -57,8 +57,10 @@ [interp,X] = recsSolveREESP(model,interp,{x1; x2; x3; x4}); %% Compare STO6 and STO6SP when informational shocks are removed -disp('Max absolute error in first subperiod storage and price (in log10)'); -disp(log10(max(abs(Xcat(:,[1 5])-X{1})))); +if exist('Xcat','var') + disp('Max absolute error in first subperiod storage and price (in log10)'); + disp(log10(max(abs(Xcat(:,[1 5])-X{1})))); +end %% Introduced information shocks sigma = [0.05/sqrt(3) eps 0.05/sqrt(3) 0.05/sqrt(3)]; diff --git a/html/Publish_recs_help.m b/html/Publish_recs_help.m index 9c8b066..967ee7e 100644 --- a/html/Publish_recs_help.m +++ b/html/Publish_recs_help.m @@ -1,7 +1,7 @@ function Publish_recs_help(website) % PUBLISH_RECS_HELP publishes help pages to html -% Copyright (C) 2011-2013 Christophe Gouel +% Copyright (C) 2011-2018 Christophe Gouel % Licensed under the Expat license, see LICENSE.txt %% Initialization @@ -93,34 +93,49 @@ function Publish_recs_help(website) txt = regexprep(txt,pattern,'"$1.html"'); pattern = '"matlab:doc\(''recsmodel.recsmodel''\)"'; txt = regexprep(txt,pattern,'"recsmodel.html"'); + pattern = '"matlab:doc\(''recsmodelsp.recsmodelsp''\)"'; + txt = regexprep(txt,pattern,'"recsmodelsp.html"'); fid = fopen(fullfile(targetdirectory,htmlfilelist(i,:)),'w'); fprintf(fid,'%s',txt); fclose(fid); end FunctionList = {'recsAccuracy',... + 'recsAccuracySP',... 'recsAuxiliary',... 'recsCheck',... 'recsConvert',... 'recsDecisionRules',... 'recsdemos',... 'recsFirstGuess',... + 'recsFirstGuessSP',... 'recsinterpinit',... 'recsmodel',... + 'recsmodelsp',... 'recsSimul',... + 'recsSimulSP',... 'recsSolveDeterministicPb',... + 'recsSolveDeterministicPbSP',... 'recsSolveLocal',... 'recsSolveREE',... + 'recsSolveREESP',... 'recsSolveREEFiniteHorizon',... 'recsSS',... + 'recsSSSP',... 'lmmcp',... + 'mcpsolve'... 'nsoli',..., 'recspathmcp',... 'SA',... 'SCP'}; for fn = FunctionList - if ~strcmp(fn{1},'recsmodel'), FunctionName = fn{1}; - else, FunctionName = 'recsmodel.recsmodel'; + switch fn{1} + case 'recsmodel' + FunctionName = 'recsmodel.recsmodel'; + case 'recsmodelsp' + FunctionName = 'recsmodelsp.recsmodelsp'; + otherwise + FunctionName = fn{1}; end copyfile(fullfile(recsdirectory,[fn{1} '.m']),fullfile(targetdirectory,[fn{1} '.m'])); txt = help2html(FunctionName); @@ -130,6 +145,9 @@ function Publish_recs_help(website) % Replace recsmodel/recsmodel pattern = 'recsmodel/recsmodel'; txt = strrep(txt,pattern,'recsmodel'); + % Replace recsmodelsp/recsmodelsp + pattern = 'recsmodelsp/recsmodelsp'; + txt = strrep(txt,pattern,'recsmodelsp'); % Replace view code pattern = '"matlab:edit (\w*)"'; txt = regexprep(txt,pattern,[fn{1} '.m']); @@ -157,13 +175,14 @@ function Publish_recs_help(website) currentfolder = cd(fullfile(recsdirectory,'demos')); DemoFileList = {'cs1','cs2','gro1','gro2','gro3',... - 'sto1','sto2','sto3','sto4','sto5'}; + 'sto1','sto2','sto3','sto4','sto5','sto6','sto6SP'}; for demo=DemoFileList publish('clearpublish.m',PublishOptions); reset(stream); publish([demo{1} '.m'],PublishOptions); end -YamlFileList = {'cs1','gro1','gro2','gro3','sto1','sto2','sto4','sto5'}; +YamlFileList = {'cs1','gro1','gro2','gro3','sto1','sto2','sto4','sto5',... + 'sto6','sto6SP1','sto6SP2','sto6SP3','sto6SP4'}; for yaml=YamlFileList copyfile([yaml{1} '.yaml'],fullfile(targetdirectory,[yaml{1} '.txt'])); publish([yaml{1} 'model.m'],PublishOptionsNoExec); diff --git a/html/demos.m b/html/demos.m index 1af50e2..9ee79e8 100644 --- a/html/demos.m +++ b/html/demos.m @@ -28,3 +28,7 @@ % * % % * +% +% * +% +% * diff --git a/html/helptoc.xml b/html/helptoc.xml index 01e7706..a0bbc52 100644 --- a/html/helptoc.xml +++ b/html/helptoc.xml @@ -1,6 +1,6 @@ - + RECS @@ -56,6 +56,8 @@ Anticipated switch to a public storage policy Competitive storage with price-band backed by public storage Two-country storage-trade model with supply reaction, fixed tariffs + Quarterly storage model with annual inelastic supply + Variant of sto6: Quarterly storage model with informational subperiods and annual inelastic supply diff --git a/html/installation.m b/html/installation.m index b5e2204..0fec14d 100644 --- a/html/installation.m +++ b/html/installation.m @@ -3,7 +3,7 @@ %% Download % RECS Toolbox zip archives are available at . % -% Why is this archive 12 MB? Much of this size is due to an executable for +% Why is this archive 20 MB? Much of this size is due to an executable for % Windows. The executable file includes a complete Python distribution % necessary to parse RECS model files. @@ -72,6 +72,11 @@ % where |/usr/bin/python2.7| should be replaced by the address of your Python % 2.7.X interpreter. % +% Alternatively, if your Python distribution is Anaconda, you can create from +% RECS folder the virtual environment by +% +% conda create -p ./Python/PythonVirtualEnv python=2.7 numpy PyYAML sympy==0.7.2 +% % *Install them in your default Python installation.* % % Recommended only if you do not use Python otherwise. In this case, just type diff --git a/html/recs_functions.m b/html/recs_functions.m index a799ad2..82eec3a 100644 --- a/html/recs_functions.m +++ b/html/recs_functions.m @@ -3,6 +3,10 @@ %% RECS functions % * - Evaluate accuracy % of a RECS solution +% * - Evaluate accuracy +% of a RECS solution for models with subperiods +% * - Calculates auxiliary variables not included in the core model +% of a RECS solution for models with subperiods % * - Check analytical derivatives against % numerical ones % * - Convert the @@ -12,23 +16,35 @@ % * - Run all RECS demonstration files % * - Find a first guess using the % perfect foresight solution or the first-order approximation of the model +% * - Find a first guess for +% models with subperiods % * - Prepare a RECS % interpolation structure % * - Prepare a RECS model object +% * - Prepare a RECS model object for +% models with subperiods % * - Simulate a model +% * - Simulate a model with subperiods % * - Solve a % perfect foresight problem +% * - Solve a +% perfect foresight problem with subperiods % * - Find the rational expectations % equilibrium (REE) of a model +% * - Find the rational expectations +% equilibrium (REE) of a model with subperiods % * - % Solve a finite horizon rational expectations problem % * - Solve for the deterministic % steady state of a model +% * - Solve for the deterministic +% steady state of a model with subperiods %% Nonlinear equations and MCP solvers that can be used with RECS % * - Solve system of nonlinear % equations (from MATLAB Optimization Toolbox) % * - Solve mixed complementarity problems +% * - Solve mixed complementarity problems % * - Solve mixed complementarity problems % (from CompEcon) % * - Solve system of nonlinear diff --git a/html/recs_product_page.m b/html/recs_product_page.m index 262451e..1b6fc32 100644 --- a/html/recs_product_page.m +++ b/html/recs_product_page.m @@ -1,4 +1,4 @@ -%% RECS toolbox Version 0.7-beta +%% RECS toolbox Version 0.7 % RECS is a MATLAB solver for dynamic, stochastic, rational expectations % equilibrium models. RECS stands for "Rational Expectations Complementarity % Solver". This name emphasizes that RECS has been developed specifically to @@ -22,7 +22,7 @@ % * % * % -% Release notes are available at . +% Changelog is available at . % % %

License

diff --git a/html/simulate.m b/html/simulate.m index 91d917f..913c847 100644 --- a/html/simulate.m +++ b/html/simulate.m @@ -28,14 +28,15 @@ % shock discretization, using the associated probabilities. % % To reproduce previously run results, it is necessarily to reset the random -% number generator using the MATLAB function |reset|. +% number generator using the MATLAB function |rng|. % % *Asymptotic statistics* % % If in the options the field |stat| is set to 1, or if four arguments are % required as the output of |recsSimul|, then some statistics over the % asymptotic distribution are calculated. The first 20 observations are -% discarded. The statistics calculated are the mean, standard deviation, +% discarded (the number of burn-in observations can be adjusted in the +% options). The statistics calculated are the mean, standard deviation, % skewness, kurtosis, minimum, maximum, percentage of time spent at the lower % and upper bounds, correlation matrix, and the five first-order autocorrelation % coefficients. In addition, |recsSimul| draws the histograms of the variables @@ -45,11 +46,6 @@ % |recsSimul|: % % [ssim,xsim,esim,stat] = recsSimul(model,interp,s0,nper); -% -% Since RECS does not retain the variable names, when displaying the statistics, -% the variables are organized as follows: first state variables, followed by -% response variables, both of which follow the order of their definition in the -% Yaml file. %% Choice of simulation techniques % There are two main approaches to simulate the model once an approximated diff --git a/html/ug_model_files.m b/html/ug_model_files.m index 1032717..7e69388 100644 --- a/html/ug_model_files.m +++ b/html/ug_model_files.m @@ -128,12 +128,7 @@ % * *Lead/Lag:* Lead variables are indicated |X(1)| and lag variables |X(-1)|. % * *Timing convention:* Transition equations are written by defining the new % state variable at current time as a function of lagged response and state -% variables: $s_t = g(s_{t-1},x_{t-1},e_t)$. Even if expectations are defined by -% $z_{t} = \mathrm{E}_{t}\left[h(s_{t},x_{t},e_{t+1},s_{t+1},x_{t+1})\right]$, -% when writing them in a Yaml file the shocks are not indicated with a -% lead. This can be seen in the competitive storage model example () where the expectations $P_{t+1}\epsilon_{t+1}$ is written as |EPe = -% P(1)*e|. +% variables: $s_t = g(s_{t-1},x_{t-1},e_t)$. % * Do not use |lambda| as a variable/parameter name, this is a restricted word. % * Write equations in the same order as the order of variables declaration. % * Yaml files are case sensitive. diff --git a/html/ug_model_struct.m b/html/ug_model_struct.m index 880f534..937f2ec 100644 --- a/html/ug_model_struct.m +++ b/html/ug_model_struct.m @@ -22,9 +22,10 @@ % definition in a MATLAB readable form but also all the derivatives of the % equations, plus some additional information such as the parameters values for % calibration or a first guess for the steady state. -% * It creates in MATLAB workspace the object |model| with two fields: the -% function name, |func| equal to |@filemodel|, and the parameters values, -% |params|, if these latter have been provided in the Yaml file. +% * It creates in MATLAB workspace the object |model| with several fields: for +% example, |functions| which contains all the model functions, and the +% parameters values, |params|, if these latter have been provided in the Yaml +% file. %% Shocks with a Gaussian distribution % If your shocks follow a Gaussian distribution, you can also define their @@ -55,14 +56,6 @@ % function call in is: model = recsmodel('gro1.yaml',... struct('Mu',0,'Sigma',0.007^2,'order',5)); -%% -% It is *important to notice* that variables names are not displayed here and -% will not be displayed in subsequent steps. Variable names are used only in the -% symbolic model definition in the Yaml file. Once the Yaml file has been -% processed, variables are merely ordered based on their original order in the -% Yaml file. In this case, it means that, in the steady-state results above, for -% the state variables the first number is capital and the second is the log of -% productivity. %% % The model object has the following properties: diff --git a/html/ug_options.m b/html/ug_options.m index 3184e92..6d43c1a 100644 --- a/html/ug_options.m +++ b/html/ug_options.m @@ -120,11 +120,16 @@ % % recsSimul, recsSolveREE % +% % T % integer defining the time horizon at which the model is supposed to % converge to its steady state (default: 50) % recsFirstGuess +% % +% Tburn +% integer defining the number of observations discarded as burn-in period (default: 20) +% recsSimul % % % diff --git a/html/ug_solvers_eq.m b/html/ug_solvers_eq.m index 31c41d2..41267e8 100644 --- a/html/ug_solvers_eq.m +++ b/html/ug_solvers_eq.m @@ -13,7 +13,7 @@ % documentation for how to manage options. %% MCP solvers -% Three MCP solvers can be used with RECS of which two are available by +% Four MCP solvers can be used with RECS of which three are available by % default. % % *|lmmcp|* @@ -21,6 +21,12 @@ % |lmmcp| is RECS default solver (for both MCP and traditional % nonlinear problems). It is included in RECS files. % +% *|mcpsolve|* +% +% |mcpsolve| is a faster implementation of |ncpsolve| from the CompEcon +% toolbox. It is a simple MCP solver that will be very fast on simple problems +% but that may lack robustness. +% % *|ncpsolve|* % % |ncpsolve| comes with the CompEcon toolbox, which has to be installed for RECS @@ -42,5 +48,5 @@ %% See also % , , -% , . +% , , +% . diff --git a/info.xml b/info.xml index 06a4852..3b3053a 100644 --- a/info.xml +++ b/info.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="optional"> - 2016a + 2017b RECS toolbox diff --git a/recsSS.m b/recsSS.m index afec8fa..39b0d95 100644 --- a/recsSS.m +++ b/recsSS.m @@ -34,7 +34,7 @@ % 1 : RECSSS converges to the deterministic steady state % 0 : Failure to converge -% Copyright (C) 2011-2016 Christophe Gouel +% Copyright (C) 2011-2018 Christophe Gouel % Licensed under the Expat license, see LICENSE.txt %% Initialization @@ -104,13 +104,22 @@ fprintf(1,['Deterministic steady state (different from first guess, ' ... 'max(|delta|)=%g)\n'],deltass) end - fprintf(1,' State variables:\n\t\t') - fprintf(1,'%0.4g\t',s) - fprintf(1,'\n\n Response variables:\n\t\t') - fprintf(1,'%0.4g\t',x) - fprintf(1,'\n\n Expectations variables:\n\t\t') - fprintf(1,'%0.4g\t',z) - fprintf(1,'\n\n') + if exist('table','file') + fprintf(1,' State variables:\n') + disp(array2table(s,'VariableNames',model.symbols.states)) + fprintf(1,' Response variables:\n') + disp(array2table(x,'VariableNames',model.symbols.controls)) + fprintf(1,' Expectations variables:\n') + disp(array2table(z,'VariableNames',model.symbols.expectations)) + else + fprintf(1,' State variables:\n\t\t') + fprintf(1,'%0.4g\t',s) + fprintf(1,'\n\n Response variables:\n\t\t') + fprintf(1,'%0.4g\t',x) + fprintf(1,'\n\n Expectations variables:\n\t\t') + fprintf(1,'%0.4g\t',z) + fprintf(1,'\n\n') + end end diff --git a/recsSSSP.m b/recsSSSP.m index 2fad77a..aefb446 100644 --- a/recsSSSP.m +++ b/recsSSSP.m @@ -30,7 +30,7 @@ % 1 : RECSSSSP converges to the deterministic steady state % 0 : Failure to converge -% Copyright (C) 2011-2016 Christophe Gouel +% Copyright (C) 2011-2018 Christophe Gouel % Licensed under the Expat license, see LICENSE.txt %% Initialization @@ -122,11 +122,22 @@ fprintf(1,['Deterministic steady state (different from first guess, ' ... 'max(|delta|)=%g)\n'],deltass) end - fprintf(1,' State variables:\n\t\t') - fprintf(1,'%0.4g\t',cat(2,s{:})) - fprintf(1,'\n\n Response variables:\n\t\t') - fprintf(1,'%0.4g\t',cat(2,x{:})) - fprintf(1,'\n\n Expectations variables:\n\t\t') + if exist('table','file') + symbols = struct2cell(model.symbols); + symbols = cat(2,symbols{1,:,:},symbols{2,:,:}); + D = sum(cell2mat(model.dim(:,1))); + fprintf(1,' State variables:\n') + disp(array2table(cat(2,s{:}),'VariableNames',symbols(1:D))) + fprintf(1,' Response variables:\n') + disp(array2table(cat(2,x{:}),'VariableNames',symbols(D+1:end))) + else + fprintf(1,' State variables:\n\t\t') + fprintf(1,'%0.4g\t',cat(2,s{:})) + fprintf(1,'\n\n Response variables:\n\t\t') + fprintf(1,'%0.4g\t',cat(2,x{:})) + fprintf(1,'\n\n') + end + fprintf(1,' Expectations variables:\n\t\t') fprintf(1,'%0.4g\t',cat(2,z{:})) fprintf(1,'\n\n') end diff --git a/recsSimul.m b/recsSimul.m index 6481e52..926f9f6 100644 --- a/recsSimul.m +++ b/recsSimul.m @@ -58,7 +58,7 @@ % % See also RECSACCURACY, RECSDECISIONRULES, RECSIRF. -% Copyright (C) 2011-2016 Christophe Gouel +% Copyright (C) 2011-2018 Christophe Gouel % Licensed under the Expat license, see LICENSE.txt %% Initialization @@ -272,7 +272,7 @@ if display==1 fprintf(1,'Statistics from simulated variables (excluding the first %i observations):\n',Tburn); disp(' Moments'); - if exist('table','file') + if tabularform disp(stat.moments) else disp(' Mean Std. Dev. Skewness Kurtosis Min Max %LB %UB'); @@ -311,7 +311,7 @@ end if display==1 disp(' Autocorrelation'); - if exist('table','file') + if tabularform disp(stat.acor); else disp(' 1 2 3 4 5'); diff --git a/recsSimulSP.m b/recsSimulSP.m index 0187591..53d1dec 100644 --- a/recsSimulSP.m +++ b/recsSimulSP.m @@ -49,7 +49,7 @@ % % See also RECSACCURACY, RECSDECISIONRULES, RECSIRF. -% Copyright (C) 2011-2017 Christophe Gouel +% Copyright (C) 2011-2018 Christophe Gouel % Licensed under the Expat license, see LICENSE.txt %% Initialization @@ -202,6 +202,9 @@ %% Compute some descriptive statistics if nargout>=4 || statdisplay + if exist('table','file'), tabularform = true; + else tabularform = false; + end if nper >= Tburn+20 X = cat(2,ssim{:},xsim{:}); X = permute(X(:,:,(Tburn+1):end),[2 1 3]); @@ -230,17 +233,25 @@ varX = mean(y.*y,1); stat.moments = [mX' sqrt(varX)' (mean(y.^3,1)./varX.^1.5)' ... (mean(y.^4,1)./(varX.*varX))' min(X)' max(X)' pLB' pUB']; - stat.moments = array2table(stat.moments,... - 'RowNames',symbols,... - 'VariableNames',... - {'Mean' 'StdDev' 'Skewness' 'Kurtosis' 'Min' 'Max' 'pLB' 'pUB'}); + if tabularform + stat.moments = array2table(stat.moments,... + 'RowNames',symbols,... + 'VariableNames',... + {'Mean' 'StdDev' 'Skewness' 'Kurtosis' 'Min' 'Max' 'pLB' 'pUB'}); + end if display==1 fprintf(1,'Statistics from simulated variables (excluding the first %i observations):\n',Tburn); disp(' Moments'); + if ~tabularform + disp(' Mean Std. Dev. Skewness Kurtosis Min Max %LB %UB'); + end disp(stat.moments) end - stat.cor = array2table(corrcoef(X),'RowNames',symbols,'VariableNames',symbols); + stat.cor = corrcoef(X); + if tabularform + stat.cor = array2table(stat.cor,'RowNames',symbols,'VariableNames',symbols); + end if display==1 disp(' Correlation'); disp(stat.cor); @@ -259,10 +270,17 @@ parfor n=1:nrep acor = acor+autocor(X(:,:,n))/nrep; end - stat.acor = array2table(acor,'RowNames',symbols,... - 'VariableNames',{'T1' 'T2' 'T3' 'T4' 'T5'}); + if tabularform + stat.acor = array2table(acor,'RowNames',symbols,... + 'VariableNames',{'T1' 'T2' 'T3' 'T4' 'T5'}); + else + stat.acor = acor; + end if display==1 disp(' Autocorrelation'); + if ~tabularform + disp(' 1 2 3 4 5'); + end disp(stat.acor); end else