diff --git a/matlab/get_irf.m b/matlab/get_irf.m new file mode 100755 index 0000000000000000000000000000000000000000..e247d2054faaa40950b755fab6e96526ae0cde7c --- /dev/null +++ b/matlab/get_irf.m @@ -0,0 +1,47 @@ + +function y0 = get_irf(exo,varargin) +% function x = get_irf(exoname, vname1, vname2, ...) +% returns IRF to individual exogenous for a list of variables and adds the +% steady state +% +% INPUTS: +% exo: exo variable name +% vname1, vname2, ... : list of variable names +% +% OUTPUTS +% x: irf matrix [time x number of variables] +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2019 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/>. + +global M_ oo_ + +ys_ = [oo_.steady_state]; +y0=zeros(length(oo_.irfs.([varargin{1} '_' exo]))+1,length(varargin)); + + +[i_var,nvar] = varlist_indices(varargin,M_.endo_names); + + +for j=1:nvar +% mfys = strmatch(varargin{j},lgy_,'exact'); + y0(:,j)=[0; oo_.irfs.([ varargin{j} '_' exo ])']+ys_(i_var(j)); +end + diff --git a/matlab/get_mean.m b/matlab/get_mean.m new file mode 100755 index 0000000000000000000000000000000000000000..f307210dc0f847aac1de34e658bfcef6d8237efc --- /dev/null +++ b/matlab/get_mean.m @@ -0,0 +1,56 @@ +function y0 = get_mean(varargin) +% function x = get_mean(vname1, vname2, <order>) +% returns the steady-state of a variable identified by its name +% +% INPUTS: +% vname1, vname2, ... : list of variable names +% order: if integer 1 or 2, optionally last input can trigger the order +% at which steady state is computed +% +% OUTPUTS +% x: steady state values +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2019 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/>. + +global M_ oo_ options_ + +if ~isempty(regexp(varargin{end},'\d','ONCE')) && isempty(regexp(varargin{end},'\D','ONCE')) + order=eval(varargin{end}); +else + order=1; +end +if order==1 + ys_ = oo_.steady_state; + ys_ = evaluate_steady_state(ys_,M_,options_,oo_,1); +elseif order==2 + ys_ = oo_.dr.ys; + ys_(oo_.dr.order_var)=ys_(oo_.dr.order_var)+oo_.dr.ghs2./2; +else + return +end +lgy_ = M_.endo_names; + +mfys=nan(length(varargin),1); +for j=1:length(varargin) + mfys(j) = find(strcmp(varargin{j},lgy_)); +end + +y0 = ys_(mfys); diff --git a/matlab/get_shock_stderr_by_name.m b/matlab/get_shock_stderr_by_name.m new file mode 100755 index 0000000000000000000000000000000000000000..b1143a69a76037924dd0dab606505d2221f1875e --- /dev/null +++ b/matlab/get_shock_stderr_by_name.m @@ -0,0 +1,39 @@ +function x = get_shock_stderr_by_name(exoname) +% function x = get_shock_stderr_by_name(exoname) +% returns the value of a shock identified by its name +% +% INPUTS: +% exoname: shock name +% +% OUTPUTS +% x: shock value +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2019 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/>. + +global M_ + +i = find(strcmp(exoname,M_.exo_names)); + +if isempty(i) + error(['Can''t find shock ', exoname]) +end + +x = sqrt(M_.Sigma_e(i,i)); diff --git a/matlab/get_smooth.m b/matlab/get_smooth.m new file mode 100755 index 0000000000000000000000000000000000000000..c81cbbc1bfb860369487e896f9b74204082db774 --- /dev/null +++ b/matlab/get_smooth.m @@ -0,0 +1,46 @@ + +function y0 = get_smooth(varargin) +% function x = get_smooth(vname1, vname2, ) +% returns smoothed variables or shocks identified by their name +% +% INPUTS: +% vname1, vname2, ... : list of variable/shock names +% +% OUTPUTS +% x: smoothed variables [T x number of variables] +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2019 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/>. +global oo_ + +SmoothedVariables=[struct2cell(oo_.SmoothedVariables); struct2cell(oo_.SmoothedShocks)]; +my_field_names = [fieldnames(oo_.SmoothedVariables); fieldnames(oo_.SmoothedShocks)]; +isvar=zeros(length(SmoothedVariables),1); +for jf = 1:length(SmoothedVariables) + isvar(jf)=~(isstruct(SmoothedVariables{jf})); +end +SmoothedVariables=cell2struct(SmoothedVariables(logical(isvar)),my_field_names(logical(isvar))); + + +y0=zeros(length(SmoothedVariables.(varargin{1})),length(varargin)); +for j=1:length(varargin) + y0(:,j)=SmoothedVariables.(varargin{j}); +end + diff --git a/matlab/get_update.m b/matlab/get_update.m new file mode 100755 index 0000000000000000000000000000000000000000..994a6e47b73e2161ebf230da94668e4561c6bf1a --- /dev/null +++ b/matlab/get_update.m @@ -0,0 +1,36 @@ +function y0 = get_update(varargin) +% function x = get_update(vname1, vname2, ) +% returns updated variables identified by their name +% +% INPUTS: +% vname1, vname2, ... : list of variable names +% +% OUTPUTS +% x: smoothed variables [T x number of variables] +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2019 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/>. +global oo_ + +y0=zeros(length(oo_.UpdatedVariables.(varargin{1})),length(varargin)); +for j=1:length(varargin) + y0(:,j)=oo_.UpdatedVariables.(varargin{j}); +end +