diff --git a/src/+gui_tools/menu_options.m b/src/+gui_tools/menu_options.m index 3ccc44b2ee1b54974f6e9a93e57d6493ac7bcca0..b5b69f6c18a84f6bc5cee64678bdd0fcc5409af4 100644 --- a/src/+gui_tools/menu_options.m +++ b/src/+gui_tools/menu_options.m @@ -110,8 +110,8 @@ switch oid case 'epilogue' handles.post_processing_epilogue.Enable = status; - case 'prior_posterior' - handles.post_processing_prior_posterior.Enable = status; + case 'posterior' + handles.post_processing_posterior.Enable = status; otherwise error(['menu option: ' oid ' not handled']); diff --git a/src/dynare_gui.m b/src/dynare_gui.m index d69993b92b2572d26530b3467fa4b4deeff2419d..9c71b6aed9155b655710226ba10fed860d2dd031 100644 --- a/src/dynare_gui.m +++ b/src/dynare_gui.m @@ -355,8 +355,8 @@ function post_processing_epilogue_Callback(hObject, ~, handles) gui_epilogue(addTab(hObject, 'Epilogue', handles)); end -function post_processing_prior_posterior_Callback(hObject, ~, handles) -gui_prior_posterior_distribution(addTab(hObject, 'Prior/Posterior distribution', handles)); +function post_processing_posterior_Callback(hObject, ~, handles) +gui_posterior_distribution(addTab(hObject, 'Posterior distribution', handles)); end % -------------------------------------------------------------------- function help_product_help_Callback(~, ~, ~) @@ -940,14 +940,14 @@ uimenu(... 'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ); appdata = []; -appdata.lastValidTag = 'post_processing_prior_posterior'; +appdata.lastValidTag = 'post_processing_posterior'; uimenu(... 'Parent', h33, ... 'Enable', 'off', ... - 'Callback', @(hObject,eventdata)dynare_gui('post_processing_prior_posterior_Callback',hObject,eventdata,guidata(hObject)),... - 'Label', 'Prior/Posterior distribution',... - 'Tag', 'post_processing_prior_posterior',... + 'Callback', @(hObject,eventdata)dynare_gui('post_processing_posterior_Callback',hObject,eventdata,guidata(hObject)),... + 'Label', 'Posterior distribution',... + 'Tag', 'post_processing_posterior',... 'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ); appdata = []; diff --git a/src/gui_posterior_distribution.m b/src/gui_posterior_distribution.m new file mode 100644 index 0000000000000000000000000000000000000000..1078a879fa3c029ac17d895e8a9f37381b23c2d7 --- /dev/null +++ b/src/gui_posterior_distribution.m @@ -0,0 +1,251 @@ +function gui_posterior_distribution(tabId) +% function gui_posterior_distribution(tabId) +% +% INPUTS +% tabId: GUI tab element which displays epilogue command interface +% +% OUTPUTS +% none +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2020 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 model_settings + +special_color = char(getappdata(0, 'special_color')); + +handles = []; +gui_size = gui_tools.get_gui_elements_size(tabId); + +% --- PANELS ------------------------------------- + +handles.uipanelShocks = uipanel( ... + 'Parent', tabId, ... + 'Tag', 'uipanelShocks', ... + 'BackgroundColor', special_color, ... + 'Units', 'normalized', ... + 'Position', [0.65 0.18 0.3 0.7], ... + 'Title', '', ... + 'BorderType', 'none'); + +radioButtonIRF_Callback; + +handles.uipanelVars = uipanel( ... + 'Parent', tabId, ... + 'Tag', 'uipanelVars', ... + 'UserData', zeros(1,0), ... + 'BackgroundColor', special_color, ... + 'Units', 'normalized', ... + 'Position', [0.3 0.18 0.3 0.7], ... + 'Title', '', ... + 'BorderType', 'none'); + +handles = gui_tabs.create_endo_vars(handles, 'posterior'); + +% --- Radio Buttons ------------------------------------- +handles.buttongroup = uibuttongroup( ... + 'Parent', tabId, ... + 'Position', [0.05 0.2 0.2 0.65], ... + 'Units', 'normalized'); + +uicontrol(handles.buttongroup, ... + 'Style', 'radiobutton', ... + 'String', 'IRF', ... + 'Units', 'normalized', ... + 'Position', [0 0.9 1 .1], ... + 'Callback', @radioButtonIRF_Callback); + + function radioButtonIRF_Callback(~, ~) + data = cell(size(model_settings.shocks, 1), 2); + data(:,1) = {false}; + data(:,2) = model_settings.shocks(:,1); + handles.shocksTabGroup = uitabgroup(handles.uipanelShocks, 'Position', [0 0 1 1]); + new_tab = uitab(handles.shocksTabGroup, 'Title', 'Shocks' , 'UserData', 1); + currentPanel = uipanel('Parent', new_tab, 'BackgroundColor', 'white', 'BorderType', 'none'); + handles.shocksTable = uitable(currentPanel, ... + 'Data', data, ... + 'Units', 'normalized', ... + 'ColumnName', {'Active','Shock'}, ... + 'ColumnEditable', [true false], ... + 'RowName', [], ... + 'Position', [0 0 1 1]); + handles.uipanelShocks.Visible = true; + end + +uicontrol(handles.buttongroup, ... + 'Style', 'radiobutton', ... + 'String', 'Covariance', ... + 'Units', 'normalized', ... + 'Position', [0 0.8 1 .1], ... + 'Callback', @radioButtonCovariance_Callback); + + function radioButtonCovariance_Callback(~, ~) + handles.uipanelShocks.Visible = false; + end + +uicontrol(handles.buttongroup, ... + 'Style', 'radiobutton', ... + 'String', 'Smoother', ... + 'Units', 'normalized', ... + 'Position', [0 0.7 1 .1], ... + 'Callback', @radioButtonSmoother_Callback); + + function radioButtonSmoother_Callback(~, ~) + handles.uipanelShocks.Visible = false; + end + +uicontrol(handles.buttongroup, ... + 'Style', 'radiobutton', ... + 'String', 'Filter', ... + 'Units', 'normalized', ... + 'Position', [0 0.6 1 .1], ... + 'Callback', @radioButtonFilter_Callback); + + function radioButtonFilter_Callback(~, ~) + handles.uipanelShocks.Visible = false; + end + +uicontrol(handles.buttongroup, ... + 'Style', 'radiobutton', ... + 'String', 'Update', ... + 'Units', 'normalized', ... + 'Position', [0 0.5 1 .1], ... + 'Callback', @radioButtonUpdate_Callback); + + function radioButtonUpdate_Callback(~, ~) + handles.uipanelShocks.Visible = false; + end + +uicontrol(handles.buttongroup, ... + 'Style', 'radiobutton', ... + 'String', 'Forecast', ... + 'Units', 'normalized', ... + 'Position', [0 0.4 1 .1], ... + 'Callback', @radioButtonForecast_Callback); + + function radioButtonForecast_Callback(~, ~) + handles.uipanelShocks.Visible = false; + end + +% --- PUSHBUTTONS ------------------------------------- +handles.pushbuttonSimulation = uicontrol( ... + 'Parent', tabId, ... + 'Tag', 'pushbuttonPosterior', ... + 'Style', 'pushbutton', ... + 'Units','normalized', ... + 'Position', [gui_size.space gui_size.bottom gui_size.button_width_small gui_size.button_height], ... + 'String', 'Run', ... + 'Callback', @pushbuttonPosterior_Callback); + + function pushbuttonPosterior_Callback(~, ~) + switch handles.buttongroup.SelectedObject.String + case 'IRF' + global posterior_irf + if sum([handles.endoTable.Data{:,1}]) ~= 1 || sum([handles.shocksTable.Data{:,1}]) ~= 1 + gui_tools.show_error('For IRF you must choose 1 endogenous and 1 exogenous variable'); + end + posterior_irf = get_posterior_irf( ... + handles.endoTable.Data{[handles.endoTable.Data{:,1}],2}, ... + handles.shocksTable.Data{[handles.shocksTable.Data{:,1}],2}); + case 'Covariance' + global posterior_covariance + selected = handles.endoTable.Data([handles.endoTable.Data{:,1}], :); + switch size(selected, 1) + case 1 + posterior_covariance = get_posterior_covariance(selected{2}, selected{2}); + case 2 + posterior_covariance = get_posterior_covariance(selected{1,2}, selected{2,2}); + otherwise + gui_tools.show_error('For Covariance you must choose 1 or 2 endogenous variables'); + end + case 'Smoother' + if sum([handles.endoTable.Data{:,1}]) ~= 1 + gui_tools.show_error('For Smoother you must choose 1 endogenous variable'); + end + global posterior_smoother + posterior_smoother = get_posterior_timeseries('smoothed', ... + handles.endoTable.Data{[handles.endoTable.Data{:,1}],2}); + case 'Filter' + if sum([handles.endoTable.Data{:,1}]) ~= 1 + gui_tools.show_error('For Filter you must choose 1 endogenous variable'); + end + global posterior_filter + posterior_filter = get_posterior_timeseries('filtered', ... + handles.endoTable.Data{[handles.endoTable.Data{:,1}],2}); + case 'Update' + if sum([handles.endoTable.Data{:,1}]) ~= 1 + gui_tools.show_error('For Update you must choose 1 endogenous variable'); + end + global posterior_update + posterior_update = get_posterior_timeseries('updated', ... + handles.endoTable.Data{[handles.endoTable.Data{:,1}],2}); + case 'Forecast' + if sum([handles.endoTable.Data{:,1}]) ~= 1 + gui_tools.show_error('For Forecast you must choose 1 endogenous variable'); + end + global posterior_forecast + posterior_forecast = get_posterior_timeseries('forecast', ... + handles.endoTable.Data{[handles.endoTable.Data{:,1}],2}); + otherwise + gui_tools.show_error('Should not arrive here'); + end + end + +handles.pushbuttonReset = uicontrol( ... + 'Parent', tabId, ... + 'Tag', 'pushbuttonReset', ... + 'Style', 'pushbutton', ... + 'Units','normalized', ... + 'Position', [gui_size.space*2+gui_size.button_width_small gui_size.bottom gui_size.button_width_small gui_size.button_height], ... + 'String', 'Reset', ... + 'Callback', @reset); + + function reset(~, ~) + handles.endoTable.Data(:, 1) = {false}; + handles.shocksTable.Data(:, 1) = {false}; + end + +uicontrol( ... + 'Parent', tabId, ... + 'Tag', 'pushbuttonCloseTab', ... + 'Style', 'pushbutton', ... + 'Units', 'normalized', ... + 'Position', [gui_size.space*3+gui_size.button_width_small*2 gui_size.bottom gui_size.button_width_small gui_size.button_height], ... + 'String', 'Close this tab', ... + 'Callback', {@close_tab,tabId}); + + function close_tab(~, ~, hTab) + gui_tabs.delete_tab(hTab); + end + +uicontrol( ... + 'Parent', tabId, ... + 'Tag', 'pushbuttonSimulation', ... + 'Style', 'pushbutton', ... + 'Units','normalized', ... + 'Position', [gui_size.space*5+gui_size.button_width_small*4 gui_size.bottom gui_size.button_width_small gui_size.button_height], ... + 'String', 'Close all output figures', ... + 'Enable', 'on', ... + 'Callback', @close_all); + + function close_all(~, ~) + gui_tools.close_all_figures(); + end +end diff --git a/src/gui_prior_posterior_distribution.m b/src/gui_prior_posterior_distribution.m deleted file mode 100644 index 523637574e7f40c913a3226995ed1344772328fc..0000000000000000000000000000000000000000 --- a/src/gui_prior_posterior_distribution.m +++ /dev/null @@ -1,163 +0,0 @@ -function gui_prior_posterior_distribution(tabId) -% function gui_prior_posterior_distribution(tabId) -% -% INPUTS -% tabId: GUI tab element which displays epilogue command interface -% -% OUTPUTS -% none -% -% SPECIAL REQUIREMENTS -% none - -% Copyright (C) 2020 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_ - -bg_color = char(getappdata(0, 'bg_color')); -special_color = char(getappdata(0, 'special_color')); - -handles = []; -gui_size = gui_tools.get_gui_elements_size(tabId); - -% --- PANELS ------------------------------------- - -handles.uipanelVars = uipanel( ... - 'Parent', tabId, ... - 'Tag', 'uipanelVars', ... - 'UserData', zeros(1,0), ... - 'BackgroundColor', special_color, ... - 'Units', 'normalized', ... - 'Position', [0.51 0.18 0.48 0.7], ... - 'Title', '', ... - 'BorderType', 'none'); - -handles = gui_tabs.create_endo_vars(handles, 'prior_posterior'); - -% --- Radio Buttons ------------------------------------- -handles.buttongroup = uibuttongroup( ... - 'Parent', tabId, ... - 'Position', [0.05 0.88 0.36 0.05], ... - 'Units', 'normalized'); - -uicontrol(handles.buttongroup, ... - 'Style', 'radiobutton', ... - 'String', 'Prior', ... - 'Units', 'normalized', ... - 'Position', [0 0 1 1]); - -uicontrol(handles.buttongroup, ... - 'Style', 'radiobutton', ... - 'String', 'Posterior', ... - 'Units', 'normalized', ... - 'Position', [0.1 0 1 1]); - -handles.buttongroup1 = uibuttongroup( ... - 'Parent', tabId, ... - 'Position', [0.05 0.2 0.4 0.65], ... - 'Units', 'normalized'); - -uicontrol(handles.buttongroup1, ... - 'Style', 'radiobutton', ... - 'String', 'IRF', ... - 'Units', 'normalized', ... - 'Position', [0 0.9 1 .1]); - -uicontrol(handles.buttongroup1, ... - 'Style', 'radiobutton', ... - 'String', 'Smoother', ... - 'Units', 'normalized', ... - 'Position', [0 0.8 1 .1]); - -uicontrol(handles.buttongroup1, ... - 'Style', 'radiobutton', ... - 'String', 'Smoother', ... - 'Units', 'normalized', ... - 'Position', [0 0.7 1 .1]); - -uicontrol(handles.buttongroup1, ... - 'Style', 'radiobutton', ... - 'String', 'Filter', ... - 'Units', 'normalized', ... - 'Position', [0 0.6 1 .1]); - -uicontrol(handles.buttongroup1, ... - 'Style', 'radiobutton', ... - 'String', 'Update', ... - 'Units', 'normalized', ... - 'Position', [0 0.5 1 .1]); - -uicontrol(handles.buttongroup1, ... - 'Style', 'radiobutton', ... - 'String', 'Forecast', ... - 'Units', 'normalized', ... - 'Position', [0 0.4 1 .1]); - -% --- PUSHBUTTONS ------------------------------------- -handles.pushbuttonSimulation = uicontrol( ... - 'Parent', tabId, ... - 'Tag', 'pushbuttonPriorPosterior', ... - 'Style', 'pushbutton', ... - 'Units','normalized', ... - 'Position', [gui_size.space gui_size.bottom gui_size.button_width_small gui_size.button_height], ... - 'String', 'Run prior/posterior', ... - 'Callback', @pushbuttonPriorPosterior_Callback); - - function pushbuttonPriorPosterior_Callback(~, ~) - end - -handles.pushbuttonReset = uicontrol( ... - 'Parent', tabId, ... - 'Tag', 'pushbuttonReset', ... - 'Style', 'pushbutton', ... - 'Units','normalized', ... - 'Position', [gui_size.space*2+gui_size.button_width_small gui_size.bottom gui_size.button_width_small gui_size.button_height], ... - 'String', 'Reset', ... - 'Callback', @reset); - - function reset(~, ~) - handles.endoTable.Data(:, 1) = {false}; - end - -uicontrol( ... - 'Parent', tabId, ... - 'Tag', 'pushbuttonCloseTab', ... - 'Style', 'pushbutton', ... - 'Units', 'normalized', ... - 'Position', [gui_size.space*3+gui_size.button_width_small*2 gui_size.bottom gui_size.button_width_small gui_size.button_height], ... - 'String', 'Close this tab', ... - 'Callback', {@close_tab,tabId}); - - function close_tab(~, ~, hTab) - gui_tabs.delete_tab(hTab); - end - -uicontrol( ... - 'Parent', tabId, ... - 'Tag', 'pushbuttonSimulation', ... - 'Style', 'pushbutton', ... - 'Units','normalized', ... - 'Position', [gui_size.space*5+gui_size.button_width_small*4 gui_size.bottom gui_size.button_width_small gui_size.button_height], ... - 'String', 'Close all output figures', ... - 'Enable', 'on', ... - 'Callback', @close_all); - - function close_all(~, ~) - gui_tools.close_all_figures(); - end -end diff --git a/src/gui_set_menus.m b/src/gui_set_menus.m index 685674eb476248a588a760f9ed9b5e646fa25d96..0830423caf6e4d9e9175429c17436cd843c0e16e 100644 --- a/src/gui_set_menus.m +++ b/src/gui_set_menus.m @@ -40,7 +40,7 @@ gui_tools.menu_options('stochastic','Off'); gui_tools.menu_options('deterministic','Off'); gui_tools.menu_options('sensitivity', 'Off'); gui_tools.menu_options('epilogue', 'Off'); -gui_tools.menu_options('prior_posterior', 'Off'); +gui_tools.menu_options('posterior', 'Off'); if isempty(model_settings) || isempty(fieldnames(model_settings)) return @@ -52,7 +52,7 @@ if enable return end gui_tools.menu_options('epilogue', 'On'); - gui_tools.menu_options('prior_posterior', 'On'); + gui_tools.menu_options('posterior', 'On'); if project_info.project_model_stochastic gui_tools.menu_options('estimation', 'On'); gui_tools.menu_options('stochastic', 'On');