Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • Dynare/matlab-gui
  • DoraK/matlab-gui
  • rattoma/matlab-gui
3 results
Select Git revision
Loading items
Show changes
...@@ -28,26 +28,25 @@ function gui_define_model_settings(hObject) ...@@ -28,26 +28,25 @@ function gui_define_model_settings(hObject)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global project_info global project_info model_settings oo_ M_ ex0_
global model_settings
global oo_ M_ ex0_
bg_color = char(getappdata(0, 'bg_color')); bg_color = char(getappdata(0, 'bg_color'));
special_color = char(getappdata(0, 'special_color')); special_color = char(getappdata(0, 'special_color'));
dynare_gui_root = getappdata(0, 'dynare_gui_root'); javaaddpath([getappdata(0, 'dynare_gui_root') filesep '+gui_external' filesep 'tablefilter-swing-5.2.2.jar']);
path = [dynare_gui_root, filesep,'+gui_external', filesep,'tablefilter-swing-5.2.2.jar'];
javaaddpath(path);
[tabId, ~] = gui_tabs.add_tab(hObject, 'Model settings'); tabId = gui_tabs.add_tab(hObject, 'Model settings');
gui_size = gui_tools.get_gui_elements_size(tabId); gui_size = gui_tools.get_gui_elements_size(tabId);
uicontrol(tabId,'Style','text',... uicontrol(tabId, ...
'Style', 'text', ...
'String', 'Define model settings in tabs below:',... 'String', 'Define model settings in tabs below:',...
'FontWeight', 'bold', ... 'FontWeight', 'bold', ...
'HorizontalAlignment', 'left','BackgroundColor', bg_color,... 'HorizontalAlignment', 'left', ...
'Units','normalized','Position',[0.01 0.92 1 0.05] ); 'BackgroundColor', bg_color,...
'Units', 'normalized', ...
'Position', [0.01 0.92 1 0.05]);
current_settings.shocks = model_settings.shocks; current_settings.shocks = model_settings.shocks;
current_settings.variables = model_settings.variables; current_settings.variables = model_settings.variables;
...@@ -60,7 +59,8 @@ panel_id = uipanel( ... ...@@ -60,7 +59,8 @@ panel_id = uipanel( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'uipanelSettings', ... 'Tag', 'uipanelSettings', ...
'BackgroundColor', special_color, ... 'BackgroundColor', special_color, ...
'Units', 'normalized', 'Position', [0 0.09 1 0.82], ... 'Units', 'normalized', ...
'Position', [0 0.09 1 0.82], ...
'Title', '', ... 'Title', '', ...
'BorderType', 'none'); 'BorderType', 'none');
...@@ -97,19 +97,51 @@ uicontrol(tabId, 'Style','pushbutton','String','Close this tab','Units','normali ...@@ -97,19 +97,51 @@ uicontrol(tabId, 'Style','pushbutton','String','Close this tab','Units','normali
model_settings.params = current_settings.params; model_settings.params = current_settings.params;
model_settings.shocks_corr = current_settings.shocks_corr; model_settings.shocks_corr = current_settings.shocks_corr;
%save current values % Doesn't support multiple shock groups for single shock.... needs new
for ii = 1:M_.exo_nbr % interface for that
% if isfield(M_, 'shock_groups')
% M_ = rmfield(M_, 'shock_groups');
% end
% for i = 1:rows(model_settings.shocks)
% if project_info.project_model_stochastic
% gn = model_settings.shocks{i, 7};
% sg = model_settings.shocks{i, 8};
% else
% gn = model_settings.shocks{i, 5};
% sg = model_settings.shocks{i, 6};
% end
% if ~isempty(gn) && ~isempty(sg)
% if ~isfield(M_, 'shock_groups')
% M_.shock_groups = struct;
% end
% if ~isfield(M_.shock_groups, gn)
% M_.shock_groups.(gn) = struct;
% end
% fn = fieldnames(M_.shock_groups.(gn));
% idx = length(fn) + 1;
% for j = 1:length(fn)
% if isfield(M_.shock_groups.(gn).(fn{j}), 'label')
% if strcmp(M_.shock_groups.(gn).(fn{j}).label, sg)
% idx = j;
% break;
% end
% end
% end
% M_.shock_groups.(gn).(['group' num2str(idx)]).label = sg;
% if isfield(M_.shock_groups.(gn).(['group' num2str(idx)]), 'shocks')
% M_.shock_groups.(gn).(['group' num2str(idx)]).shocks = [M_.shock_groups.(gn).(['group' num2str(idx)]).shocks model_settings.shocks(i, 1)];
% else
% M_.shock_groups.(gn).(['group' num2str(idx)]).shocks = model_settings.shocks(i, 1);
% end
% end
% end
if project_info.project_model_stochastic if project_info.project_model_stochastic
M_.Sigma_e(ii,ii) = (current_settings.shocks{ii,4})^2; M_.Sigma_e(1:1+size(M_.Sigma_e,1):end) = cellfun(@(A) A^2, current_settings.shocks(:,4));
else else
ex0_(ii) = str2double(current_settings.shocks{ii,4}); ex0_ = cell2mat(current_settings.shocks(:,4));
end end
end M_.params = [current_settings.params{:, 4}]';
for ii = 1:M_.param_nbr
M_.params(ii) = current_settings.params{ii,4};
end
oo_.steady_state = cell2mat(model_settings.variables(:, 8)); oo_.steady_state = cell2mat(model_settings.variables(:, 8));
gui_tools.project_log_entry('Saving model settings', '...'); gui_tools.project_log_entry('Saving model settings', '...');
...@@ -147,10 +179,11 @@ uicontrol(tabId, 'Style','pushbutton','String','Close this tab','Units','normali ...@@ -147,10 +179,11 @@ uicontrol(tabId, 'Style','pushbutton','String','Close this tab','Units','normali
end end
end end
column_names = {' Name ',' LaTeX name ', ' Long name ', ' Current value ', column_name, ' STD ', ' Show/Hide ', ' Group (tab) name ',' Show/Hide group ', ' Rename group '}; column_names = {' Name ', ' LaTeX name ', ' Long name ', ' Current value ', column_name, ' STD ', ' Shock Groups ', ' Shock Group '};
column_format = {'char','char','char','numeric' , 'numeric','numeric','logical', 'char','logical','char'}; column_format = {'char', 'char', 'char', 'numeric' , 'numeric', 'numeric', 'char', 'char'};
uit = uitable(tabId,'Data',data,... uit = uitable(tabId, ...
'Units','normalized',...% 'Units','characters',...normalized 'Data', data, ...
'Units','normalized', ...
'ColumnName', column_names,... 'ColumnName', column_names,...
'ColumnFormat', column_format,... 'ColumnFormat', column_format,...
'ColumnEditable', [ false true true true false false true true true true],... 'ColumnEditable', [ false true true true false false true true true true],...
...@@ -172,7 +205,8 @@ uicontrol(tabId, 'Style','pushbutton','String','Close this tab','Units','normali ...@@ -172,7 +205,8 @@ uicontrol(tabId, 'Style','pushbutton','String','Close this tab','Units','normali
'HorizontalAlignment', 'left','BackgroundColor', special_color,... 'HorizontalAlignment', 'left','BackgroundColor', special_color,...
'Units','normalized','Position',[0.01,0.45,.98,0.05]);% 'Units','characters','Position',[1 12 50 1] ); 'Units','normalized','Position',[0.01,0.45,.98,0.05]);% 'Units','characters','Position',[1 12 50 1] );
uitable(tabId,'Data',data_corr,... uitable(tabId, ...
'Data', data_corr, ...
'Units', 'normalized', ... 'Units', 'normalized', ...
'ColumnName', corr_names, ... 'ColumnName', corr_names, ...
'ColumnFormat', corr_format, ... 'ColumnFormat', corr_format, ...
...@@ -189,9 +223,10 @@ uicontrol(tabId, 'Style','pushbutton','String','Close this tab','Units','normali ...@@ -189,9 +223,10 @@ uicontrol(tabId, 'Style','pushbutton','String','Close this tab','Units','normali
end end
end end
column_names = {' Name ',' LaTeX name ', ' Long name ', ' initval ', ' Show/Hide ', ' Group (tab) name ',' Show/Hide group ', ' Rename group '}; column_names = {' Name ', ' LaTeX name ', ' Long name ', ' initval ', ' Shock Groups', ' Shock Group '};
column_format = {'char','char','char','numeric' , 'logical', 'char','logical','char'}; column_format = {'char', 'char', 'char', 'numeric', 'char', 'char'};
uit = uitable(tabId,'Data',data,... uit = uitable(tabId, ...
'Data', data, ...
'Units', 'normalized', ... 'Units', 'normalized', ...
'ColumnName', column_names, ... 'ColumnName', column_names, ...
'ColumnFormat', column_format, ... 'ColumnFormat', column_format, ...
...@@ -320,9 +355,7 @@ uicontrol(tabId, 'Style','pushbutton','String','Close this tab','Units','normali ...@@ -320,9 +355,7 @@ uicontrol(tabId, 'Style','pushbutton','String','Close this tab','Units','normali
set(uit,'data',t_data); set(uit,'data',t_data);
%jtable.getRowSorter.setRowFilter(current_filter); %jtable.getRowSorter.setRowFilter(current_filter);
end end
end end
end end
function gui_params(tabId, data) function gui_params(tabId, data)
...@@ -402,7 +435,6 @@ uicontrol(tabId, 'Style','pushbutton','String','Close this tab','Units','normali ...@@ -402,7 +435,6 @@ uicontrol(tabId, 'Style','pushbutton','String','Close this tab','Units','normali
c_rename_group = 8; c_rename_group = 8;
end end
if c == c_show_hide_group if c == c_show_hide_group
t_data=get(uit,'data'); t_data=get(uit,'data');
group_name = t_data{r,c_group_name}; group_name = t_data{r,c_group_name};
......
...@@ -39,43 +39,53 @@ gui_size = gui_tools.get_gui_elements_size(tabId); ...@@ -39,43 +39,53 @@ gui_size = gui_tools.get_gui_elements_size(tabId);
% --- PANELS ------------------------------------- % --- PANELS -------------------------------------
handles.uipanelShocks = uipanel( ... handles.uipanelShocks = uipanel( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'uipanelShocks','BackgroundColor', special_color,... 'Tag', 'uipanelShocks', ...
'Units', 'normalized', 'Position', [0.01 0.18 0.6 0.73],... 'BackgroundColor', special_color, ...
'Units', 'normalized', ...
'Position', [0.01 0.18 0.6 0.73], ...
'Title', '', ... 'Title', '', ...
'BorderType', 'none'); 'BorderType', 'none');
uipanelShocks_CreateFcn; uipanelShocks_CreateFcn;
handles.uipanelVars = uipanel( ... handles.uipanelVars = uipanel( ...
'Parent', tabId, 'Tag', 'uipanelVars', ... 'Parent', tabId, ...
'UserData', zeros(1,0), 'BackgroundColor', special_color,... 'Tag', 'uipanelVars', ...
'Units', 'normalized', 'Position', [0.62 0.18 0.37 0.73], ... 'UserData', zeros(1,0), ...
'Title', '', 'BorderType', 'none'); 'BackgroundColor', special_color, ...
'Units', 'normalized', ...
'Position', [0.62 0.18 0.37 0.70], ...
'Title', '', ...
'BorderType', 'none');
handles = gui_tabs.create_endo_vars(handles, 'perfect_foresight'); handles = gui_tabs.create_endo_vars(handles, 'perfect_foresight');
handles.uipanelComm = uipanel( ... handles.uipanelComm = uipanel( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'uipanelCommOptions', ... 'Tag', 'uipanelCommOptions', ...
'UserData', zeros(1,0), 'BackgroundColor', bg_color, ... 'UserData', zeros(1,0), ...
'Units', 'normalized', 'Position', [0.01 0.09 0.98 0.09], ... 'BackgroundColor', bg_color, ...
'Units', 'normalized', ...
'Position', [0.01 0.09 0.98 0.09], ...
'Title', 'Current command options:'); 'Title', 'Current command options:');
% --- STATIC TEXT ------------------------------------- % --- STATIC TEXT -------------------------------------
handles.text7 = uicontrol( ... uicontrol( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'text7', ... 'Style', 'text', ...
'Style', 'text', 'BackgroundColor', bg_color,... 'BackgroundColor', bg_color, ...
'Units','normalized','Position',[0.62 0.92 0.48 0.05],... 'Units', 'normalized', ...
'Position', [0.62 0.92 0.48 0.05], ...
'FontWeight', 'bold', ... 'FontWeight', 'bold', ...
'String', 'Select variables for which to plot simulated trajectory:', ... 'String', 'Select variables for which to plot simulated trajectory:', ...
'HorizontalAlignment', 'left'); 'HorizontalAlignment', 'left');
handles.text8 = uicontrol( ... uicontrol( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'text8', ... 'Style', 'text', ...
'Style', 'text', 'BackgroundColor', bg_color,... 'BackgroundColor', bg_color, ...
'Units','normalized','Position',[0.01 0.92 0.48 0.05],... 'Units', 'normalized', ...
'Position', [0.01 0.92 0.48 0.05], ...
'FontWeight', 'bold', ... 'FontWeight', 'bold', ...
'String', 'Define shocks on exogenous variables:', ... 'String', 'Define shocks on exogenous variables:', ...
'HorizontalAlignment', 'left'); 'HorizontalAlignment', 'left');
...@@ -95,6 +105,38 @@ handles.simul = uicontrol( ... ...@@ -95,6 +105,38 @@ handles.simul = uicontrol( ...
'TooltipString', comm_str, ... 'TooltipString', comm_str, ...
'HorizontalAlignment', 'left'); 'HorizontalAlignment', 'left');
% --- Radio Buttons -------------------------------------
handles.buttongroup = uibuttongroup( ...
'Parent', tabId, ...
'Position', [0.62 0.88 0.36 0.05], ...
'Units', 'normalized', ...
'SelectionChangedFcn', {@init_val, handles});
uicontrol(handles.buttongroup, ...
'Style', 'text', ...
'Units', 'normalized', ...
'Position', [0 -.2 1 1], ...
'FontWeight', 'bold', ...
'String', 'Initial value: ', ...
'HorizontalAlignment', 'left');
uicontrol(handles.buttongroup, ...
'Style', 'radiobutton', ...
'String', 'zero', ...
'Units', 'normalized', ...
'Position', [0.2 0 1 1]);
uicontrol(handles.buttongroup, ...
'Style', 'radiobutton', ...
'String', 'steady state', ...
'Units', 'normalized', ...
'Position', [0.3 0 1 1]);
uicontrol(handles.buttongroup, ...
'Style', 'radiobutton', ...
'String', 'smoother', ...
'Units', 'normalized', ...
'Position', [0.5 0 1 1]);
% --- PUSHBUTTONS ------------------------------------- % --- PUSHBUTTONS -------------------------------------
handles.pushbuttonSimulation = uicontrol( ... handles.pushbuttonSimulation = uicontrol( ...
...@@ -172,7 +214,7 @@ handles.pushbuttonCommandDefinition = uicontrol( ... ...@@ -172,7 +214,7 @@ handles.pushbuttonCommandDefinition = uicontrol( ...
'Position', [0.02 0.10 0.96 0.6], ... 'Position', [0.02 0.10 0.96 0.6], ...
'ColumnName', {'Shock', 'Start', 'End', 'Value', 'Expect date', 'Unanticipated', 'Permanent', 'Remove'}, ... 'ColumnName', {'Shock', 'Start', 'End', 'Value', 'Expect date', 'Unanticipated', 'Permanent', 'Remove'}, ...
'ColumnFormat', {'char', 'numeric', 'numeric', 'char', 'numeric', 'logical', 'logical', 'logical' }, ... 'ColumnFormat', {'char', 'numeric', 'numeric', 'char', 'numeric', 'logical', 'logical', 'logical' }, ...
'ColumnEditable', {false, true, true, true, true, true, true, true}, ... 'ColumnEditable', [false, true, true, true, true, true, true, true], ...
'RowName', [], ... 'RowName', [], ...
'CellEditCallback', @savedata); 'CellEditCallback', @savedata);
...@@ -220,7 +262,6 @@ handles.pushbuttonCommandDefinition = uicontrol( ... ...@@ -220,7 +262,6 @@ handles.pushbuttonCommandDefinition = uicontrol( ...
= str2double(callbackdata.NewData); = str2double(callbackdata.NewData);
end end
elseif callbackdata.Indices(2) == 4 elseif callbackdata.Indices(2) == 4
callbackdata.NewData
if ~isempty(callbackdata.NewData) && (any(isnan(callbackdata.NewData)) || any(isinf(callbackdata.NewData))) if ~isempty(callbackdata.NewData) && (any(isnan(callbackdata.NewData)) || any(isinf(callbackdata.NewData)))
handles.shocks_table.Data{callbackdata.Indices(1), callbackdata.Indices(2)} = ''; handles.shocks_table.Data{callbackdata.Indices(1), callbackdata.Indices(2)} = '';
end end
...@@ -504,3 +545,30 @@ handles.pushbuttonCommandDefinition = uicontrol( ... ...@@ -504,3 +545,30 @@ handles.pushbuttonCommandDefinition = uicontrol( ...
json = savejson('', json, 'ParseLogical', 1, 'FileName', '', 'ArrayIndent', 0); json = savejson('', json, 'ParseLogical', 1, 'FileName', '', 'ArrayIndent', 0);
end end
end end
function init_val(~, evt, handles)
global oo_
if strcmp(evt.NewValue.String, 'zero')
handles.endoTable.Data(:,3) = num2cell(zeros(M_.orig_endo_nbr, 1));
elseif strcmp(evt.NewValue.String, 'steady state')
if ~isfield(oo_, 'steady_state')
gui_tools.show_warning('Must first calculate the steady state')
evt.OldValue.Value = 1;
return
end
handles.endoTable.Data(:,3) = num2cell(oo_.steady_state);
elseif strcmp(evt.NewValue.String, 'smoother')
if ~isfield(oo_, 'SmoothedVariables')
gui_tools.show_warning('Must first run smoother')
evt.OldValue.Value = 1;
return
end
fname = inputdlg('output file from smoother2histval');
if isempty(fname)
evt.OldValue.Value = 1;
else
histvalf(fname{:})
handles.endoTable.Data(:,3) = num2cell(M_.endo_histval);
end
end
end
\ No newline at end of file
...@@ -11,7 +11,7 @@ function gui_epilogue(tabId) ...@@ -11,7 +11,7 @@ function gui_epilogue(tabId)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2019 Dynare Team % Copyright (C) 2019-2020 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -28,7 +28,7 @@ function gui_epilogue(tabId) ...@@ -28,7 +28,7 @@ function gui_epilogue(tabId)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global project_info dynare_gui_ options_ model_settings oo_ M_ global M_
bg_color = char(getappdata(0, 'bg_color')); bg_color = char(getappdata(0, 'bg_color'));
special_color = char(getappdata(0, 'special_color')); special_color = char(getappdata(0, 'special_color'));
...@@ -68,12 +68,12 @@ handles.equations = uicontrol( ... ...@@ -68,12 +68,12 @@ handles.equations = uicontrol( ...
'Max', 3, ... 'Max', 3, ...
'Min', 1); 'Min', 1);
if exist(['+' M_.fname filesep 'epilogue.m'], 'file') == 2 if exist(['+' M_.fname filesep 'epilogue_dynamic.m'], 'file') == 2
% If the epilogue file already exists, parse it and set the edit box % If the epilogue file already exists, parse it and set the edit box
% string equal to the equations in the file % string equal to the equations in the file
eqs = regexp(fileread(['+' M_.fname filesep 'epilogue.m']), 'from.*', 'match', 'dotexceptnewline'); eqs = regexp(fileread(['+' M_.fname filesep 'epilogue_dynamic.m']), 'from.*', 'match', 'dotexceptnewline');
eqs = strrep(eqs, 'from simul_begin_date to simul_end_date do dseries__.', ''); eqs = strrep(eqs, 'from simul_begin_date to simul_end_date do ds.', '');
eqs = strrep(eqs, 'dseries__.', ''); eqs = strrep(eqs, 'ds.', '');
eqs = regexprep(eqs, '\s', ''); eqs = regexprep(eqs, '\s', '');
eqs = regexprep(eqs, ['\<(' strjoin(M_.endo_names, '|') ')\(t\)'], '$1'); eqs = regexprep(eqs, ['\<(' strjoin(M_.endo_names, '|') ')\(t\)'], '$1');
eqs = regexprep(eqs, '\(t\)=', '='); eqs = regexprep(eqs, '\(t\)=', '=');
...@@ -116,25 +116,48 @@ handles.pushbuttonEpilogue = uicontrol( ... ...@@ -116,25 +116,48 @@ handles.pushbuttonEpilogue = uicontrol( ...
max_lag(i) = abs(min(cellfun(@str2num, max_lag_eqs{i}))); max_lag(i) = abs(min(cellfun(@str2num, max_lag_eqs{i})));
end end
end end
equations = regexprep(equations, '(\w*)=', 'dseries__.$1(t)='); equations = regexprep(equations, '(\w*)=', 'ds.$1(t)=');
equations = regexprep(equations, ['\<(' strjoin([M_.endo_names; M_.exo_names], '|') ')(?!\()\>'], 'dseries__.$1(t)'); equations = regexprep(equations, ['\<(' strjoin([M_.endo_names; M_.exo_names], '|') ')(?!\()\>'], 'ds.$1(t)');
equations = regexprep(equations, ['\<(' strjoin([M_.endo_names; M_.exo_names], '|') ')\>\(\-'], 'dseries__.$1(t-'); equations = regexprep(equations, ['\<(' strjoin([M_.endo_names; M_.exo_names], '|') ')\>\(\-'], 'ds.$1(t-');
equations = regexprep(equations, ['\<(' strjoin(M_.param_names, '|') ')\>'], '${[''params('' num2str(find(not(cellfun(''isempty'',strfind(M_.param_names,$1))))) '')'']}'); equations = regexprep(equations, ['\<(' strjoin(M_.param_names, '|') ')\>'], '${[''params('' num2str(find(not(cellfun(''isempty'',strfind(M_.param_names,$1))))) '')'']}');
fidw = fopen(['+' M_.fname filesep 'epilogue.m'], 'w'); fidw = fopen(['+' M_.fname filesep 'epilogue_dynamic.m'], 'w');
if fidw < 0 if fidw < 0
gui_tools.show_warning(['Couldn''t open +' M_.fname filesep 'epilogue.m for writing']); gui_tools.show_warning(['Couldn''t open +' M_.fname filesep 'epilogue_dynamic.m for writing']);
return return
end end
fprintf(fidw, 'function dseries__ = epilogue(params, dseries__)\n'); fprintf(fidw, 'function ds = epilogue_dynamic(params, ds)\n');
fprintf(fidw, '%s\n', '% function dseries__ = epilogue(params, dseries__)'); fprintf(fidw, '%s\n', '% function ds = epilogue_dynamic(params, ds)');
fprintf(fidw, '%s\n', '% Epilogue file generated by Dynare GUI'); fprintf(fidw, '%s\n\n', '% Epilogue file generated by Dynare GUI');
fprintf(fidw, 'simul_end_date = lastdate(dseries__);\n\n'); fprintf(fidw, 'simul_end_date = lastdate(ds);\n\n');
for i = 1:length(equations) for i = 1:length(equations)
fprintf(fidw, 'simul_begin_date = firstobservedperiod(dseries__{''%s''}) + %d + 1;\n', strjoin(rhs{i}, ''','''), max_lag(i)); fprintf(fidw, 'if ~ds.exist(''%s'')\n', lhs{i});
fprintf(fidw, 'if ~dseries__.exist(''%s'')\n', lhs{i}); fprintf(fidw, ' ds = [ds dseries(NaN(ds.nobs,1), ds.firstdate, ''%s'')];\n', lhs{i});
fprintf(fidw, ' dseries__ = [dseries__ dseries(NaN(dseries__.nobs,1), dseries__.firstdate, ''%s'')];\n', lhs{i});
fprintf(fidw, 'end\n'); fprintf(fidw, 'end\n');
fprintf(fidw, 'try\n');
fprintf(fidw, ' simul_begin_date = firstobservedperiod(ds{''%s''}) + %d;\n', strjoin(rhs{i}, ''','''), max_lag(i));
fprintf(fidw, ' from simul_begin_date to simul_end_date do %s;\n\n', equations{i}); fprintf(fidw, ' from simul_begin_date to simul_end_date do %s;\n\n', equations{i});
fprintf(fidw, 'catch\n');
fprintf(fidw, 'end\n');
end
fprintf(fidw, 'end\n');
fclose(fidw);
fidw = fopen(['+' M_.fname filesep 'epilogue_static.m'], 'w');
if fidw < 0
gui_tools.show_warning(['Couldn''t open +' M_.fname filesep 'epilogue_static.m for writing']);
return
end
fprintf(fidw, 'function ds = epilogue_static(params, ds)\n');
fprintf(fidw, '%s\n', '% function ds = epilogue_static(params, ds)');
fprintf(fidw, '%s\n\n', '% Epilogue file generated by Dynare GUI');
equations = regexprep(equations, '.*=', '');
equations = regexprep(equations, '\(t((-\d)|(+d))?\)', '');
for i = 1:length(equations)
fprintf(fidw, 'epilogue_static_tmp_term = %s;\n', equations{i});
fprintf(fidw, 'if isdseries(epilogue_static_tmp_term)\n');
fprintf(fidw, ' ds.%s = epilogue_static_tmp_term;\n', lhs{i});
fprintf(fidw, 'else\n');
fprintf(fidw, ' ds.%s = dseries(ones(ds.nobs,1)*epilogue_static_tmp_term, ds.firstdate, ''%s'');\n', lhs{i}, lhs{i});
fprintf(fidw, 'end\n');
end end
fprintf(fidw, 'end\n'); fprintf(fidw, 'end\n');
fclose(fidw); fclose(fidw);
......
function gui_irf_calibration(tabId)
% function gui_irf_calibration(tabId)
% interface for the DYNARE irf_calibration command
%
% INPUTS
% tabId: GUI tab element which displays the irf_calibration interface
%
% OUTPUTS
% none
%
% 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 model_settings options_
handles = [];
gui_size = gui_tools.get_gui_elements_size(tabId);
uicontrol( ...
tabId, ...
'Tag', 'pushbuttonSimulation', ...
'Style', 'pushbutton', ...
'Units', 'normalized', ...
'Position', [gui_size.space gui_size.bottom gui_size.button_width_small gui_size.button_height], ...
'String', 'Run IRF Calibration', ...
'Callback', @call_irf_calibration);
uicontrol( ...
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);
uicontrol( ...
tabId, ...
'Tag', 'pushbuttonReset', ...
'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 Tab', ...
'Callback', {@close_tab, tabId});
handles.uipanelShocks = uipanel( ...
tabId, ...
'Tag', 'uipanelShocks', ...
'Units', 'normalized', ...
'Position', [0.01 0.1 .99 0.9], ...
'Title', '', ...
'BorderType', 'none');
handles.shocksTabGroup = uitabgroup( ...
handles.uipanelShocks, ...
'Position', [0 0 1 1]);
handles.shocks_tab = uitab( ...
handles.shocksTabGroup, ...
'Title', 'Shocks', ...
'UserData', 1);
handles.var_panel = uipanel( ...
handles.shocks_tab, ...
'BorderType', 'none');
uicontrol( ...
handles.var_panel, ...
'Style', 'text', ...
'Units', 'normalized', ...
'Position', [0.02 0.85 0.96 0.1], ...
'FontWeight', 'bold', ...
'String', 'Select variable and shock to define IRF calibration criteria.', ...
'HorizontalAlignment', 'left');
handles.relative_irf = uicontrol( ...
handles.var_panel, ...
'Style', 'checkbox', ...
'Units', 'normalized', ...
'Position', [0.02 0.82 0.96 0.1], ...
'String', 'relative_irf.', ...
'HorizontalAlignment', 'left');
endogs = model_settings.variables(:, 3);
list_endogs = uicontrol( ...
handles.var_panel, ...
'Style', 'popupmenu', ...
'Units', 'normalized', ...
'Position', [0.02 0.77 0.3 0.06], ...
'String', ['Select endog...'; endogs], ...
'Callback', @varlist_selection_changed);
shocks = model_settings.shocks(:, 3);
list_shocks = uicontrol( ...
handles.var_panel, ...
'Style', 'popupmenu', ...
'Units', 'normalized', ...
'Position', [0.36 0.77 0.3 0.06], ...
'String', ['Select shock...'; shocks], ...
'Callback', @varlist_selection_changed);
handles.add_var = uicontrol( ...
handles.var_panel, ...
'Style', 'pushbutton', ...
'Units', 'normalized', ...
'Position', [0.73 0.77 0.25 0.06], ...
'String', 'Add ...', ...
'Enable', 'Off', ...
'Callback', @add_var);
handles.table = uitable(handles.var_panel, ...
'Units', 'normalized', ...
'Position', [0.02 0.10 0.96 0.6], ...
'ColumnName', {'Varibale', 'Start Period', 'End Period', 'Exogenous', 'Sign', 'Start Interval', 'End Interval', 'Remove'}, ...
'ColumnFormat', {'char', 'numeric', 'numeric', 'char', 'char', 'numeric', 'numeric', 'logical'}, ...
'ColumnEditable', [false, true, true, false, true, true, true, true], ...
'RowName', [], ...
'CellEditCallback', @savedata);
handles.remove_all_selected = uicontrol( ...
handles.var_panel, ...
'Style', 'pushbutton', ...
'Units', 'normalized', ...
'Position', [0.73 0.03 0.25 0.06], ...
'String', 'Remove all selected', ...
'Enable', 'Off', ...
'Callback', @remove);
function varlist_selection_changed(~, ~)
if list_shocks.Value > 1 && list_endogs.Value > 1
handles.add_var.Enable = 'On';
else
handles.add_var.Enable = 'Off';
end
end
function add_var(~, ~)
if list_shocks.Value > 1 && list_endogs.Value > 1
handles.table.Data{end+1, 1} = endogs{list_endogs.Value-1};
handles.table.Data{end, 2} = '';
handles.table.Data{end, 3} = '';
handles.table.Data{end, 4} = shocks{list_shocks.Value-1};
handles.table.Data{end, 5} = '';
handles.table.Data{end, 6} = '';
handles.table.Data{end, 7} = '';
handles.table.Data{end, 8} = false;
end
end
function remove(~, ~)
handles.table.Data = ...
handles.table.Data(not([handles.table.Data{:, 8}]), :);
end
function savedata(~, callbackdata)
if callbackdata.Indices(2) == 2 || callbackdata.Indices(2) == 3
if isnan(str2double(callbackdata.NewData)) ...
|| str2double(callbackdata.NewData) < 0
handles.table.Data{callbackdata.Indices(1), callbackdata.Indices(2)} = ...
callbackdata.PreviousData;
end
elseif callbackdata.Indices(2) == 5
if ~strcmp(callbackdata.NewData, '-') ...
&& ~strcmp(callbackdata.NewData, '+')
handles.table.Data{callbackdata.Indices(1), callbackdata.Indices(2)} = ...
callbackdata.PreviousData;
end
elseif callbackdata.Indices(2) == 6 || callbackdata.Indices(2) == 7
if isnan(str2double(callbackdata.NewData))
handles.table.Data{callbackdata.Indices(1), callbackdata.Indices(2)} = ...
callbackdata.PreviousData;
end
elseif callbackdata.Indices(2) == 8
if any([handles.table.Data{:, 8}])
handles.remove_all_selected.Enable = 'On';
else
handles.remove_all_selected.Enable = 'Off';
end
end
end
function reset(~, ~)
handles.table.Data = cell(0, 8);
end
function call_irf_calibration(~, ~)
if handles.relative_irf.Value
options_.relative_irf = true;
else
options_.relative_irf = false;
end
r = rows(handles.table.Data);
options_.endogenous_prior_restrictions.irf = cell(r, 4);
for i = 1:r
options_.endogenous_prior_restrictions.irf{i, 1} = handles.table.Data{i, 1};
options_.endogenous_prior_restrictions.irf{i, 2} = handles.table.Data{i, 4};
if str2double(handles.table.Data{i, 2}) == str2double(handles.table.Data{i, 3})
options_.endogenous_prior_restrictions.irf{i, 3} = str2double(handles.table.Data{i, 2});
else
options_.endogenous_prior_restrictions.irf{i, 3} = str2double(handles.table.Data{i, 2}):str2double(handles.table.Data{i, 3});
end
if isempty(handles.table.Data{i, 5})
options_.endogenous_prior_restrictions.irf{i, 4} = [str2double(handles.table.Data{i, 6}), str2double(handles.table.Data{i, 7})];
else
if strcmp(handles.table.Data{i, 5}, '+')
options_.endogenous_prior_restrictions.irf{i, 4} = [0 inf];
else
options_.endogenous_prior_restrictions.irf{i, 4} = [-inf 0];
end
end
end
end
end
function close_tab(~, ~, hTab)
gui_tabs.delete_tab(hTab);
end
...@@ -11,7 +11,7 @@ function gui_load_mod_file(hObject) ...@@ -11,7 +11,7 @@ function gui_load_mod_file(hObject)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2019 Dynare Team % Copyright (C) 2003-2020 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -166,9 +166,7 @@ end ...@@ -166,9 +166,7 @@ end
if strcmp(answer,'No') if strcmp(answer,'No')
return return
end end
M_ = []; clear oo_ M_ options_ estim_params_ bayestopt_ estimation_info ex0_ ys0_ dataset_ dataset_info
oo_ = [];
options_ = [];
end end
%save globals %save globals
...@@ -185,12 +183,12 @@ end ...@@ -185,12 +183,12 @@ end
steady; steady;
oo_.dr.eigval = check(M_, options_, oo_); oo_.dr.eigval = check(M_, options_, oo_);
catch catch
gui_tools.show_error('Couldn''t find the steady state, so you need to fill in Model Settings->Steady State Guess before doing anything else'); gui_tools.show_warning('Couldn''t find the steady state, so you need to fill in Model Settings->Steady State Guess before doing anything else');
end end
jObj.stop; jObj.stop;
jObj.setBusyText('Done'); jObj.setBusyText('Done');
%restore globals %restore GUI globals
evalin('base', 'global dynare_gui_ project_info model_settings'); evalin('base', 'global dynare_gui_ project_info model_settings');
dynare_gui_ = glob_dynare_gui_; dynare_gui_ = glob_dynare_gui_;
project_info = glob_project_info; project_info = glob_project_info;
......
function gui_moment_calibration(tabId)
% function gui_moment_calibration(tabId)
% interface for the DYNARE moment_calibration command
%
% INPUTS
% tabId: GUI tab element which displays the moment_calibration interface
%
% OUTPUTS
% none
%
% 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 model_settings options_
handles = [];
gui_size = gui_tools.get_gui_elements_size(tabId);
uicontrol( ...
tabId, ...
'Tag', 'pushbuttonSimulation', ...
'Style', 'pushbutton', ...
'Units', 'normalized', ...
'Position', [gui_size.space gui_size.bottom gui_size.button_width_small gui_size.button_height], ...
'String', 'Run Moment Calibration', ...
'Callback', @call_moment_calibration);
uicontrol( ...
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);
uicontrol( ...
tabId, ...
'Tag', 'pushbuttonReset', ...
'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 Tab', ...
'Callback', {@close_tab, tabId});
handles.panel = uipanel( ...
tabId, ...
'Tag', 'panel', ...
'Units', 'normalized', ...
'Position', [0.01 0.1 .99 0.9], ...
'Title', '', ...
'BorderType', 'none');
handles.tabGroup = uitabgroup( ...
handles.panel, ...
'Position', [0 0 1 1]);
handles.tab = uitab( ...
handles.tabGroup, ...
'Title', 'Variables', ...
'UserData', 1);
handles.var_panel = uipanel( ...
handles.tab, ...
'BorderType', 'none');
uicontrol( ...
handles.var_panel, ...
'Style', 'text', ...
'Units', 'normalized', ...
'Position', [0.02 0.85 0.96 0.1], ...
'FontWeight', 'bold', ...
'String', 'Select variable and shock to define Moment calibration criteria.', ...
'HorizontalAlignment', 'left');
endogs = model_settings.variables(:, 3);
list_endogs1 = uicontrol( ...
handles.var_panel, ...
'Style', 'popupmenu', ...
'Units', 'normalized', ...
'Position', [0.02 0.77 0.3 0.06], ...
'String', ['Select endog...'; endogs], ...
'Callback', @varlist_selection_changed);
list_endogs2 = uicontrol( ...
handles.var_panel, ...
'Style', 'popupmenu', ...
'Units', 'normalized', ...
'Position', [0.36 0.77 0.3 0.06], ...
'String', ['Select shock...'; endogs], ...
'Callback', @varlist_selection_changed);
handles.add_var = uicontrol( ...
handles.var_panel, ...
'Style', 'pushbutton', ...
'Units', 'normalized', ...
'Position', [0.73 0.77 0.25 0.06], ...
'String', 'Add ...', ...
'Enable', 'Off', ...
'Callback', @add_var);
handles.table = uitable(handles.var_panel, ...
'Units', 'normalized', ...
'Position', [0.02 0.10 0.96 0.6], ...
'ColumnName', {'Varibale1', 'Variable2', 'Period Sign', 'Start Period', 'End Period', 'Sign', 'Start Interval', 'End Interval', 'Remove'}, ...
'ColumnFormat', {'char', 'char', 'char', 'numeric', 'numeric', 'char', 'numeric', 'numeric', 'logical'}, ...
'ColumnEditable', [false, false, true, true, true, true, true, true, true], ...
'RowName', [], ...
'CellEditCallback', @savedata);
handles.remove_all_selected = uicontrol( ...
handles.var_panel, ...
'Style', 'pushbutton', ...
'Units', 'normalized', ...
'Position', [0.73 0.03 0.25 0.06], ...
'String', 'Remove all selected', ...
'Enable', 'Off', ...
'Callback', @remove);
function varlist_selection_changed(~, ~)
if list_endogs1.Value > 1 && list_endogs2.Value > 1
handles.add_var.Enable = 'On';
else
handles.add_var.Enable = 'Off';
end
end
function add_var(~, ~)
if list_endogs1.Value > 1 && list_endogs2.Value > 1
handles.table.Data{end+1, 1} = endogs{list_endogs1.Value-1};
handles.table.Data{end, 2} = endogs{list_endogs2.Value-1};
handles.table.Data{end, 3} = '';
handles.table.Data{end, 4} = '';
handles.table.Data{end, 5} = '';
handles.table.Data{end, 6} = '';
handles.table.Data{end, 7} = '';
handles.table.Data{end, 8} = '';
handles.table.Data{end, 9} = false;
end
end
function remove(~, ~)
handles.table.Data = ...
handles.table.Data(not([handles.table.Data{:, 9}]), :);
end
function savedata(~, callbackdata)
if callbackdata.Indices(2) == 4 || callbackdata.Indices(2) == 5
if isnan(str2double(callbackdata.NewData))
handles.table.Data{callbackdata.Indices(1), callbackdata.Indices(2)} = ...
callbackdata.PreviousData;
end
elseif callbackdata.Indices(2) == 3 || callbackdata.Indices(2) == 6
if ~strcmp(callbackdata.NewData, '-') ...
&& ~strcmp(callbackdata.NewData, '+')
handles.table.Data{callbackdata.Indices(1), callbackdata.Indices(2)} = ...
callbackdata.PreviousData;
end
elseif callbackdata.Indices(2) == 7 || callbackdata.Indices(2) == 8
if isnan(str2double(callbackdata.NewData))
handles.table.Data{callbackdata.Indices(1), callbackdata.Indices(2)} = ...
callbackdata.PreviousData;
end
elseif callbackdata.Indices(2) == 9
if any([handles.table.Data{:, 9}])
handles.remove_all_selected.Enable = 'On';
else
handles.remove_all_selected.Enable = 'Off';
end
end
end
function reset(~, ~)
handles.table.Data = cell(0, 9);
end
function call_moment_calibration(~, ~)
r = rows(handles.table.Data);
options_.endogenous_prior_restrictions.moment = cell(r, 4);
for i = 1:r
options_.endogenous_prior_restrictions.moment{i, 1} = handles.table.Data{i, 1};
options_.endogenous_prior_restrictions.moment{i, 2} = handles.table.Data{i, 2};
sign = 1;
if strcmp(handles.table.Data{i, 3}, '-')
sign = -1;
end
if str2double(handles.table.Data{i, 4}) == str2double(handles.table.Data{i, 5})
options_.endogenous_prior_restrictions.moment{i, 3} = sign*str2double(handles.table.Data{i, 4});
else
options_.endogenous_prior_restrictions.moment{i, 3} = sign*(str2double(handles.table.Data{i, 4}):str2double(handles.table.Data{i, 5}));
end
if isempty(handles.table.Data{i, 6})
options_.endogenous_prior_restrictions.moment{i, 4} = [str2double(handles.table.Data{i, 7}), str2double(handles.table.Data{i, 8})];
else
if strcmp(handles.table.Data{i, 6}, '+')
options_.endogenous_prior_restrictions.moment{i, 4} = [0 inf];
else
options_.endogenous_prior_restrictions.moment{i, 4} = [-inf 0];
end
end
end
end
end
function close_tab(~, ~, hTab)
gui_tabs.delete_tab(hTab);
end
...@@ -104,6 +104,8 @@ handles.pushbuttonReset = uicontrol( ... ...@@ -104,6 +104,8 @@ handles.pushbuttonReset = uicontrol( ...
handles.use_shock_groups.Value = 0; handles.use_shock_groups.Value = 0;
handles.fig_name.String = ''; handles.fig_name.String = '';
handles.vintage.String = ''; handles.vintage.String = '';
handles.plot_init_date.String = '';
handles.plot_end_date.String = '';
end end
handles.pushbuttonCloseAll = uicontrol( ... handles.pushbuttonCloseAll = uicontrol( ...
...@@ -331,18 +333,11 @@ handles.pushbuttonClose = uicontrol( ... ...@@ -331,18 +333,11 @@ handles.pushbuttonClose = uicontrol( ...
'String', 'realtime:', ... 'String', 'realtime:', ...
'HorizontalAlignment', 'left'); 'HorizontalAlignment', 'left');
if project_info.stochastic_simulation_run && project_info.realtime_shock_decomposition_run
realtimestring = {'standard historical shock decomposition', ... realtimestring = {'standard historical shock decomposition', ...
'realtime historical shock decomposition', ... 'realtime historical shock decomposition', ...
'conditional realtime shock decomposition', ... 'conditional realtime shock decomposition', ...
'realtime forecast shock decomposition'}; 'realtime forecast shock decomposition'};
elseif project_info.stochastic_simulation_run
realtimestring = {'standard historical shock decomposition'};
else
realtimestring = {'realtime historical shock decomposition', ...
'conditional realtime shock decomposition', ...
'realtime forecast shock decomposition'};
end
handles.realtime = uicontrol( ... handles.realtime = uicontrol( ...
'Parent', handles.uipanelResults, ... 'Parent', handles.uipanelResults, ...
'Tag', 'realtime', ... 'Tag', 'realtime', ...
...@@ -355,47 +350,121 @@ handles.pushbuttonClose = uicontrol( ... ...@@ -355,47 +350,121 @@ handles.pushbuttonClose = uicontrol( ...
num = num + 1; num = num + 1;
uicontrol( ... uicontrol( ...
'Parent', handles.uipanelResults, ... 'Parent', handles.uipanelResults, ...
'Tag', 'text8', ... 'Tag', 'vintage', ...
'Style', 'text', ... 'Style', 'text', ...
'Units', 'normalized', ... 'Units', 'normalized', ...
'Position', [spc*3 top-num*dheight dwidth*1.5 dheight/2], ... 'Position', [spc*3 top-num*dheight dwidth*1.5 dheight/2], ...
'String', 'vintage:', ... 'String', 'vintage:', ...
'HorizontalAlignment', 'left'); 'HorizontalAlignment', 'left');
if ~project_info.realtime_shock_decomposition_run
enable = 'Off';
else
enable = 'On';
end
handles.vintage = uicontrol( ... handles.vintage = uicontrol( ...
'Parent', handles.uipanelResults, ... 'Parent', handles.uipanelResults, ...
'Tag', 'vintage', ... 'Tag', 'vintage', ...
'String', '0', ...
'Style', 'edit', ...
'Units', 'normalized', ...
'Position', [spc*3+dwidth*1.5 top-num*dheight dwidth*2 dheight/2], ...
'Value', 0);
num = num + 1;
uicontrol( ...
'Parent', handles.uipanelResults, ...
'Tag', 'plot_init_date', ...
'Style', 'text', ...
'Units', 'normalized', ...
'Position', [spc*3 top-num*dheight dwidth*1.5 dheight/2], ...
'String', 'plot_init_date:', ...
'HorizontalAlignment', 'left');
handles.plot_init_date = uicontrol( ...
'Parent', handles.uipanelResults, ...
'Tag', 'plot_init_date', ...
'String', '', ...
'Style', 'edit', ...
'Units', 'normalized', ...
'Position', [spc*3+dwidth*1.5 top-num*dheight dwidth*2 dheight/2], ...
'Value', 0);
num = num + 1;
uicontrol( ...
'Parent', handles.uipanelResults, ...
'Tag', 'plot_end_date', ...
'Style', 'text', ...
'Units', 'normalized', ...
'Position', [spc*3 top-num*dheight dwidth*1.5 dheight/2], ...
'String', 'plot_end_date:', ...
'HorizontalAlignment', 'left');
handles.plot_end_date = uicontrol( ...
'Parent', handles.uipanelResults, ...
'Tag', 'plot_end_date', ...
'String', '', ...
'Style', 'edit', ... 'Style', 'edit', ...
'Units', 'normalized', ... 'Units', 'normalized', ...
'Position', [spc*3+dwidth*1.5 top-num*dheight dwidth*2 dheight/2], ... 'Position', [spc*3+dwidth*1.5 top-num*dheight dwidth*2 dheight/2], ...
'Value', 0, ... 'Value', 0);
'Enable', enable);
num = num + 1;
uicontrol( ...
'Parent', handles.uipanelResults, ...
'Tag', 'use_shock_groups', ...
'Style', 'text', ...
'Units', 'normalized', ...
'Position', [spc*3 top-num*dheight dwidth*1.5 dheight/2], ...
'String', 'use_shock_groups:', ...
'HorizontalAlignment', 'left');
shock_group_options = {''};
if isfield(M_, 'shock_groups')
shock_group_options = [shock_group_options; fieldnames(M_.shock_groups)];
end
handles.use_shock_groups = uicontrol( ... handles.use_shock_groups = uicontrol( ...
'Parent', handles.uipanelResults, ... 'Parent', handles.uipanelResults, ...
'Style', 'checkbox',... 'Tag', 'use_shock_groups', ...
'Style', 'popupmenu', ...
'Units', 'normalized', ... 'Units', 'normalized', ...
'Position', [spc top-num*dheight 1-spc*4 dheight/2], ... 'Position', [spc*3+dwidth*1.5 top-num*dheight dwidth*2 dheight/2], ...
'String', 'use_shock_groups'); 'String', shock_group_options);
end end
function pushbuttonPlotShockDecomposition_Callback(hObject, ~) function pushbuttonPlotShockDecomposition_Callback(hObject, ~)
old_options = options_; old_options = options_;
if project_info.realtime_shock_decomposition_run if isempty(str2double(handles.vintage.String)) ...
if ~isnumeric(handles.vintage.Value) ... || ~isint(str2double(handles.vintage.String)) ...
|| ~isint(num2str(handles.vintage.Value)) ... || str2double(handles.vintage.String) < 0
|| num2str(handles.vintage.Value) < 0
gui_tools.show_warning('Vintage must be an integer >= 0'); gui_tools.show_warning('Vintage must be an integer >= 0');
uicontrol(hObject); uicontrol(hObject);
return return
end end
options_.plot_shock_decomp.vintage = handles.vintage.Value; options_.plot_shock_decomp.vintage = str2double(handles.vintage.String);
if ~isempty(handles.plot_init_date.String)
if isint(str2double(handles.plot_init_date.String))
options_.plot_shock_decomp.plot_init_date = str2double(handles.plot_init_date.String);
elseif isdate(handles.plot_init_date.String)
options_.plot_shock_decomp.plot_init_date = dates(handles.plot_init_date.String);
else
gui_tools.show_warning('Initial date must be an integer or a date');
uicontrol(hObject);
return
end
else
options_.plot_shock_decomp.plot_init_date = '';
end
if ~isempty(handles.plot_end_date.String)
if isint(str2double(handles.plot_end_date.String))
options_.plot_shock_decomp.plot_end_date = str2double(handles.plot_end_date.String);
elseif isdate(handles.plot_end_date.String)
options_.plot_shock_decomp.plot_end_date = dates(handles.plot_end_date.String);
else
gui_tools.show_warning('End date must be an integer or a date');
uicontrol(hObject);
return
end
else
options_.plot_shock_decomp.plot_end_date = '';
end end
if handles.colormap.Value ~= 1 if handles.colormap.Value ~= 1
...@@ -443,13 +512,8 @@ handles.pushbuttonClose = uicontrol( ... ...@@ -443,13 +512,8 @@ handles.pushbuttonClose = uicontrol( ...
options_.plot_shock_decomp.write_xls = true; options_.plot_shock_decomp.write_xls = true;
end end
if project_info.stochastic_simulation_run && project_info.realtime_shock_decomposition_run options_.plot_shock_decomp.use_shock_groups = handles.use_shock_groups.String{handles.use_shock_groups.Value};
options_.plot_shock_decomp.realtime = handles.realtime.Value - 1; options_.plot_shock_decomp.realtime = handles.realtime.Value - 1;
elseif project_info.stochastic_simulation_run
options_.plot_shock_decomp.realtime = 0;
else
options_.plot_shock_decomp.realtime = handles.realtime.Value;
end
gui_tools.project_log_entry('Running plot shock decomposition', '...'); gui_tools.project_log_entry('Running plot shock decomposition', '...');
[jObj, guiObj] = gui_tools.create_animated_screen('Running plot shock decomposition, please wait...', tabId); [jObj, guiObj] = gui_tools.create_animated_screen('Running plot shock decomposition, please wait...', tabId);
......
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'
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});
assignin('base', 'posterior_irf', posterior_irf);
case '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
assignin('base', 'posterior_covariance', posterior_covariance);
case 'Smoother'
if sum([handles.endoTable.Data{:,1}]) ~= 1
gui_tools.show_error('For Smoother you must choose 1 endogenous variable');
end
posterior_smoother = get_posterior_timeseries('smoothed', ...
handles.endoTable.Data{[handles.endoTable.Data{:,1}],2});
assignin('base', 'posterior_smoother', posterior_smoother);
case 'Filter'
if sum([handles.endoTable.Data{:,1}]) ~= 1
gui_tools.show_error('For Filter you must choose 1 endogenous variable');
end
posterior_filter = get_posterior_timeseries('filtered', ...
handles.endoTable.Data{[handles.endoTable.Data{:,1}],2});
assignin('base', 'posterior_filter', posterior_filter);
case 'Update'
if sum([handles.endoTable.Data{:,1}]) ~= 1
gui_tools.show_error('For Update you must choose 1 endogenous variable');
end
posterior_update = get_posterior_timeseries('updated', ...
handles.endoTable.Data{[handles.endoTable.Data{:,1}],2});
assignin('base', 'posterior_update', posterior_update);
case 'Forecast'
if sum([handles.endoTable.Data{:,1}]) ~= 1
gui_tools.show_error('For Forecast you must choose 1 endogenous variable');
end
posterior_forecast = get_posterior_timeseries('forecast', ...
handles.endoTable.Data{[handles.endoTable.Data{:,1}],2});
assignin('base', 'posterior_forecast', posterior_forecast);
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
...@@ -13,7 +13,7 @@ function gui_project(tabId, oid) ...@@ -13,7 +13,7 @@ function gui_project(tabId, oid)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2019 Dynare Team % Copyright (C) 2003-2020 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -111,7 +111,7 @@ uicontrol(tabId, ... ...@@ -111,7 +111,7 @@ uicontrol(tabId, ...
gui_tools.project_log_entry('Creating new project', ['project_name: ' project_info.project_name]); gui_tools.project_log_entry('Creating new project', ['project_name: ' project_info.project_name]);
end end
gui_tools.save_project(); gui_tools.save_project();
set(handles.project_name, 'Enable', 'Off'); handles.project_name.Enable = 'Off';
gui_tabs.rename_tab(tabId, ['Project: ' project_info.project_name]); gui_tabs.rename_tab(tabId, ['Project: ' project_info.project_name]);
end end
elseif strcmp(oid,'Save') || strcmp(oid,'Open') elseif strcmp(oid,'Save') || strcmp(oid,'Open')
...@@ -142,8 +142,7 @@ uicontrol(tabId, ... ...@@ -142,8 +142,7 @@ uicontrol(tabId, ...
end end
if strcmp(oid,'New') || strcmp(oid,'Open') || strcmp(oid,'Save As') || ~strcmp(project_info.project_folder, old_project_folder) if strcmp(oid,'New') || strcmp(oid,'Open') || strcmp(oid,'Save As') || ~strcmp(project_info.project_folder, old_project_folder)
% change current folder to project folder cd(project_info.project_folder);
eval(sprintf('cd ''%s'' ',project_info.project_folder));
end end
% close tab on successful save and prompt to load .mod file % close tab on successful save and prompt to load .mod file
gui_load_mod_file(tabId) gui_load_mod_file(tabId)
......
...@@ -269,6 +269,15 @@ handles.pushbuttonClose = uicontrol( ... ...@@ -269,6 +269,15 @@ handles.pushbuttonClose = uicontrol( ...
'Position', [spc*3+dwidth*1.5 top-num*dheight dwidth*2 dheight/2], ... 'Position', [spc*3+dwidth*1.5 top-num*dheight dwidth*2 dheight/2], ...
'String', {'qoq','yoy','aoa'}, ... 'String', {'qoq','yoy','aoa'}, ...
'Value', 1); 'Value', 1);
num = num+1.5;
handles.noGraph = uicontrol(...
'Parent', handles.uipanelResults, ...
'Style','checkbox',...
'Units', 'normalized', ...
'Position', [spc top-num*dheight 1-spc*4 dheight/2], ...
'String', 'Only compute shock decomposition, do not plot',...
'FontWeight', 'bold');
end end
function pushbuttonShockDecomposition_Callback(hObject, ~) function pushbuttonShockDecomposition_Callback(hObject, ~)
...@@ -300,6 +309,8 @@ handles.pushbuttonClose = uicontrol( ... ...@@ -300,6 +309,8 @@ handles.pushbuttonClose = uicontrol( ...
options_.nodisplay = 0; options_.nodisplay = 0;
options_.plot_priors = 0; options_.plot_priors = 0;
options_.type = handles.type.String; options_.type = handles.type.String;
options_.no_graph.shock_decomposition = handles.noGraph.Value;
gui_tools.project_log_entry('Running shock decomposition','...'); gui_tools.project_log_entry('Running shock decomposition','...');
[jObj, guiObj] = gui_tools.create_animated_screen('Running shock decomposition, please wait...', tabId); [jObj, guiObj] = gui_tools.create_animated_screen('Running shock decomposition, please wait...', tabId);
var_list_ = handles.endoTable.Data([handles.endoTable.Data{:,1}], 2); var_list_ = handles.endoTable.Data([handles.endoTable.Data{:,1}], 2);
...@@ -394,6 +405,7 @@ handles.pushbuttonClose = uicontrol( ... ...@@ -394,6 +405,7 @@ handles.pushbuttonClose = uicontrol( ...
handles.lastPeriodYear.Value = handles.lastPeriodYearDefault; handles.lastPeriodYear.Value = handles.lastPeriodYearDefault;
handles.useShockGrouping.Value = 0; handles.useShockGrouping.Value = 0;
handles.type.Value = 1; handles.type.Value = 1;
handles.noGraph = 0;
end end
function close_tab(~, ~, hTab) function close_tab(~, ~, hTab)
......
...@@ -11,7 +11,7 @@ function gui_sensitivity_analysis(tabId) ...@@ -11,7 +11,7 @@ function gui_sensitivity_analysis(tabId)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2019 Dynare Team % Copyright (C) 2019-2020 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -35,6 +35,8 @@ bg_color = char(getappdata(0, 'bg_color')); ...@@ -35,6 +35,8 @@ bg_color = char(getappdata(0, 'bg_color'));
handles = []; handles = [];
gui_size = gui_tools.get_gui_elements_size(tabId); gui_size = gui_tools.get_gui_elements_size(tabId);
do_not_check_all_results = 0;
if ~isfield(model_settings, 'sensitivity') if ~isfield(model_settings, 'sensitivity')
model_settings.sensitivity = struct(); model_settings.sensitivity = struct();
end end
...@@ -52,7 +54,8 @@ handles.sensitivity = uicontrol( ... ...@@ -52,7 +54,8 @@ handles.sensitivity = uicontrol( ...
'Tag', 'sensitivity', ... 'Tag', 'sensitivity', ...
'Style', 'text', 'BackgroundColor', bg_color,... 'Style', 'text', 'BackgroundColor', bg_color,...
'Units', 'normalized', 'Position', [0.01 0.01 0.98 0.98], ... 'Units', 'normalized', 'Position', [0.01 0.01 0.98 0.98], ...
'FontAngle', 'italic','String', comm_str, ... 'FontAngle', 'italic', ...
'String', comm_str, ...
'TooltipString', comm_str, ... 'TooltipString', comm_str, ...
'HorizontalAlignment', 'left'); 'HorizontalAlignment', 'left');
...@@ -68,20 +71,54 @@ handles.pushbuttonSensitivity = uicontrol( ... ...@@ -68,20 +71,54 @@ handles.pushbuttonSensitivity = uicontrol( ...
old_oo_ = oo_; old_oo_ = oo_;
old_options_ = options_; old_options_ = options_;
try try
options_ = struct();
if ~isempty(model_settings.sensitivity) if ~isempty(model_settings.sensitivity)
names = fieldnames(model_settings.sensitivity); names = fieldnames(model_settings.sensitivity);
options_gsa = model_settings.sensitivity;
options_ = old_options_;
for ii = 1:size(names, 1) for ii = 1:size(names, 1)
if isempty(model_settings.sensitivity.(names{ii})) switch names{ii}
gui_auxiliary.set_command_option(names{ii}, 1, 'check_option'); case 'ilptau'
if options_gsa.(names{ii}) == 2
options_gsa.ilptau = 0;
end
case 'pprior'
if options_gsa.(names{ii}) == 2
options_gsa.pprior = 0;
end
case 'prior_range'
if options_gsa.(names{ii}) == 2
options_gsa.prior_range = 0;
end
case 'stab'
if options_gsa.(names{ii}) == 2
options_gsa.stab = 0;
end
case 'namendo'
if contains(options_gsa.(names{ii}), ',')
namendo_ = strsplit(options_gsa.(names{ii}), ',');
options_gsa.namendo = namendo_;
else else
gui_auxiliary.set_command_option(names{ii}, model_settings.sensitivity.(names{ii})); options_gsa.namendo = {options_gsa.(names{ii})};
end
case 'namlagendo'
if contains(options_gsa.(names{ii}), ',')
namlagendo_ = strsplit(options_gsa.(names{ii}), ',');
options_gsa.namlagendo = namlagendo_;
else
options_gsa.namlagendo = {options_gsa.(names{ii})};
end
case 'namexo'
if contains(options_gsa.(names{ii}), ',')
namexo_ = strsplit(options_gsa.(names{ii}), ',');
options_gsa.namexo = namexo_;
else
options_gsa.namexo = {options_gsa.(names{ii})};
end
case 'threshold_redform'
options_gsa.threshold_redform = str2num(options_gsa.(names{ii}));
end end
end end
end end
options_gsa = options_;
options_ = old_options_;
gui_tools.project_log_entry('Running stochastic sensitivity','...'); gui_tools.project_log_entry('Running stochastic sensitivity','...');
[jObj, guiObj] = gui_tools.create_animated_screen('Running stochastic sensitivity, please wait...', tabId); [jObj, guiObj] = gui_tools.create_animated_screen('Running stochastic sensitivity, please wait...', tabId);
handles.pushbuttonResults.Enable = 'off'; handles.pushbuttonResults.Enable = 'off';
...@@ -128,7 +165,7 @@ handles.pushbuttonCommandDefinition = uicontrol( ... ...@@ -128,7 +165,7 @@ handles.pushbuttonCommandDefinition = uicontrol( ...
try try
new_comm = getappdata(0, 'sensitivity'); new_comm = getappdata(0, 'sensitivity');
model_settings.sensitivity = new_comm; model_settings.sensitivity = new_comm;
comm_str = gui_tools.command_string('dynare_sensitivity', new_comm); comm_str = gui_tools.command_string('sensitivity', new_comm);
handles.sensitivity.String = comm_str; handles.sensitivity.String = comm_str;
gui_tools.project_log_entry('Defined sensitivity command',comm_str); gui_tools.project_log_entry('Defined sensitivity command',comm_str);
......
...@@ -11,7 +11,7 @@ function gui_set_menus(enable) ...@@ -11,7 +11,7 @@ function gui_set_menus(enable)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2019 Dynare Team % Copyright (C) 2019-2020 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -40,6 +40,7 @@ gui_tools.menu_options('stochastic','Off'); ...@@ -40,6 +40,7 @@ gui_tools.menu_options('stochastic','Off');
gui_tools.menu_options('deterministic','Off'); gui_tools.menu_options('deterministic','Off');
gui_tools.menu_options('sensitivity', 'Off'); gui_tools.menu_options('sensitivity', 'Off');
gui_tools.menu_options('epilogue', 'Off'); gui_tools.menu_options('epilogue', 'Off');
gui_tools.menu_options('posterior', 'Off');
if isempty(model_settings) || isempty(fieldnames(model_settings)) if isempty(model_settings) || isempty(fieldnames(model_settings))
return return
...@@ -51,6 +52,7 @@ if enable ...@@ -51,6 +52,7 @@ if enable
return return
end end
gui_tools.menu_options('epilogue', 'On'); gui_tools.menu_options('epilogue', 'On');
gui_tools.menu_options('posterior', 'On');
if project_info.project_model_stochastic if project_info.project_model_stochastic
gui_tools.menu_options('estimation', 'On'); gui_tools.menu_options('estimation', 'On');
gui_tools.menu_options('stochastic', 'On'); gui_tools.menu_options('stochastic', 'On');
......
...@@ -247,6 +247,15 @@ handles.pushbuttonClose = uicontrol( ... ...@@ -247,6 +247,15 @@ handles.pushbuttonClose = uicontrol( ...
'Position', [spc*3+dwidth*1.5 top-num*dheight dwidth*2 dheight/2], ... 'Position', [spc*3+dwidth*1.5 top-num*dheight dwidth*2 dheight/2], ...
'String', {'qoq','yoy','aoa'}, ... 'String', {'qoq','yoy','aoa'}, ...
'Value', 1); 'Value', 1);
num = num+1.5;
handles.noGraph = uicontrol(...
'Parent', handles.uipanelResults, ...
'Style','checkbox',...
'Units', 'normalized', ...
'Position', [spc top-num*dheight 1-spc*4 dheight/2], ...
'String', 'Only compute shock decomposition, do not plot',...
'FontWeight', 'bold');
end end
function pushbuttonShockDecomposition_Callback(hObject, ~) function pushbuttonShockDecomposition_Callback(hObject, ~)
...@@ -305,6 +314,7 @@ handles.pushbuttonClose = uicontrol( ... ...@@ -305,6 +314,7 @@ handles.pushbuttonClose = uicontrol( ...
options_.model_settings.shocks = model_settings.shocks; options_.model_settings.shocks = model_settings.shocks;
options_.shock_grouping = handles.useShockGrouping.Value; options_.shock_grouping = handles.useShockGrouping.Value;
options_.shock_decomp.init_state = handles.useInitState.Value; options_.shock_decomp.init_state = handles.useInitState.Value;
options_.no_graph.shock_decomposition = handles.noGraph.Value;
oo_ = shock_decomposition(M_, oo_, options_, var_list_, bayestopt_, estim_params_); oo_ = shock_decomposition(M_, oo_, options_, var_list_, bayestopt_, estim_params_);
end end
jObj.stop; jObj.stop;
...@@ -370,6 +380,7 @@ handles.pushbuttonClose = uicontrol( ... ...@@ -370,6 +380,7 @@ handles.pushbuttonClose = uicontrol( ...
handles.useShockGrouping.Value = 0; handles.useShockGrouping.Value = 0;
handles.useInitState.Value = 0; handles.useInitState.Value = 0;
handles.type.Value = 1; handles.type.Value = 1;
handles.noGraph = 0;
end end
function close_tab(~, ~, hTab) function close_tab(~, ~, hTab)
......
function gui_smoother2histval(tabId)
% function gui_smoother2histval(tabId)
% interface for the DYNARE smoother2histval command
%
% INPUTS
% tabId: GUI tab element which displays smoother2histval command interface
%
% OUTPUTS
% none
%
% 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 project_info options_ model_settings oo_ estim_params_ M_ bayestopt_
handles = [];
gui_size = gui_tools.get_gui_elements_size(tabId);
model_settings.smoother2histval = struct();
model_settings.smoother2histval.period = options_.nobs;
model_settings.smoother2histval.invars = [strjoin(M_.endo_names(1:M_.orig_endo_nbr), ',') ',' strjoin(M_.exo_names, ',')];
model_settings.smoother2histval.outvars = model_settings.smoother2histval.invars;
% --- PANELS -------------------------------------
handles.uipanelVars = uipanel(tabId, ...
'Units', 'normalized', ...
'Position', [0.01 0.18 0.48 0.73], ...
'Title', '', ...
'BorderType', 'none');
handles = gui_tabs.create_endo_vars(handles, 'smoother2histval');
handles.endoTable.Data(:, 1) = {true};
handles.endoTable.CellEditCallback = @selectVar;
handles.command_options = uipanel(tabId, ...
'Units', 'normalized', ...
'Position', [0.51 0.7 0.48 0.2], ...
'Title', 'Command options:');
command_options_CreateFcn;
handles.uipanelShocks = uipanel( ...
'Parent', tabId, ...
'Tag', 'uipanelShocks', ...
'Units', 'normalized', ...
'Position', [0.51 0.18 0.48 0.5], ...
'Title', '', ...
'BorderType', 'none');
uipanelShocks_CreateFcn;
function uipanelShocks_CreateFcn()
data = cell(size(model_settings.shocks, 1), 2);
data(:,1) = {true};
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], ...
'CellEditCallback', @selectVar);
end
handles.uipanelComm = uipanel(tabId, ...
'UserData', zeros(1,0), ...
'Units', 'normalized', ...
'Position', [0.01 0.09 0.98 0.09], ...
'Title', 'Current command options:');
uicontrol(tabId, ...
'Style', 'text', ...
'Units','normalized', ...
'Position',[0.01 0.92 0.48 0.05], ...
'FontWeight', 'bold', ...
'String', 'Select variables to be used by smoother2histval:', ...
'HorizontalAlignment', 'left');
comm_str = gui_tools.command_string('smoother2histval', model_settings.smoother2histval);
handles.smoother2histval = uicontrol(handles.uipanelComm, ...
'Style', 'text', ...
'Units', 'normalized', ...
'Position', [0.01 0.01 0.98 0.98], ...
'FontAngle', 'italic', ...
'String', comm_str, ...
'HorizontalAlignment', 'left');
handles.RunSmoother2histval = uicontrol(tabId, ...
'Style', 'pushbutton', ...
'Units', 'normalized', ...
'Position', [gui_size.space gui_size.bottom gui_size.button_width gui_size.button_height], ...
'String', 'Run smoother2histval', ...
'Callback', @RunSmoother2histvalCallback);
handles.Reset = uicontrol(tabId, ...
'Style', 'pushbutton', ...
'Units','normalized', ...
'Position', [gui_size.space*2+gui_size.button_width gui_size.bottom gui_size.button_width gui_size.button_height], ...
'String', 'Reset', ...
'Callback', @Reset_Callback);
handles.Close = uicontrol(tabId, ...
'Style', 'pushbutton', ...
'Units', 'normalized', ...
'Position', [gui_size.space*3+gui_size.button_width*2 gui_size.bottom gui_size.button_width gui_size.button_height], ...
'String', 'Close tab', ...
'Callback', {@close_tab, tabId});
function command_options_CreateFcn()
uicontrol(handles.command_options, ...
'Style', 'text', ...
'Units', 'normalized', ...
'Position', [.05 .8 .3 .17], ...
'String', 'infile:', ...
'HorizontalAlignment', 'left');
handles.infile = uicontrol(handles.command_options, ...
'Style', 'edit', ...
'Units', 'normalized', ...
'Position', [.12 .8 .7 .17], ...
'HorizontalAlignment', 'left', ...
'Callback', {@checkCommOption_Callback, 'infile'});
uicontrol(handles.command_options, ...
'Style', 'text', ...
'Units', 'normalized', ...
'Position', [.05 .6 .3 .17], ...
'String', 'outfile:', ...
'HorizontalAlignment', 'left');
handles.outfile = uicontrol(handles.command_options, ...
'Style', 'edit', ...
'Units', 'normalized', ...
'Position', [.12 .6 .7 .17], ...
'HorizontalAlignment', 'left', ...
'Callback', {@checkCommOption_Callback, 'outfile'});
uicontrol(handles.command_options, ...
'Style', 'text', ...
'Units', 'normalized', ...
'Position', [.05 .4 .3 .17], ...
'String', 'period:', ...
'HorizontalAlignment', 'left');
handles.period = uicontrol(...
'Parent', handles.command_options, ...
'Style', 'edit', ...
'Units', 'normalized', ...
'Position', [.12 .4 .7 .17], ...
'HorizontalAlignment', 'left', ...
'String', num2str(options_.nobs), ...
'Callback', {@checkCommOption_Callback, 'period'});
uicontrol(handles.command_options, ...
'Style', 'checkbox', ...
'Units', 'normalized', ...
'Position', [.05 .2 .2 .17], ...
'String', 'clear endogs', ...
'Callback', @clearendogs);
uicontrol(handles.command_options, ...
'Style', 'checkbox', ...
'Units', 'normalized', ...
'Position', [.35 .2 .2 .17], ...
'String', 'clear exogs', ...
'Callback', @clearexogs);
function checkCommOption_Callback(~, ~, option_name)
comm_options = model_settings.smoother2histval;
switch option_name
case 'infile'
comm_options.infile = handles.infile.String;
case 'outfile'
comm_options.outfile = handles.outfile.String;
case 'period'
period = str2double(handles.period.String);
if isnan(period) || ~isint(period) ...
|| period < 1 || period > options_.nobs
gui_tools.show_error(['period must be an int between 1 and ' options_.nobs])
return
end
comm_options.period = period;
end
comm_str = gui_tools.command_string('smoother2histval', comm_options);
handles.smoother2histval.String = comm_str;
model_settings.smoother2histval = comm_options;
end
end
function RunSmoother2histvalCallback(hObject, ~)
try
options_smoother2histval = model_settings.smoother2histval;
gui_tools.project_log_entry('Running smoother2histval ','...');
[jObj, guiObj] = gui_tools.create_animated_screen('Running smoother2histval, please wait...', tabId);
smoother2histval(options_smoother2histval);
jObj.stop;
jObj.setBusyText('All done!');
project_info.modified = true;
project_info.smoother2histval_run = true;
gui_set_menus(true);
catch ME
jObj.stop;
jObj.setBusyText('Done with errors!');
gui_tools.show_error('Error in execution of smoother2histval command', ME, 'extended');
uicontrol(hObject);
end
delete(guiObj);
end
function Reset_Callback(~, ~)
handles.infile.String = '';
handles.outfile.String = '';
handles.periods.String = '';
handles.endoTable.Data(:, 1) = {true};
handles.shocksTable.Data(:,1) = {true};
end
function selectVar(~, ~)
comm_options = model_settings.smoother2histval;
if any([handles.endoTable.Data{:,1} handles.shocksTable.Data{:,1}])
comm_options.invars = strjoin(handles.endoTable.Data([handles.endoTable.Data{:,1}], 2), ',');
if any([handles.shocksTable.Data{:,1}])
if ~isempty(comm_options.invars)
comm_options.invars = [ comm_options.invars ','];
end
comm_options.invars = ...
[ ...
comm_options.invars ...
strjoin(handles.shocksTable.Data([handles.shocksTable.Data{:,1}], 2), ',') ...
];
end
comm_options.outvars = comm_options.invars;
else
if isfield(comm_options, 'invars')
comm_options = rmfield(comm_options, 'invars');
end
if isfield(comm_options, 'outvars')
comm_options = rmfield(comm_options, 'outvars');
end
end
comm_str = gui_tools.command_string('smoother2histval', comm_options);
handles.smoother2histval.String = comm_str;
model_settings.smoother2histval = comm_options;
end
function clearendogs(~, evt)
handles.endoTable.Data(:,1) = {~logical(evt.Source.Value)};
selectVar(1, 1);
end
function clearexogs(~, evt)
handles.shocksTable.Data(:,1) = {~logical(evt.Source.Value)};
selectVar(1, 1);
end
end
function close_tab(~, ~, hTab)
gui_tabs.delete_tab(hTab);
end
...@@ -11,7 +11,7 @@ function gui_stoch_simulation(tabId) ...@@ -11,7 +11,7 @@ function gui_stoch_simulation(tabId)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2019 Dynare Team % Copyright (C) 2003-2020 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -39,8 +39,10 @@ gui_size = gui_tools.get_gui_elements_size(tabId); ...@@ -39,8 +39,10 @@ gui_size = gui_tools.get_gui_elements_size(tabId);
% --- PANELS ------------------------------------- % --- PANELS -------------------------------------
handles.uipanelShocks = uipanel( ... handles.uipanelShocks = uipanel( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'uipanelShocks', 'BackgroundColor', special_color,... 'Tag', 'uipanelShocks', ...
'Units', 'normalized', 'Position', [0.01 0.18 0.48 0.73], ... 'BackgroundColor', special_color, ...
'Units', 'normalized', ...
'Position', [0.01 0.18 0.48 0.73], ...
'Title', '', ... 'Title', '', ...
'BorderType', 'none'); 'BorderType', 'none');
...@@ -49,17 +51,22 @@ uipanelShocks_CreateFcn; ...@@ -49,17 +51,22 @@ uipanelShocks_CreateFcn;
handles.uipanelVars = uipanel( ... handles.uipanelVars = uipanel( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'uipanelVars', ... 'Tag', 'uipanelVars', ...
'UserData', zeros(1,0), 'BackgroundColor', special_color,... 'UserData', zeros(1,0), ...
'Units', 'normalized', 'Position', [0.51 0.18 0.48 0.73], ... 'BackgroundColor', special_color, ...
'Title', '', 'BorderType', 'none'); 'Units', 'normalized', ...
'Position', [0.51 0.18 0.48 0.7], ...
'Title', '', ...
'BorderType', 'none');
handles = gui_tabs.create_endo_vars(handles, 'stoch_simul'); handles = gui_tabs.create_endo_vars(handles, 'stoch_simul');
handles.uipanelComm = uipanel( ... handles.uipanelComm = uipanel( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'uipanelCommOptions', ... 'Tag', 'uipanelCommOptions', ...
'UserData', zeros(1,0), 'BackgroundColor', bg_color, ... 'UserData', zeros(1,0), ...
'Units', 'normalized', 'Position', [0.01 0.09 0.98 0.09], ... 'BackgroundColor', bg_color, ...
'Units', 'normalized', ...
'Position', [0.01 0.09 0.98 0.09], ...
'Title', 'Current command options:'); 'Title', 'Current command options:');
...@@ -96,12 +103,48 @@ handles.stoch_simul = uicontrol( ... ...@@ -96,12 +103,48 @@ handles.stoch_simul = uicontrol( ...
'TooltipString', comm_str, ... 'TooltipString', comm_str, ...
'HorizontalAlignment', 'left'); 'HorizontalAlignment', 'left');
% --- Radio Buttons -------------------------------------
handles.buttongroup = uibuttongroup( ...
'Parent', tabId, ...
'Position', [0.51 0.88 0.36 0.05], ...
'Units', 'normalized', ...
'SelectionChangedFcn', {@init_val, handles});
uicontrol(handles.buttongroup, ...
'Style', 'text', ...
'Units', 'normalized', ...
'Position', [0 -.2 1 1], ...
'FontWeight', 'bold', ...
'String', 'Initial value: ', ...
'HorizontalAlignment', 'left');
uicontrol(handles.buttongroup, ...
'Style', 'radiobutton', ...
'String', 'zero', ...
'Units', 'normalized', ...
'Position', [0.2 0 1 1]);
uicontrol(handles.buttongroup, ...
'Style', 'radiobutton', ...
'String', 'steady state', ...
'Units', 'normalized', ...
'Value', 1, ...
'Position', [0.3 0 1 1]);
uicontrol(handles.buttongroup, ...
'Style', 'radiobutton', ...
'String', 'smoother', ...
'Units', 'normalized', ...
'Position', [0.5 0 1 1]);
% --- PUSHBUTTONS ------------------------------------- % --- PUSHBUTTONS -------------------------------------
handles.pushbuttonSimulation = uicontrol( ... handles.pushbuttonSimulation = uicontrol( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'pushbuttonSimulation', ... 'Tag', 'pushbuttonSimulation', ...
'Style', 'pushbutton', ... 'Style', 'pushbutton', ...
'Units','normalized','Position',[gui_size.space gui_size.bottom gui_size.button_width_small gui_size.button_height],... 'Units','normalized', ...
'Position', [gui_size.space gui_size.bottom gui_size.button_width_small gui_size.button_height], ...
'String', 'Run simulation', ... 'String', 'Run simulation', ...
'Callback', @pushbuttonSimulation_Callback); 'Callback', @pushbuttonSimulation_Callback);
...@@ -109,43 +152,48 @@ handles.pushbuttonReset = uicontrol( ... ...@@ -109,43 +152,48 @@ handles.pushbuttonReset = uicontrol( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'pushbuttonReset', ... 'Tag', 'pushbuttonReset', ...
'Style', 'pushbutton', ... '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],... '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', ... 'String', 'Reset', ...
'Callback', @pushbuttonReset_Callback); 'Callback', @reset);
handles.pushbuttonClose = uicontrol( ... uicontrol( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'pushbuttonReset', ... 'Tag', 'pushbuttonCloseTab', ...
'Style', 'pushbutton', ... '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],... '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', ... 'String', 'Close this tab', ...
'Callback', {@close_tab,tabId}); 'Callback', {@close_tab,tabId});
handles.pushbuttonResults = uicontrol( ... uicontrol( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'pushbuttonSimulation', ... 'Tag', 'pushbuttonSimulation', ...
'Style', 'pushbutton', ... 'Style', 'pushbutton', ...
'Units','normalized','Position',[gui_size.space*4+gui_size.button_width_small*3 gui_size.bottom gui_size.button_width_small gui_size.button_height],... 'Units','normalized', ...
'Position', [gui_size.space*4+gui_size.button_width_small*3 gui_size.bottom gui_size.button_width_small gui_size.button_height], ...
'String', 'Browse results...', ... 'String', 'Browse results...', ...
'Enable', 'on', ... 'Enable', 'on', ...
'Callback', @pushbuttonResults_Callback); 'Callback', @results);
handles.pushbuttonCloseAll = uicontrol( ... uicontrol( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'pushbuttonSimulation', ... 'Tag', 'pushbuttonSimulation', ...
'Style', 'pushbutton', ... '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],... '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', ... 'String', 'Close all output figures', ...
'Enable', 'on', ... 'Enable', 'on', ...
'Callback', @pushbuttonCloseAll_Callback); 'Callback', @close_all);
handles.pushbuttonCommandDefinition = uicontrol( ... uicontrol( ...
'Parent', tabId, ... 'Parent', tabId, ...
'Tag', 'pushbuttonCommandDefinition', ... 'Tag', 'pushbuttonCommandDefinition', ...
'Style', 'pushbutton', ... 'Style', 'pushbutton', ...
'Units','normalized','Position',[1-gui_size.space-gui_size.button_width_small gui_size.bottom gui_size.button_width_small gui_size.button_height],... 'Units', 'normalized', ...
'Position', [1-gui_size.space-gui_size.button_width_small gui_size.bottom gui_size.button_width_small gui_size.button_height], ...
'String', 'Define command options ...', ... 'String', 'Define command options ...', ...
'Callback', @pushbuttonCommandDefinition_Callback); 'Callback', @define_command);
function uipanelShocks_CreateFcn() function uipanelShocks_CreateFcn()
data = cell(size(model_settings.shocks, 1), 2); data = cell(size(model_settings.shocks, 1), 2);
...@@ -163,12 +211,15 @@ handles.pushbuttonCommandDefinition = uicontrol( ... ...@@ -163,12 +211,15 @@ handles.pushbuttonCommandDefinition = uicontrol( ...
'Position', [0 0 1 1]); 'Position', [0 0 1 1]);
end end
function pushbuttonSimulation_Callback(hObject, ~) function pushbuttonSimulation_Callback(~, ~)
old_oo_ = oo_; old_oo_ = oo_;
try try
backup = gui_auxiliary.backup_options(options_); backup = gui_auxiliary.backup_options(options_);
options_ = default_option_values(M_); options_ = default_option_values(M_);
options_ = gui_auxiliary.add_backup_to_options(options_, backup); options_ = gui_auxiliary.add_backup_to_options(options_, backup);
if ~isfield(M_, 'hessian_eq_zero')
options_.order = 1;
end
if any([handles.shocksTable.Data{:,1}]) if any([handles.shocksTable.Data{:,1}])
options_.irf_shocks = char(handles.shocksTable.Data([handles.shocksTable.Data{:,1}],2)); options_.irf_shocks = char(handles.shocksTable.Data([handles.shocksTable.Data{:,1}],2));
end end
...@@ -191,7 +242,7 @@ handles.pushbuttonCommandDefinition = uicontrol( ... ...@@ -191,7 +242,7 @@ handles.pushbuttonCommandDefinition = uicontrol( ...
gui_tools.project_log_entry('Running stochastic simulation','...'); gui_tools.project_log_entry('Running stochastic simulation','...');
[jObj, guiObj] = gui_tools.create_animated_screen('Running stochastic simulation, please wait...', tabId); [jObj, guiObj] = gui_tools.create_animated_screen('Running stochastic simulation, please wait...', tabId);
handles.pushbuttonResults.Enable = 'off'; handles.pushbuttonResults.Enable = 'off';
info = stoch_simul(model_settings.varlist_.stoch_simul); [info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, model_settings.varlist_.stoch_simul);
if info(1) if info(1)
throw(['dynare error number ' info(1)]); throw(['dynare error number ' info(1)]);
end end
...@@ -210,7 +261,7 @@ handles.pushbuttonCommandDefinition = uicontrol( ... ...@@ -210,7 +261,7 @@ handles.pushbuttonCommandDefinition = uicontrol( ...
delete(guiObj); delete(guiObj);
end end
function pushbuttonReset_Callback(~, ~) function reset(~, ~)
handles.endoTable.Data(:, 1) = {false}; handles.endoTable.Data(:, 1) = {false};
handles.shocksTable.Data(:,1) = {false}; handles.shocksTable.Data(:,1) = {false};
model_settings.stoch_simul = struct(); model_settings.stoch_simul = struct();
...@@ -219,7 +270,7 @@ handles.pushbuttonCommandDefinition = uicontrol( ... ...@@ -219,7 +270,7 @@ handles.pushbuttonCommandDefinition = uicontrol( ...
handles.stoch_simul.TooltipString = comm_str; handles.stoch_simul.TooltipString = comm_str;
end end
function pushbuttonCommandDefinition_Callback(~, ~) function define_command(~, ~)
h = gui_define_comm_options(dynare_gui_.stoch_simul, 'stoch_simul'); h = gui_define_comm_options(dynare_gui_.stoch_simul, 'stoch_simul');
uiwait(h); uiwait(h);
try try
...@@ -234,11 +285,11 @@ handles.pushbuttonCommandDefinition = uicontrol( ... ...@@ -234,11 +285,11 @@ handles.pushbuttonCommandDefinition = uicontrol( ...
end end
end end
function pushbuttonResults_Callback(~, ~) function results(~, ~)
gui_results('stoch_smulation', dynare_gui_.stoch_simulation_results); gui_results('stoch_smulation', dynare_gui_.stoch_simulation_results);
end end
function pushbuttonCloseAll_Callback(~, ~) function close_all(~, ~)
gui_tools.close_all_figures(); gui_tools.close_all_figures();
end end
...@@ -246,3 +297,30 @@ handles.pushbuttonCommandDefinition = uicontrol( ... ...@@ -246,3 +297,30 @@ handles.pushbuttonCommandDefinition = uicontrol( ...
gui_tabs.delete_tab(hTab); gui_tabs.delete_tab(hTab);
end end
end end
function init_val(~, evt, handles)
global M_ oo_ model_settings
if strcmp(evt.NewValue.String, 'zero')
handles.endoTable.Data(:,3) = num2cell(zeros(M_.orig_endo_nbr, 1));
elseif strcmp(evt.NewValue.String, 'steady state')
if ~isfield(oo_, 'steady_state')
gui_tools.show_warning('Must first calculate the steady state')
evt.OldValue.Value = 1;
return
end
handles.endoTable.Data(:,3) = num2cell(oo_.steady_state([model_settings.variables{:, 4}]));
elseif strcmp(evt.NewValue.String, 'smoother')
if ~isfield(oo_, 'SmoothedVariables')
gui_tools.show_warning('Must first run smoother')
evt.OldValue.Value = 1;
return
end
fname = inputdlg('output file from smoother2histval');
if isempty(fname)
evt.OldValue.Value = 1;
else
histvalf(fname{:})
handles.endoTable.Data(:,3) = num2cell(M_.endo_histval([model_settings.variables{:, 4}]));
end
end
end