Add CLI for some routines.

- steady,
 - check,
 - evaluate_likelihood,
 - evaluate_posterior_kernel, and
 - evaluate_prior.

*Example*

After running a mod file, on the Matlab's command line:

>> cli.check

EIGENVALUES:
         Modulus             Real        Imaginary

               0                0                0
       1.389e-16        1.389e-16                0
          0.6452           0.6452                0
          0.9707           0.9707                0
           1.038            1.038                0
       1.271e+16        1.271e+16                0
        2.33e+17         2.33e+17                0

There are 3 eigenvalue(s) larger than 1 in modulus
for 3 forward-looking variable(s)

The rank condition is verified.
pac-components
Stéphane Adjemian (Ryûk) 2021-12-14 14:40:07 +01:00
parent 301fe42ed8
commit 4dd3ee8546
Signed by: stepan
GPG Key ID: 295C1FE89E17EB3C
5 changed files with 191 additions and 0 deletions

40
matlab/cli/+cli/check.m Normal file
View File

@ -0,0 +1,40 @@
function check(printflag)
% Computes and displays the generalized eigenvalues. Also checks BK conditions.
%
% INPUTS
% - printflag [logical] scalar, print eigenvalues if true (default value is true).
%
% OUTPUTS
% None
% Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
global options_ M_ oo_
if ~nargin || isempty(printflag)
printflag = true;
end
noprint = options_.noprint;
options_.noprint = ~printflag;
check(M_, options_, oo_);
options_.noprint = noprint;

View File

@ -0,0 +1,37 @@
function llik = evaluate_likelihood(parameters)
% Evaluates the likelihood function.
%
% INPUTS
% - parameters [char,double] If row char array, possible values are 'posterior mode', 'posterior mean',
% 'posterior median', 'prior mode' or 'prior mean'. Otherwise, parmaters must
% be a vector of doubles (arbitrary values for the parameters).
%
% OUTPUTS
% None
% Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
global M_ estim_params_ oo_ options_ bayestopt_
llik = evaluate_likelihood(parameters, M_, estim_params_, oo_, options_, bayestopt_);
if ~nargout
dprintf('\nValue of the log-likelihood: %20.6f\n', llik);
clear ('llik'); % Do not display the value returned by the function.
end

View File

@ -0,0 +1,37 @@
function lpk = evaluate_posterior_kernel(parameters)
% Evaluates the posterior kernel function.
%
% INPUTS
% - parameters [char,double] If row char array, possible values are 'posterior mode', 'posterior mean',
% 'posterior median', 'prior mode' or 'prior mean'. Otherwise, parmaters must
% be a vector of doubles (arbitrary values for the parameters).
%
% OUTPUTS
% None
% Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
global M_ estim_params_ oo_ options_ bayestopt_
lpk = evaluate_posterior_kernel(parameters, M_, estim_params_, oo_, options_, bayestopt_);
if ~nargout
dprintf('\nValue of the logged posterior kernel: %20.6f\n', lpk);
clear ('lpk'); % Do not display the value returned by the function.
end

View File

@ -0,0 +1,37 @@
function ldens = evaluate_prior(parameters)
% Evaluates the posterior kernel function.
%
% INPUTS
% - parameters [char,double] If row char array, possible values are 'posterior mode', 'posterior mean',
% 'posterior median', 'prior mode' or 'prior mean'. Otherwise, parmaters must
% be a vector of doubles (arbitrary values for the parameters).
%
% OUTPUTS
% None
% Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
global M_ estim_params_ oo_ options_ bayestopt_
ldens = evaluate_prior(parameters, M_, estim_params_, oo_, options_, bayestopt_);
if ~nargout
dprintf('\nValue of the logged prior density: %20.6f\n', ldens);
clear ('ldens'); % Do not display the value returned by the function.
end

40
matlab/cli/+cli/steady.m Normal file
View File

@ -0,0 +1,40 @@
function steady(printflag)
% Computes and prints the steady state.
%
% INPUTS
% - printflag [logical] scalar, print steady state if true (default value is true).
%
% OUTPUTS
% None
% Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
global options_
if ~nargin || isempty(printflag)
printflag = true;
end
noprint = options_.noprint;
options_.noprint = ~printflag;
steady();
options_.noprint = noprint;