From c7e306f9cd8bbfc92d12241f43500d2a3acd5e1b Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Thu, 13 Feb 2020 11:37:04 +0100
Subject: [PATCH] introduce interface for prior/posterior distribution of
 moments

---
 src/+gui_tools/menu_options.m          |   7 +-
 src/dynare_gui.m                       |  16 ++-
 src/gui_prior_posterior_distribution.m | 163 +++++++++++++++++++++++++
 src/gui_set_menus.m                    |   4 +-
 4 files changed, 186 insertions(+), 4 deletions(-)
 create mode 100644 src/gui_prior_posterior_distribution.m

diff --git a/src/+gui_tools/menu_options.m b/src/+gui_tools/menu_options.m
index 859ede5..3ccc44b 100644
--- a/src/+gui_tools/menu_options.m
+++ b/src/+gui_tools/menu_options.m
@@ -12,7 +12,7 @@ function menu_options(oid, status)
 % SPECIAL REQUIREMENTS
 %   none
 
-% Copyright (C) 2003-2019 Dynare Team
+% Copyright (C) 2003-2020 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -29,7 +29,7 @@ function menu_options(oid, status)
 % 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_ project_info
+global oo_ project_info
 
 handles = guihandles(getappdata(0,'main_figure'));
 
@@ -109,6 +109,9 @@ switch oid
 
     case 'epilogue'
         handles.post_processing_epilogue.Enable = status;
+        
+    case 'prior_posterior'
+        handles.post_processing_prior_posterior.Enable = status;
 
     otherwise
         error(['menu option: ' oid ' not handled']);
diff --git a/src/dynare_gui.m b/src/dynare_gui.m
index b6987d0..498c181 100644
--- a/src/dynare_gui.m
+++ b/src/dynare_gui.m
@@ -17,7 +17,7 @@ function varargout = dynare_gui(varargin)
 %      stop.  All inputs are passed to dynare_gui_OpeningFcn via varargin.
 %
 %
-% Copyright (C) 2003-2019 Dynare Team
+% Copyright (C) 2003-2020 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -355,6 +355,9 @@ 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));
+end
 % --------------------------------------------------------------------
 function help_product_help_Callback(~, ~, ~)
 path = [getappdata(0, 'dynare_gui_root') filesep 'resources' filesep 'html' filesep 'index.html'];
@@ -936,6 +939,17 @@ uimenu(...
     'Tag', 'post_processing_epilogue',...
     'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
 
+appdata = [];
+appdata.lastValidTag = 'post_processing_prior_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',...
+    'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
+
 appdata = [];
 appdata.lastValidTag = 'help';
 
diff --git a/src/gui_prior_posterior_distribution.m b/src/gui_prior_posterior_distribution.m
new file mode 100644
index 0000000..5236375
--- /dev/null
+++ b/src/gui_prior_posterior_distribution.m
@@ -0,0 +1,163 @@
+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 2615456..685674e 100644
--- a/src/gui_set_menus.m
+++ b/src/gui_set_menus.m
@@ -11,7 +11,7 @@ function gui_set_menus(enable)
 % SPECIAL REQUIREMENTS
 %   none
 
-% Copyright (C) 2019 Dynare Team
+% Copyright (C) 2019-2020 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -40,6 +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');
 
 if isempty(model_settings) || isempty(fieldnames(model_settings))
     return
@@ -51,6 +52,7 @@ if enable
         return
     end
     gui_tools.menu_options('epilogue', 'On');
+    gui_tools.menu_options('prior_posterior', 'On');
     if project_info.project_model_stochastic
         gui_tools.menu_options('estimation', 'On');
         gui_tools.menu_options('stochastic', 'On');
-- 
GitLab