Descarga la aplicación para disfrutar aún más
Esta es una vista previa del archivo. Inicie sesión para ver el archivo original
mfe-toolbox-master/Contents.m % MFE Toolbox Toolbox % Version 4.0 28-Oct-2009 mfe-toolbox-master/GUI/ARMAX.fig hgS_070000:[1x1 struct array] [1x6 char array] [1x1 double array] [1x1 struct array] @ = CloseRequestFcn : [1x54 char array] Color : [1x3 double array] Colormap : [64x3 double array] FileName : [1x44 char array] IntegerHandle : [1x3 char array] InvertHardcopy : [1x2 char array] MenuBar : [1x4 char array] Name : [1x5 char array] NumberTitle : [1x3 char array] PaperPosition : [1x4 double array] Position : [1x4 double array] Resize : [1x3 char array] ToolBar : [1x4 char array] CreateFcn : [1x48 char array] HandleVisibility : [1x8 char array] Tag : [1x7 char array] UserData : [1x0 double array] ApplicationData : [1x1 struct array] [16x1 struct array] @ = 16x1 struct array with fields: type handle properties children special [0x0 double array] mfe-toolbox-master/GUI/ARMAX.m function varargout = ARMAX(varargin) % ARMAX M-file for ARMAX.fig % ARMAX, by itself, creates a new ARMAX or raises the existing % singleton*. % % H = ARMAX returns the handle to a new ARMAX or the handle to % the existing singleton*. % % ARMAX('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in ARMAX.M with the given input arguments. % % ARMAX('Property','Value',...) creates a new ARMAX or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before ARMAX_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to ARMAX_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help ARMAX % Last Modified by GUIDE v2.5 29-Jan-2007 16:09:05 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ARMAX_OpeningFcn, ... 'gui_OutputFcn', @ARMAX_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before ARMAX is made visible. function ARMAX_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to ARMAX (see VARARGIN) % Choose default command line output for ARMAX handles.output = hObject; handles.model_ARMAX_AR_order=[]; handles.model_ARMAX_MA_order=[]; handles.model_ARMAX_AR_order_string=''; handles.model_ARMAX_MA_order_string=''; handles.y = varargin{1}; handles.model_ARMAX_residuals=[]; handles.ACF_lags=min(24,floor(length(handles.y)/8)); handles.model_InferenceMethod = 1; handles.model_IncludeConstant=1; handles.models={}; % Update handles structure guidata(hObject, handles); % UIWAIT makes ARMAX wait for user response (see UIRESUME) % uiwait(handles.figure1); axes(handles.plot_handle); clear_axes(handles) h=plot(handles.y); set(h,'LineWidth',2,'Color',[0 0 .6]) axis tight; title('Plot of original data') AX=axis; range = AX(4)-AX(3); AX(3)=AX(3)-.1*range; AX(4)=AX(4)+.1*range; axis(AX); set(handles.heterorobust_menu,'Checked','on') set(handles.homoerror_menu,'Checked','off') set(handles.ACF_lags_edit,'String',num2str(handles.ACF_lags)) % --- Outputs from this function are returned to the command line. function varargout = ARMAX_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) function EXOG_edit_Callback(hObject, eventdata, handles) % hObject handle to EXOG_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EXOG_edit as text % str2double(get(hObject,'String')) returns contents of EXOG_edit as a double % --- Executes during object creation, after setting all properties. function EXOG_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to EXOG_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) function edit2_Callback(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit2 as text % str2double(get(hObject,'String')) returns contents of edit2 as a double % --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in estimate_pushbutton. function estimate_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to estimate_pushbutton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %Thsi is the main function. Call ARMACFILTER and then call teh display %routine to display the results. Make sure there are no errorr, if there %are display a message that something went wrrong. y=handles.y; ar = handles.model_ARMAX_AR_order; ma = handles.model_ARMAX_MA_order; constant = handles.model_IncludeConstant; % A couple of quick sanity checks readytorun = true; notalreadyrun = true; if (isempty(ar) || all(ar==0)) && (isempty(ma) || all(ma==0)) readytorun=false; end % Check to make sure the this model hasn't been estimated; if it has, % do not reestimate but load the results of the previous estimation. % Probably print a message in th3 window. % To check, compare teh constant, and the other things, if a match is % founf, set readyto run to false, update a message and display the model % results by changing the current model number. models = handles.models; matchedModel=0; for i=1:length(handles.models) match=true; thisModel = models{i}; % conditions for maths % constant == modelcontant % length(ar)==length(modelar) % if true than check that they are all the same % length(ma)==length(modelma) % if true than check that they are all the same if constant ~= thisModel.constant match=false; end if length(ar)~=length(thisModel.ARlags) match=false; elseif ~all(unique(ar)==unique(thisModel.ARlags)) match=false; end if length(ma)~=length(thisModel.MAlags) match=false; elseif ~all(unique(ma)==unique(thisModel.MAlags)) match=false; end if match matchedModel=i; notalreadyrun = false; end end if matchedModel handles.currentModelNumber = matchedModel; errors = models{matchedModel}.errors; end if readytorun && notalreadyrun try [parameters, ll, errors, seregression, diagnostics, vcvrobust, vcv, likelihoods, scores]=armaxfilter(y,constant,ar,ma); handles.model_ARMAX_residuals=errors; modelno=length(handles.models)+1; handles.models{modelno}.parameters=parameters; handles.models{modelno}.errors=errors; handles.models{modelno}.ll=ll; handles.models{modelno}.seregression=seregression; handles.models{modelno}.diagnostics=diagnostics; if handles.model_InferenceMethod handles.models{modelno}.covariance=vcvrobust; else handles.models{modelno}.covariance=vcv; end handles.models{modelno}.likelihoods=likelihoods; handles.models{modelno}.scores=scores; handles.models{modelno}.ARlags=ar; handles.models{modelno}.MAlags=ma; handles.models{modelno}.constant=constant; handles.models{modelno}.y=y; handles.models{modelno}.yhat=y-errors; [aic,bic]=aicsbic(errors,constant,ar,ma); handles.models{modelno}.AIC=aic; handles.models{modelno}.BIC=bic; handles.models{modelno}.K=length(parameters); handles.models{modelno}.StdErr=sqrt(diag(handles.models{modelno}.covariance)); handles.models{modelno}.Tstat=parameters./handles.models{modelno}.StdErr; handles.models{modelno}.Pval=2-2*normcdf(abs(handles.models{modelno}.Tstat)); % Update the string in the popup ar = handles.models{modelno}.ARlags; ma = handles.models{modelno}.MAlags; irregular = false; if ~isempty(ar) if length(ar)<max(ar) irregular = true; end end if ~isempty(ma) if length(ma)<max(ma) irregular = true; end end this_str = 'ARMA('; if ~isempty(max(ar)) this_str=[this_str num2str(max(ar)) ',']; else this_str=[this_str '0,']; end if ~isempty(max(ma)) this_str=[this_str num2str(max(ma)) ')']; else this_str=[this_str '0)']; end if constant this_str = [this_str ' w/ constant']; else this_str = [this_str ' w/o constant']; end if irregular this_str = [this_str ' (Irregular)']; end handles.models{modelno}.StringID = this_str; str =[]; for i=1:length(handles.models) str=strvcat(str,handles.models{i}.StringID); end set(handles.model_selector_popup,'String',str,'Value',size(str,1)); set(handles.message_text,'String','The model has been sucessfully estimated.','ForegroundColor',[0 0 .8]) handles.currentModelNumber=length(models); catch err=lasterror; errmsg = err.message; set(handles.message_text,'String',['There was an error: ' errmsg],'ForegroundColor',[.9 0 0]) end elseif ~readytorun set(handles.message_text,'String','The model is not ready to run. Please check the inputs.','ForegroundColor',[.9 0 0]) elseif ~notalreadyrun set(handles.message_text,'String','Model previously estimated; results loaded.','ForegroundColor',[0 0 .8]) end if readytorun || ~notalreadyrun % Plot the residuals and update the radio button set(handles.resid_raw_radio,'Value',1) axes(handles.plot_handle); clear_axes(handles) h=plot(errors); set(h,'LineWidth',2,'Color',[0 0 .6]) axis tight; title('Plot of model errors') AX=axis; range = AX(4)-AX(3); AX(3)=AX(3)-.1*range; AX(4)=AX(4)+.1*range; axis(AX); end % Store the results in the display model structure guidata(hObject, handles); % Call the display function with the display model structure and the model % number if readytorun ARMAX_viewer(handles.models) elseif ~notalreadyrun ARMAX_viewer(handles.models,matchedModel) end function edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit4 as text % str2double(get(hObject,'String')) returns contents of edit4 as a double % --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in close_pushbutton. function close_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to close_pushbutton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) pos_size = get(handles.figure1,'Position'); % Call modaldlg with the argument 'Position'. %user_response ='Yes'; user_response = ARMAX_close_dialog('Title','Confirm Close'); switch user_response case {'No'} % take no action case 'Yes' delete(handles.figure1) end % --- Executes during object creation, after setting all properties. function MA_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to MA_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in pushbutton6. function reset_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to pushbutton6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.model_ARMAX_MA_order= []; handles.model_ARMAX_AR_order = []; % Update handles structure guidata(hObject, handles); set(findobj('Tag','MA_lags_edit'),'String',''); set(findobj('Tag','AR_lags_edit'),'String',''); set(findobj('Tag','EXOG_edit'),'String',' '); set(findobj('Tag','orig_raw_radio'),'Value',1) set(findobj('Tag','message_text'),'String','') set(findobj('Tag','hold_back_edit'),'String','0') y=handles.y; axes(handles.plot_handle); clear_axes(handles) hold off; % Need to produce a plot h=plot(y); set(h,'LineWidth',2,'Color',[0 0 .6]) axis tight; title('Plot of original data') AX=axis; range = AX(4)-AX(3); AX(3)=AX(3)-.1*range; AX(4)=AX(4)+.1*range; axis(AX); % --- Executes on button press in pushbutton7. function pushbutton7_Callback(hObject, eventdata, handles) % hObject handle to pushbutton7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function residuals_save_residuals_Callback(hObject, eventdata, handles) % hObject handle to residuals_save_residuals (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function residuals_save_std_residuals_Callback(hObject, eventdata, handles) % hObject handle to residuals_save_std_residuals (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function export_tiff_Callback(hObject, eventdata, handles) % hObject handle to export_tiff (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) this_handle = handles.plot_handle; HandleNewFigure = figure; copyobj(handles.plot_handle, HandleNewFigure); HandleAxes = get(HandleNewFigure,'Children'); set(HandleAxes,'Units', 'Pixels'); HandleAxesPosition = get(HandleAxes, 'Position'); HandleNewFigurePosition = get(HandleNewFigure, 'Position'); set(HandleAxes, 'Position', [70 70 HandleAxesPosition(3)+50 HandleAxesPosition(4)+50]); set(HandleNewFigure,'Position', [HandleNewFigurePosition(1) HandleNewFigurePosition(2) HandleAxesPosition(3)+110+50 HandleAxesPosition(4)+110+50]); % -------------------------------------------------------------------- function export_png_Callback(hObject, eventdata, handles) % hObject handle to export_png (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function export_eps_Callback(hObject, eventdata, handles) % hObject handle to export_eps (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function residual_menu_Callback(hObject, eventdata, handles) % hObject handle to residual_menu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function export_menu_Callback(hObject, eventdata, handles) % hObject handle to export_menu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in EXOG_clear_pushbutton. function EXOG_clear_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to EXOG_clear_pushbutton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(findobj('Tag','EXOG_edit'),'String',' '); % --- Executes during object creation, after setting all properties. function figure1_CreateFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % --- Executes during object creation, after setting all properties. function plot_handle_CreateFcn(hObject, eventdata, handles) % hObject handle to plot_handle (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: place code in OpeningFcn to populate plot_handle function AR_lags_edit_Callback(hObject, eventdata, handles) % hObject handle to AR_lags_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of AR_lags_edit as text % str2double(get(hObject,'String')) returns contents of AR_lags_edit as a double [lags, str, OK] = validate_AR_MA_lags(get(hObject,'String'),handles.model_ARMAX_AR_order,handles.model_ARMAX_AR_order_string); if OK && ~isempty(lags) handles.model_ARMAX_AR_order = lags; % Update handles structure guidata(hObject, handles); set(handles.message_text,'String',['AR lags set sucessfully to ' num2str(lags) '.'],'ForegroundColor',[0 0 0]) elseif OK && isempty(lags) set(handles.message_text,'String','No AR lags included.','ForegroundColor',[0 0 0]) else set(handles.message_text,'String','There was a problem setting the AR lags. Please try again.','ForegroundColor',[.8 0 0]) end % --- Executes during object creation, after setting all properties. function AR_lags_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to AR_lags_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function MA_lags_edit_Callback(hObject, eventdata, handles) % hObject handle to MA_lags_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of MA_lags_edit as text % str2double(get(hObject,'String')) returns contents of MA_lags_edit as a double [lags, str, OK] = validate_AR_MA_lags(get(hObject,'String'),handles.model_ARMAX_MA_order,handles.model_ARMAX_MA_order_string); if OK && ~isempty(lags) handles.model_ARMAX_MA_order = lags; % Update handles structure guidata(hObject, handles); set(handles.message_text,'String',['MA lags set sucessfully to ' num2str(lags) '.'],'ForegroundColor',[0 0 0]) elseif OK && isempty(lags) set(handles.message_text,'String',['No MA lags included.'],'ForegroundColor',[0 0 0]) else set(handles.message_text,'String','There was a problem setting the MA lags. Please try again.','ForegroundColor',[.8 0 0]) end % --- Executes during object creation, after setting all properties. function MA_lags_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to MA_lags_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in last_model_pushbutton. function last_model_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to last_model_pushbutton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function copy_figure_copy_Callback(hObject, eventdata, handles) % hObject handle to copy_figure_copy (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % FIXME I don't work with two axes, need to copy them seperately! f=figure; set(f,'PaperSize',[11 8.5],'PaperPosition',[0.25 0.25 10.5 8],... 'PaperOrientation','landscape','Visible','on'); % Copy the current axes to the new figure copyobj(handles.plot_axes2,f); if get(handles.radiobutton18,'Value') || get(handles.radiobutton19,'Value') hold on; copyobj(handles.plot_handle,f); hold off; end % Get the axes handle ax = get(f,'Children'); % Make the figure standard set(ax,'ActivePositionProperty','outerposition','Units','normalized',... 'Position',[0.1300 0.1100 0.7750 0.8150]); function hold_back_edit_Callback(hObject, eventdata, handles) % hObject handle to hold_back_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of hold_back_edit as text % str2double(get(hObject,'String')) returns contents of hold_back_edit as a double % --- Executes during object creation, after setting all properties. function hold_back_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to hold_back_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % -------------------------------------------------------------------- function initialization_Callback(hObject, eventdata, handles) % hObject handle to initialization (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Call the initialization popup window and return the correct info % --- Executes when user attempts to close figure1. function figure1_CloseRequestFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) pos_size = get(handles.figure1,'Position'); % Call modaldlg with the argument 'Position'. %user_response = 'Yes'; user_response = ARMAX_close_dialog('Title','Confirm Close'); switch user_response case {'No'} % take no action case 'Yes' delete(handles.figure1) end function ACF_lags_edit_Callback(hObject, eventdata, handles) % hObject handle to ACF_lags_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of ACF_lags_edit as text % str2double(get(hObject,'String')) returns contents of ACF_lags_edit as a double ACF_lags=handles.ACF_lags; y=handles.y; val = get(hObject,'String'); [val, OK] = bounded_integer_validate(val,ACF_lags,1,length(y)-1); if ~OK set(hObject,'String',num2str(val)); end handles.ACF_lags = val; % Update handles structure guidata(hObject, handles); % --- Executes during object creation, after setting all properties. function ACF_lags_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to ACF_lags_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function [val, OK] = bounded_integer_validate(val,orig_val,LB,UB) val = str2double(val); % Test cases % Nan: return old value and OK=0 % <0 return 0 and OK=0 % + but not integer, floor and OK=0 % +, integer, OK =1 OK = false; if isnan(val) val = orig_val; elseif val<LB val = LB; elseif val>UB; val = UB; elseif floor(val)~=val val=floor(val); else OK = true; end % -------------------------------------------------------------------- function about_menu_Callback(hObject, eventdata, handles) % hObject handle to about_menu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) value = ARMAX_about('Title','About'); function no_model_run_plot(ax,handles) axes(ax); clear_axes(handles) h=plot([0 1],[0 1]); axis tight set(h,'Visible','off') t=text(.1,.5,'You must estimate a model before residual plots can be produced'); set(t,'FontWeight','bold','FontSize',8,'FontName','Tahoma') set(get(h,'Parent'),'XTick',[],'YTick',[],'XColor',[1 1 1],'YColor',[1 1 1]) % -------------------------------------------------------------------- function stderror_menu_Callback(hObject, eventdata, handles) % hObject handle to stderror_menu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function heterorobust_menu_Callback(hObject, eventdata, handles) % hObject handle to heterorobust_menu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.model_InferenceMethod = 1; set(hObject,'Checked','on') set(handles.homoerror_menu,'Checked','off') guidata(hObject, handles); set(handles.message_text,'String',['Inference will be made using a heteroskedasticity robust covariace estimator.'],'ForegroundColor',[0 0 0]) % -------------------------------------------------------------------- function homoerror_menu_Callback(hObject, eventdata, handles) % hObject handle to homoerror_menu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.model_InferenceMethod = 0; set(hObject,'Checked','on') set(handles.heterorobust_menu,'Checked','off') guidata(hObject, handles); set(handles.message_text,'String',['Inference will be made assuming homoskedastic errors.'],'ForegroundColor',[0 0 0]) function [lags, str, OK] = validate_AR_MA_lags(str,old_lags,old_str) % This code will do the input validation for the strings used for the AR % and MA lags % Lags must be less than T-1 % Must be > 0 % first things to do is to find the spaces. From here I can break up the % string into units which have to be of one type, either a number (#) or a % number-colon-number combo (#:#). Any failure and the OK = 0 and the % program should terminate. if isempty(str) || all(ismember(str',' ')) OK = true; lags = []; str = ''; return end % The fisr check is to verify that all the elements are in {1,2,...,9,0,:} valid=all(ismember(str',{'1','2','3','4','5','6','7','8','9','0',':',' '})); lags=[]; OK = false; if valid try eval(['lags=[' str '];']); catch OK = false; end end if ~isempty(lags) lags = unique(lags); OK=true; else str = old_str; OK = false; end % --- Executes on selection change in model_selector_popup. function model_selector_popup_Callback(hObject, eventdata, handles) % hObject handle to model_selector_popup (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns model_selector_popup contents as cell array % contents{get(hObject,'Value')} returns selected item from model_selector_popup % 1. Update AR Lags, MA Lags and Constant model = handles.models{get(hObject,'Value')}; set(handles.AR_lags_edit,'String',num2str(model.ARlags)) set(handles.MA_lags_edit,'String',num2str(model.MAlags)) % 2. Change residuals handles.model_ARMAX_residuals=model.errors; % 3. Graph raw residuals y=handles.model_ARMAX_residuals; axes(handles.plot_handle); clear_axes(handles) hold off; % Need to produce a plot h=plot(y); set(h,'LineWidth',2,'Color',[0 0 .6]) axis tight; title('Plot of estimated errors') AX=axis; range = AX(4)-AX(3); AX(3)=AX(3)-.1*range; AX(4)=AX(4)+.1*range; axis(AX); % 4. Change Radio button set(handles.resid_raw_radio,'Value',1) % 2. Update Message set(handles.message_text,'String',['Results from model ' model.StringID ' loaded.'],'ForegroundColor',[0 0 .9]) % --- Executes during object creation, after setting all properties. function model_selector_popup_CreateFcn(hObject, eventdata, handles) % hObject handle to model_selector_popup (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes during object creation, after setting all properties. function constant_include_CreateFcn(hObject, eventdata, handles) % hObject handle to constant_include (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % --- Executes on button press in constant_include. function constant_include_Callback(hObject, eventdata, handles) % hObject handle to constant_include (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of constant_include handles.model_IncludeConstant=1; guidata(hObject, handles); set(handles.message_text,'String','Model will include a constant.','ForegroundColor',[0 0 0]) % --- Executes on button press in constant_exclude. function constant_exclude_Callback(hObject, eventdata, handles) % hObject handle to constant_exclude (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of constant_exclude handles.model_IncludeConstant=0; guidata(hObject, handles); set(handles.message_text,'String','Model will not include a constant.','ForegroundColor',[0 0 0]) % --- Executes on button press in orig_raw_radio. function orig_raw_radio_Callback(hObject, eventdata, handles) % hObject handle to orig_raw_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of orig_raw_radio y=handles.y; axes(handles.plot_handle); clear_axes(handles) hold off; % Need to produce a plot h=plot(y); set(h,'LineWidth',2,'Color',[0 0 .6]) axis tight; title('Plot of original data') AX=axis; range = AX(4)-AX(3); AX(3)=AX(3)-.1*range; AX(4)=AX(4)+.1*range; axis(AX); % --- Executes on button press in orig_acf_radio. function orig_acf_radio_Callback(hObject, eventdata, handles) % hObject handle to orig_acf_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of orig_acf_radio y=handles.y; ACF_lags=handles.ACF_lags; robust=handles.model_InferenceMethod; axes(handles.plot_handle); clear_axes(handles); hold off; [ac,acstd]=sacf(y,ACF_lags,robust,0); h = bar(ac); set(h,'FaceColor',[.5 .5 1]); axis tight; ax = axis; spread = .2*(ax(4)-ax(3)); ax(1) = 0; ax(2) = ACF_lags+1; ax(3) = ax(3) - spread; ax(4) = ax(4) + spread; axis(ax); hold on; h2 = plot((0:ACF_lags+1)',[[acstd(1);acstd;acstd(ACF_lags)] -[acstd(1);acstd;acstd(ACF_lags)]]); if robust title('Sample Autocorrelations and Robust Standard Errors'); else title('Sample Autocorrelations and Non-robust Standard Errors'); end set(h2(1),'LineWidth',2,'LineStyle',':','Color',[0 0 0]); set(h2(2),'LineWidth',2,'LineStyle',':','Color',[0 0 0]); % --- Executes on button press in orig_pacf_radio. function orig_pacf_radio_Callback(hObject, eventdata, handles) % hObject handle to orig_pacf_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of orig_pacf_radio y=handles.y; ACF_lags=handles.ACF_lags; robust=handles.model_InferenceMethod; axes(handles.plot_handle); clear_axes(handles) hold off; [pac,pacstd]=spacf(y,ACF_lags,robust,0); h = bar(pac); set(h,'FaceColor',[.5 .5 1]); axis tight; ax = axis; spread = .2*(ax(4)-ax(3)); ax(1) = 0; ax(2) = ACF_lags+1; ax(3) = ax(3) - spread; ax(4) = ax(4) + spread; axis(ax); hold on; h2 = plot((0:ACF_lags+1)',[2*[pacstd(1);pacstd;pacstd(ACF_lags)] -2*[pacstd(1);pacstd;pacstd(ACF_lags)]]); if robust title('Sample Partial Autocorrelations and Robust Standard Errors'); else title('Sample Partial Autocorrelations and Non-robust Standard Errors'); end set(h2(1),'LineWidth',2,'LineStyle',':','Color',[0 0 0]); set(h2(2),'LineWidth',2,'LineStyle',':','Color',[0 0 0]); % --- Executes on button press in resid_raw_radio. function resid_raw_radio_Callback(hObject, eventdata, handles) % hObject handle to resid_raw_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of resid_raw_radio if isempty(handles.model_ARMAX_residuals) no_model_run_plot(handles.plot_handle,handles); else y=handles.model_ARMAX_residuals; axes(handles.plot_handle); clear_axes(handles) hold off; % Need to produce a plot h=plot(y); set(h,'LineWidth',2,'Color',[0 0 .6]) axis tight; title('Plot of estimated errors') AX=axis; range = AX(4)-AX(3); AX(3)=AX(3)-.1*range; AX(4)=AX(4)+.1*range; axis(AX); end % --- Executes on button press in resid_fit_radio. function resid_fit_radio_Callback(hObject, eventdata, handles) % hObject handle to resid_fit_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of resid_fit_radio if isempty(handles.model_ARMAX_residuals) no_model_run_plot(handles.plot_handle,handles); else yhat=handles.y-handles.model_ARMAX_residuals; y=handles.y; axes(handles.plot_handle); clear_axes(handles) hold off; % Need to produce a plot h=plot([y yhat]); set(h(1),'LineWidth',2,'Color',[0 0 .6]) set(h(2),'LineWidth',2,'Color',[.16 .38 .27]) axis tight; title('Plot of estimated errors') legend('Original Data','Fit Data') AX=axis; range = AX(4)-AX(3); AX(3)=AX(3)-.1*range; AX(4)=AX(4)+.1*range; axis(AX); end % --- Executes on button press in resid_acf_radio. function resid_acf_radio_Callback(hObject, eventdata, handles) % hObject handle to resid_acf_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of resid_acf_radio if isempty(handles.model_ARMAX_residuals) no_model_run_plot(handles.plot_handle,handles); else y=handles.model_ARMAX_residuals; ACF_lags=handles.ACF_lags; robust=handles.model_InferenceMethod; axes(handles.plot_handle); clear_axes(handles); hold off; [ac,acstd]=sacf(y,ACF_lags,robust,0); h = bar(ac); set(h,'FaceColor',[.5 .5 1]); axis tight; ax = axis; spread = .2*(ax(4)-ax(3)); ax(1) = 0; ax(2) = ACF_lags+1; ax(3) = ax(3) - spread; ax(4) = ax(4) + spread; axis(ax); hold on; h2 = plot((0:ACF_lags+1)',[[acstd(1);acstd;acstd(ACF_lags)] -[acstd(1);acstd;acstd(ACF_lags)]]); if robust title('Sample Autocorrelations and Robust Standard Errors'); else title('Sample Autocorrelations and Non-robust Standard Errors'); end set(h2(1),'LineWidth',2,'LineStyle',':','Color',[0 0 0]); set(h2(2),'LineWidth',2,'LineStyle',':','Color',[0 0 0]); end % --- Executes on button press in resid_pacf_radio. function resid_pacf_radio_Callback(hObject, eventdata, handles) % hObject handle to resid_pacf_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of resid_pacf_radio if isempty(handles.model_ARMAX_residuals) no_model_run_plot(handles.plot_handle,handles); else y=handles.model_ARMAX_residuals; ACF_lags=handles.ACF_lags; robust=handles.model_InferenceMethod; axes(handles.plot_handle); clear_axes(handles) hold off; [pac,pacstd]=spacf(y,ACF_lags,robust,0); h = bar(pac); set(h,'FaceColor',[.5 .5 1]); axis tight; ax = axis; spread = .2*(ax(4)-ax(3)); ax(1) = 0; ax(2) = ACF_lags+1; ax(3) = ax(3) - spread; ax(4) = ax(4) + spread; axis(ax); hold on; h2 = plot((0:ACF_lags+1)',[2*[pacstd(1);pacstd;pacstd(ACF_lags)] -2*[pacstd(1);pacstd;pacstd(ACF_lags)]]); if robust title('Sample Partial Autocorrelations and Robust Standard Errors'); else title('Sample Partial Autocorrelations and Non-robust Standard Errors'); end set(h2(1),'LineWidth',2,'LineStyle',':','Color',[0 0 0]); set(h2(2),'LineWidth',2,'LineStyle',':','Color',[0 0 0]); end % --- Executes on button press in radiobutton18. function radiobutton18_Callback(hObject, eventdata, handles) % hObject handle to radiobutton18 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of radiobutton18 lags = handles.ACF_lags; y = handles.y; if handles.model_InferenceMethod [stat,pval] = lmtest1(y,lags); titleString = 'LM Test Statistic Values (left) and P-values (right)'; else [stat,pval] = ljungbox(y,lags); titleString = 'Ljung-Box Q Statistics (left) and P-values (right)'; end clear_axes(handles) % 1. Set up the axes and their limits barUL = max(stat)*1.1; plotUL = 1.1; plotLL = 0; barLL = -max(stat)*.1; axes(handles.plot_handle); ax=gca; axis([0 lags+1 barLL barUL]) set(ax,'XTickMode', 'auto','YTickMode', 'auto','Units','pixels','Position',[32 37 585 392]); axes(handles.plot_axes2); axis([0 lags+1 -.1 1.1]) ax=gca; set(ax,'YTickMode','auto','Units','pixels','Position',[32 37 585 392],'YAxisLocation','right'); % 2. Draw teh bar graph and establish it's limits axes(handles.plot_handle); hold on; b = bar(stat); set(b,'EdgeColor',[1 1 1],'FaceColor',[.5 .5 1]) set(get(b(1),'BaseLine'),'LineWidth',1,'LineStyle','none') hold on; h = plot(max(stat)*pval); set(h,'LineWidth',1,'LineStyle','none','Color',[0 0 0],'Marker','s','MarkerFaceColor',[0 0 0],'MarkerEdgeColor',[0 0 0]); legend('Statistic Value','P-value','Location','NorthWest') % 3. Labels and titles title(titleString) % --- Executes on button press in radiobutton19. function radiobutton19_Callback(hObject, eventdata, handles) % hObject handle to radiobutton19 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of radiobutton19 if isempty(handles.model_ARMAX_residuals) no_model_run_plot(handles.plot_handle,handles); else lags = handles.ACF_lags; y=handles.model_ARMAX_residuals; if handles.model_InferenceMethod [stat,pval] = lmtest1(y,lags); titleString = 'Error LM Test Statistic Values (left) and P-values (right)'; else [stat,pval] = ljungbox(y,lags); titleString = 'Error Ljung-Box Q Statistics (left) and P-values (right)'; end clear_axes(handles) % 1. Set up the axes and their limits barUL = max(stat)*1.1; plotUL = 1.1; plotLL = 0; barLL = -max(stat)*.1; axes(handles.plot_handle); ax=gca; axis([0 lags+1 barLL barUL]) set(ax,'XTickMode', 'auto','YTickMode', 'auto','Units','pixels','Position',[32 37 585 392]); axes(handles.plot_axes2); axis([0 lags+1 -.1 1.1]) ax=gca; set(ax,'YTickMode','auto','Units','pixels','Position',[32 37 585 392],'YAxisLocation','right'); % 2. Draw teh bar graph and establish it's limits axes(handles.plot_handle); hold on; b = bar(stat); set(b,'EdgeColor',[1 1 1],'FaceColor',[.5 .5 1]) set(get(b(1),'BaseLine'),'LineWidth',1,'LineStyle','none') hold on; h = plot(max(stat)*pval); set(h,'LineWidth',1,'LineStyle','none','Color',[0 0 0],'Marker','s','MarkerFaceColor',[0 0 0],'MarkerEdgeColor',[0 0 0]); legend('Statistic Value','P-value','Location','NorthWest') % 3. Labels and titles title(titleString) end function clear_axes(handles) axes(handles.plot_handle); cla set(handles.plot_handle,'XTick',[],'YTick',[],'Units','pixels','Position',[32 37 585 392]) title('') axes(handles.plot_axes2); cla set(handles.plot_axes2,'XTick',[],'YTick',[],'Units','pixels','Position',[32 37 585 392]) title('') mfe-toolbox-master/GUI/ARMAX_about.fig mfe-toolbox-master/GUI/ARMAX_about.m function varargout = ARMAX_about(varargin) % ARMAX_ABOUT M-file for ARMAX_about.fig % ARMAX_ABOUT by itself, creates a new ARMAX_ABOUT or raises the % existing singleton*. % % H = ARMAX_ABOUT returns the handle to a new ARMAX_ABOUT or the handle to % the existing singleton*. % % ARMAX_ABOUT('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in ARMAX_ABOUT.M with the given input arguments. % % ARMAX_ABOUT('Property','Value',...) creates a new ARMAX_ABOUT or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before ARMAX_about_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to ARMAX_about_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help ARMAX_about % Last Modified by GUIDE v2.5 19-Aug-2006 18:42:58 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ARMAX_about_OpeningFcn, ... 'gui_OutputFcn', @ARMAX_about_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before ARMAX_about is made visible. function ARMAX_about_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to ARMAX_about (see VARARGIN) % Choose default command line output for ARMAX_about handles.output = 'Yes'; % Update handles structure guidata(hObject, handles); % Insert custom Title and Text if specified by the user % Hint: when choosing keywords, be sure they are not easily confused % with existing figure properties. See the output of set(figure) for % a list of figure properties. if(nargin > 3) for index = 1:2:(nargin-3), if nargin-3==index, break, end switch lower(varargin{index}) case 'title' set(hObject, 'Name', varargin{index+1}); case 'string' set(handles.text1, 'String', varargin{index+1}); end end end % Determine the position of the dialog - centered on the callback figure % if available, else, centered on the screen FigPos=get(0,'DefaultFigurePosition'); OldUnits = get(hObject, 'Units'); set(hObject, 'Units', 'pixels'); OldPos = get(hObject,'Position'); FigWidth = OldPos(3); FigHeight = OldPos(4); if isempty(gcbf) ScreenUnits=get(0,'Units'); set(0,'Units','pixels'); ScreenSize=get(0,'ScreenSize'); set(0,'Units',ScreenUnits); FigPos(1)=1/2*(ScreenSize(3)-FigWidth); FigPos(2)=2/3*(ScreenSize(4)-FigHeight); else GCBFOldUnits = get(gcbf,'Units'); set(gcbf,'Units','pixels'); GCBFPos = get(gcbf,'Position'); set(gcbf,'Units',GCBFOldUnits); FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ... (GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2]; end FigPos(3:4)=[FigWidth FigHeight]; set(hObject, 'Position', FigPos); set(hObject, 'Units', OldUnits); % Show a question icon from dialogicons.mat - variables questIconData % and questIconMap load OxLogo.mat IconData=OxLogo; %questIconMap(256,:) = get(handles.figure1, 'Color'); %IconCMap=questIconMap; Img=image(IconData, 'Parent', handles.axes1); % set(handles.figure1, 'Colormap', IconCMap); set(handles.axes1, ... 'Visible', 'off', ... 'YDir' , 'reverse' , ... 'XLim' , get(Img,'XData'), ... 'YLim' , get(Img,'YData') ... ); % Make the GUI modal set(handles.figure1,'WindowStyle','modal') % UIWAIT makes ARMAX_about wait for user response (see UIRESUME) uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = ARMAX_about_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % The figure can be deleted now delete(handles.figure1); % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.output = get(hObject,'String'); % Update handles structure guidata(hObject, handles); % Use UIRESUME instead of delete because the OutputFcn needs % to get the updated handles structure. uiresume(handles.figure1); % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.output = get(hObject,'String'); % Update handles structure guidata(hObject, handles); % Use UIRESUME instead of delete because the OutputFcn needs % to get the updated handles structure. uiresume(handles.figure1); % --- Executes when user attempts to close figure1. function figure1_CloseRequestFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if isequal(get(handles.figure1, 'waitstatus'), 'waiting') % The GUI is still in UIWAIT, us UIRESUME uiresume(handles.figure1); else % The GUI is no longer waiting, just close it delete(handles.figure1); end % --- Executes on key press over figure1 with no controls selected. function figure1_KeyPressFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Check for "enter" or "escape" if isequal(get(hObject,'CurrentKey'),'escape') % User said no by hitting escape handles.output = 'No'; % Update handles structure guidata(hObject, handles); uiresume(handles.figure1); end if isequal(get(hObject,'CurrentKey'),'return') uiresume(handles.figure1); end mfe-toolbox-master/GUI/ARMAX_close_dialog.fig hgS_070000:[1x1 struct array] [1x6 char array] [1x1 double array] [1x1 struct array] @ = Units : [1x10 char array] CloseRequestFcn : [1x67 char array] Color : [1x3 double array] Colormap : [256x3 double array] FileName : [1x57 char array] IntegerHandle : [1x3 char array] InvertHardcopy : [1x2 char array] KeyPressFcn : [1x63 char array] MenuBar : [1x4 char array] Name : [1x18 char array] NumberTitle : [1x3 char array] PaperPosition : [1x4 double array] Position : [1x4 double array] Resize : [1x3 char array] HandleVisibility : [1x8 char array] Tag : [1x7 char array] UserData : [1x0 double array] ApplicationData : [1x1 struct array] [4x1 struct array] @ = 4x1 struct array with fields: type handle properties children special [0x0 double array] mfe-toolbox-master/GUI/ARMAX_close_dialog.m function varargout = ARMAX_close_dialog(varargin) % ARMAX_CLOSE_DIALOG M-file for ARMAX_close_dialog.fig % ARMAX_CLOSE_DIALOG by itself, creates a new ARMAX_CLOSE_DIALOG or raises the % existing singleton*. % % H = ARMAX_CLOSE_DIALOG returns the handle to a new ARMAX_CLOSE_DIALOG or the handle to % the existing singleton*. % % ARMAX_CLOSE_DIALOG('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in ARMAX_CLOSE_DIALOG.M with the given input arguments. % % ARMAX_CLOSE_DIALOG('Property','Value',...) creates a new ARMAX_CLOSE_DIALOG or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before ARMAX_close_dialog_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to ARMAX_close_dialog_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help ARMAX_close_dialog % Last Modified by GUIDE v2.5 19-Aug-2006 01:03:58 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ARMAX_close_dialog_OpeningFcn, ... 'gui_OutputFcn', @ARMAX_close_dialog_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before ARMAX_close_dialog is made visible. function ARMAX_close_dialog_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to ARMAX_close_dialog (see VARARGIN) % Choose default command line output for ARMAX_close_dialog handles.output = 'Yes'; % Update handles structure guidata(hObject, handles); % Insert custom Title and Text if specified by the user % Hint: when choosing keywords, be sure they are not easily confused % with existing figure properties. See the output of set(figure) for % a list of figure properties. if(nargin > 3) for index = 1:2:(nargin-3), if nargin-3==index, break, end switch lower(varargin{index}) case 'title' set(hObject, 'Name', varargin{index+1}); case 'string' set(handles.text1, 'String', varargin{index+1}); end end end % Determine the position of the dialog - centered on the callback figure % if available, else, centered on the screen FigPos=get(0,'DefaultFigurePosition'); OldUnits = get(hObject, 'Units'); set(hObject, 'Units', 'pixels'); OldPos = get(hObject,'Position'); FigWidth = OldPos(3); FigHeight = OldPos(4); if isempty(gcbf) ScreenUnits=get(0,'Units'); set(0,'Units','pixels'); ScreenSize=get(0,'ScreenSize'); set(0,'Units',ScreenUnits); FigPos(1)=1/2*(ScreenSize(3)-FigWidth); FigPos(2)=2/3*(ScreenSize(4)-FigHeight); else GCBFOldUnits = get(gcbf,'Units'); set(gcbf,'Units','pixels'); GCBFPos = get(gcbf,'Position'); set(gcbf,'Units',GCBFOldUnits); FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ... (GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2]; end FigPos(3:4)=[FigWidth FigHeight]; set(hObject, 'Position', FigPos); set(hObject, 'Units', OldUnits); % Show a question icon from dialogicons.mat - variables questIconData % and questIconMap load dialogicons.mat IconData=questIconData; questIconMap(256,:) = get(handles.figure1, 'Color'); IconCMap=questIconMap; Img=image(IconData, 'Parent', handles.axes1); set(handles.figure1, 'Colormap', IconCMap); set(handles.axes1, ... 'Visible', 'off', ... 'YDir' , 'reverse' , ... 'XLim' , get(Img,'XData'), ... 'YLim' , get(Img,'YData') ... ); % Make the GUI modal set(handles.figure1,'WindowStyle','modal') % UIWAIT makes ARMAX_close_dialog wait for user response (see UIRESUME) uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = ARMAX_close_dialog_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % The figure can be deleted now delete(handles.figure1); % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.output = get(hObject,'String'); % Update handles structure guidata(hObject, handles); % Use UIRESUME instead of delete because the OutputFcn needs % to get the updated handles structure. uiresume(handles.figure1); % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.output = get(hObject,'String'); % Update handles structure guidata(hObject, handles); % Use UIRESUME instead of delete because the OutputFcn needs % to get the updated handles structure. uiresume(handles.figure1); % --- Executes when user attempts to close figure1. function figure1_CloseRequestFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.output = 'No'; guidata(hObject, handles); if isequal(get(handles.figure1, 'waitstatus'), 'waiting') % The GUI is still in UIWAIT, us UIRESUME uiresume(handles.figure1); else % The GUI is no longer waiting, just close it delete(handles.figure1); end % --- Executes on key press over figure1 with no controls selected. function figure1_KeyPressFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Check for "enter" or "escape" if isequal(get(hObject,'CurrentKey'),'escape') % User said no by hitting escape handles.output = 'No' % Update handles structure guidata(hObject, handles); uiresume(handles.figure1); end if isequal(get(hObject,'CurrentKey'),'return') uiresume(handles.figure1); end mfe-toolbox-master/GUI/ARMAX_viewer.fig hgS_070000:[1x1 struct array] [1x6 char array] [1x1 double array] [1x1 struct array] @ = Color : [1x3 double array] Colormap : [64x3 double array] FileName : [1x51 char array] IntegerHandle : [1x3 char array] InvertHardcopy : [1x2 char array] MenuBar : [1x4 char array] Name : [1x16 char array] NumberTitle : [1x3 char array] PaperPosition : [1x4 double array] Position : [1x4 double array] Resize : [1x3 char array] HandleVisibility : [1x8 char array] Tag : [1x7 char array] UserData : [1x0 double array] ApplicationData : [1x1 struct array] [11x1 struct array] @ = 11x1 struct array with fields: type handle properties children special [0x0 double array] mfe-toolbox-master/GUI/ARMAX_viewer.m function varargout = ARMAX_viewer(varargin) % ARMAX_viewer M-file for ARMAX_viewer.fig % ARMAX_viewer, by itself, creates a new ARMAX_viewer or raises the existing % singleton*. % % H = ARMAX_viewer returns the handle to a new ARMAX_viewer or the handle to % the existing singleton*. % % ARMAX_viewer('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in ARMAX_viewer.M with the given input arguments. % % ARMAX_viewer('Property','Value',...) creates a new ARMAX_viewer or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before ARMAX_viewer_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to ARMAX_viewer_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % TODO : Add parameter display for hyperparapmeter for distributions % FIXME: Fix the behavior for very large models % Edit the above text to modify the response to help ARMAX_viewer % Last Modified by GUIDE v2.5 09-Sep-2006 14:45:09 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ARMAX_viewer_OpeningFcn, ... 'gui_OutputFcn', @ARMAX_viewer_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before ARMAX_viewer is made visible. function ARMAX_viewer_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to ARMAX_viewer (see VARARGIN) % Choose default command line output for ARMAX_viewer handles.output = hObject; handles.Results = varargin{1}; if length(varargin)==2 handles.DisplayNumber = varargin{2}; else handles.DisplayNumber = length(handles.Results); end % Update handles structure guidata(hObject, handles); popup_cell=[]; for i=1:length(handles.Results); popup_cell{i}=handles.Results{i}.StringID; end set(handles.model_popupmenu,'String',popup_cell) set(handles.model_popupmenu,'Value',length(handles.Results)) set(gcf,'Position',[10 10 1000 706]) % display_model(handles,hObject); % UIWAIT makes ARMAX_viewer wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = ARMAX_viewer_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on mouse press over axes background. function model_axes_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to model_axes (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) function generate_text(handles,hObject); % Get rid of results not needed number = handles.DisplayNumber; results=handles.Results{number}; % Compute the needed strings [ParameterString,VariableString]= generate_strings(results); % Layout the model [model_layout_info]=model_layout(ParameterString,VariableString,handles); % Layout the model statistics [model_stats_layout_info]=model_stats_layout(results,handles); % Resize the Parameter Estimates Window [estimate_window]=resize_parameter_estimate_uipanel(handles); % Layout the column titles and return their position [title_positions]=title_layout(handles); % Compute the text elements for the main display and their positions [text_positions]=compute_text_positions(handles,ParameterString,title_positions); % Update the results with a flag that the text layout is done and with all % of the relevant information, also set the handles handles.Results{number}.ParameterString=ParameterString; handles.Results{number}.VariableString=VariableString; handles.Results{number}.model_layout_info=model_layout_info; handles.Results{number}.model_stats_layout_info=model_stats_layout_info; handles.Results{number}.estimate_window=estimate_window; handles.Results{number}.title_position=title_positions; handles.Results{number}.text_position=text_positions; handles.Results{number}.TextFinished=true; guidata(hObject, handles); function [ParameterString,VariableString]= generate_strings(results); % Not finished % TO DO: ARARCH, EGARCH and AGARCH index=1; ParameterString{index}='y_t ='; c{index}=''; index=index+1; if results.constant ParameterString{index}='\phi_0'; VariableString{index}=''; index=index+1; end if ~isempty(results.ARlags) if max(results.ARlags)>0 for i=1:length(results.ARlags) ParameterString{index}=['\phi_{' num2str(results.ARlags(i)) '}']; VariableString{index}=['y_{t-' num2str(results.ARlags(i)) '}']; index=index+1; end end end if ~isempty(results.MAlags) if max(results.MAlags)>0 for i=1:length(results.MAlags) ParameterString{index}=['\theta_{' num2str(results.MAlags(i)) '}']; VariableString{index}=['\epsilon_{t-' num2str(results.MAlags(i)) '}']; index=index+1; end end end ParameterString{index}=''; VariableString{index}='\epsilon_t'; function [layout_info]=model_layout(ParameterString,VariableString,handles) axes(handles.model_axes); %set(gcf,'Position',[ -3 35 1024 664],'Units','pixels') %set(ax,'Units','pixels','Position',[134.1200 500.0400 793.6000 120]) line=0.75; count=1; result = handles.Results{handles.DisplayNumber}; ModelString = result.StringID; % Add on the model specific string final_str{count}=ModelString; count=count+1; %FIX ME, need to worry about no constant! if result.constant final_str{count}=[ParameterString{1} ParameterString{2}]; else final_str{count}=[ParameterString{1} ParameterString{2} VariableString{2}]; end xpos=.05; for i=3:length(ParameterString) t=text(xpos,line,['$' final_str{count} '+' ParameterString{i} VariableString{i} '$' ],'Interpreter','latex','FontSize',12); ex=get(t,'Extent'); delete(t); if ex(1)+ex(3)<1 % No problems, add and try next final_str{count}=[final_str{count} '+' ParameterString{i} VariableString{i}]; else %Problem, no not add and start a new line xpos=.1; count=count+1; final_str{count}=['+' ParameterString{i} VariableString{i}]; end end t=[]; line=0.75; for i=1:count; if i<3 xpos=.02; else xpos=.07; end if i>1 t{i}=text(xpos,line,['$' final_str{i} '$'] ,'Interpreter','latex','FontSize',12); else t{i}=text(xpos,line,['$' final_str{i} '$'] ,'FontSize',12); end line=line-0.25; end % Now that the text is layed out, the axes and uipanel need to be resized % accordingly and the text strings need to be vertically repositioned % axes height is 33* no lines, y position is always 9 % uipanel height is 33*no lines+24, y position is 650-uiheight no_lines=length(final_str); uiHeight = no_lines*33+24; uiY = 670 - uiHeight; uiP=get(handles.model_uipanel,'Position'); uiP(2)=uiY; uiP(4)=uiHeight; set(handles.model_uipanel,'Position',uiP); axHeight = 33*no_lines; axY = 9; axP=get(handles.model_axes,'Position'); axP(2)=axY; axP(4)=axHeight; set(handles.model_axes,'Position',axP); % Finally uniformly distribute the t{i} between at % [1:no_lines]/(no_lines+1) positions = (no_lines:-1:1)/(no_lines+1); for i=1:no_lines; tP=get(t{i},'Position'); tP(2)=positions(i); set(t{i},'Position',tP); end % Need to return everything needed to make relayout easy: % uipanle position % axes position % text strings % text string position layout_info.model_uipanel_position = get(handles.model_uipanel,'Position'); layout_info.model_axes_position = get(handles.model_axes,'Position'); layout_info.model_text_strings = final_str; for i=1:length(final_str); layout_info.model_text_strings_position{i}=get(t{i},'Position'); end % Clear the axis cla function [layout_info]=model_stats_layout(results,handles) % 1. Fix the position of and size of the UI and axes % 2. Layout the important stats and their labels axes(handles.stats_axes); set(handles.stats_axes,'Position',[15 9 920 60]) model_uipanel_position=get(handles.model_uipanel ,'Position'); set(handles.model_stats_uipanel,'Position',[25 model_uipanel_position(2)-84 950 84]) titles={'Log-likelihood','No. of Params',' Akaike IC','Schwartz/Bayesian IC','$\hat{\sigma}^2$'}; positions=linspace(.02,.9,length(titles)); total_space=0; for i=1:length(titles) if i==5 t(i)=text(positions(i),.66,titles{i},'FontName','Tahoma','FontSize',10,'Interpreter','latex'); else t(i)=text(positions(i),.66,titles{i},'FontName','Tahoma','FontSize',10); end ex(i,:)=get(t(i),'Extent'); if i>1 total_space=total_space+ex(i,1)-(ex(i-1,3)+ex(i-1,1)); end end total_space=total_space+.98-(ex(5,3)+ex(5,1)); % Compute the total amount of space between the objects and uniformly % respace them spaces=[4 4 4 4]*total_space/22; for i=2:length(titles) ex=get(t(i-1),'Extent'); set(t(i),'Position',[ex(1)+ex(3)+spaces(i-1) .66 0]); end % Set up the text strings. I need to limit the width data{1}=sprintf('%0.7g',results.ll); data{2}=num2str(results.K); data{3}=sprintf('%0.7g',results.AIC); data{4}=sprintf('%0.7g',results.BIC); data{5}=sprintf('%0.7g',results.seregression); for i=1:5 d(i)=text(positions(i),.33,data{i},'FontName','Tahoma','FontSize',10); % Now move it so that it is right aligned p1 = get(d(i),'Extent'); p2 = get(t(i),'Extent'); set(d(i),'Position',[p2(1)+p2(3)-p1(3) .33 0]); end AX=axis; hold on; for i=1:5 % Now move it so that it is right aligned p2 = get(t(i),'Extent'); axis(AX); x_line_data{i}=[p2(1) p2(1)+p2(3)]'; y_line_data{i}=[p2(2) p2(2)]; plot([p2(1) p2(1)+p2(3)],[p2(2) p2(2)],'k'); end hold off; % Need to return all of teh strings along with all of their positions layout_info.Titles=titles; layout_info.Data=data; layout_info.TitlePosition=[]; layout_info.DataPosition=[]; for i=1:5; layout_info.TitleHandles{i}=t(i); layout_info.TitlePosition{i}=get(t(i),'Position'); layout_info.DataHandle{i}=d(i); layout_info.DataPosition{i}=get(d(i),'Position'); end layout_info.model_stats_uipanel_position = get(handles.model_stats_uipanel,'Position'); layout_info.stats_axes_position = get(handles.stats_axes,'Position'); layout_info.x_line_data=x_line_data; layout_info.y_line_data=y_line_data; % Clear the axis cla % --- Executes on selection change in model_popupmenu. function model_popupmenu_Callback(hObject, eventdata, handles) % hObject handle to model_popupmenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns model_popupmenu contents as cell array % contents{get(hObject,'Value')} returns selected item from model_popupmenu handles.DisplayNumber = get(hObject,'Value'); guidata(hObject, handles); display_model(handles,hObject); % --- Executes during object creation, after setting all properties. function model_popupmenu_CreateFcn(hObject, eventdata, handles) % hObject handle to model_popupmenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function page_number_edit_Callback(hObject, eventdata, handles) % hObject handle to page_number_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of page_number_edit as text % str2double(get(hObject,'String')) returns contents of page_number_edit as a double val = get(hObject,'String'); result = handles.Results{handles.DisplayNumber}; LastPage = handles.LastPage; NumberOfPages = size(result.text_position.x_pos,3); [CurrentPage, OK] = bounded_integer_validate(val,LastPage,1,NumberOfPages); if ~OK set(hObject,'String',num2str(CurrentPage)); end draw_parameter_table(result,CurrentPage,handles) handles.LastPage=CurrentPage; % Update handles structure guidata(hObject, handles); % --- Executes during object creation, after setting all properties. function page_number_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to page_number_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function num_pages_text_Callback(hObject, eventdata, handles) % hObject handle to num_pages_text (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of num_pages_text as text % str2double(get(hObject,'String')) returns contents of num_pages_text as a double % --- Executes during object creation, after setting all properties. function num_pages_text_CreateFcn(hObject, eventdata, handles) % hObject handle to num_pages_text (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in increase_page_pushbutton. function increase_page_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to increase_page_pushbutton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) result = handles.Results{handles.DisplayNumber}; NumberOfPages = size(result.text_position.x_pos,3); CurrentPage = str2double(get(handles.page_number_edit,'String')); if CurrentPage < NumberOfPages CurrentPage = CurrentPage +1; set(handles.page_number_edit,'String',num2str(CurrentPage)); draw_parameter_table(result,CurrentPage,handles) handles.LastPage=CurrentPage; % Update handles structure guidata(hObject, handles); end % --- Executes on button press in decrease_page_pushbutton. function decrease_page_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to decrease_page_pushbutton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) result = handles.Results{handles.DisplayNumber}; CurrentPage = str2double(get(handles.page_number_edit,'String')); if CurrentPage >1 CurrentPage = CurrentPage - 1; set(handles.page_number_edit,'String',num2str(CurrentPage)); draw_parameter_table(result,CurrentPage,handles) handles.LastPage=CurrentPage; % Update handles structure guidata(hObject, handles); end % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) delete(handles.figure1) function [window_stats]=resize_parameter_estimate_uipanel(handles) model_uipanel_pos=get(handles.model_stats_uipanel,'Position'); estimates_uipanel_pos=get(handles.estimates_uipanel ,'Position'); estimates_uipanel_pos(4)=estimates_uipanel_pos(4)+model_uipanel_pos(2)-sum(estimates_uipanel_pos([2 4])); set(handles.estimates_uipanel ,'Position',estimates_uipanel_pos); estimates_axes_pos=get(handles.estimates_axes,'Position'); estimates_axes_pos(2)=12; set(handles.estimates_axes,'Position',estimates_axes_pos) estimates_uipanel_pos=get(handles.estimates_uipanel ,'Position'); estimates_axes_pos=get(handles.estimates_axes,'Position'); estimates_axes_pos(4)=estimates_uipanel_pos(4)-24; set(handles.estimates_axes,'Position',estimates_axes_pos); estimates_axes_pos=get(handles.estimates_axes,'Position'); % Note, I want ot make sure that the estimates window is at least 330 % pixels high % FIXME: Fix the behavior for very large models % ScreenSize = get(0,'ScreenSize') % set(handles.figure1,'Position',[1 ScreenSize-HeightofWindow-33 WidthofWindow HeightofWindow]) % Return the position of the uipanel, the axes and the figure! window_stats.axes_pos=estimates_axes_pos; window_stats.uipanel_pos=estimates_uipanel_pos; window_stats.figure_pos=get(handles.figure1,'Position'); function [title_position]=title_layout(handles) titles={'Parameter','Estimate','Std. Error','T-stat','P-val'}; axes(handles.estimates_axes); t(1)=text(.02,.5,titles{1},'FontName','Tahoma','FontSize',10); axes_pos=get(handles.estimates_axes,'Position'); set(t(1),'Units','pixels'); t_pos=get(t(1),'Position'); t_ex = get(t(1),'Extent'); y=floor(axes_pos(4)-t_ex(4)/2-10); t_pos(2)=y; set(t(1),'Position',t_pos) position{1}=t_pos; for i=2:length(titles); t(i)=text((i-1)/6+.02,.5,titles{i},'FontName','Tahoma','FontSize',10); set(t(i),'Units','pixels') ; t_pos=get(t(i),'Position'); t_pos(2)=y; set(t(i),'Position',t_pos); position{i}=t_pos; end AX=axis; hold on; for i=1:length(titles) % Now move it so that it is right aligned set(t(i),'Units','normalized'); p2 = get(t(i),'Extent'); % Need to get the right points of each label to do right alignment right_points{i}=p2(1)+p2(3); axis(AX);
Compartir