www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdev_local/rmse_plot.m

    function h=rmse_plot(mdev,Type,XVar,Ax,ind)
% MDEV_LOCAL/RMSE_PLOT plot local rmse

%  Copyright 2000-2014 The MathWorks, Inc. and Ford Global Technologies, Inc.



SNo=[];
switch lower(Type)
case 'local'
   % local
   df= mdev.MLE.df;
   RMSE= zeros(size(df));
   RMSE(df>0)= sqrt(mdev.MLE.SSE_nat(df>0)./df(df>0));
   RMSE(df<=0)= NaN;   
   s= statistics(mdev);
   Pooled_RMSE= s(1);

   if nargin==5
      SNo= ind;
   end
case 'pred'
   % predicted
   RMSE= mdev.TSstatistics.RMSE(:,ind);
   if mdev.MLE.Validate 
      % for mle validation
      Pooled_RMSE= mdev.TSstatistics.Summary(ind,2);
   else
      % for ts validation
      twostageRMSEindex = 2;
      Pooled_RMSE= mdev.TSstatistics.Summary(ind,twostageRMSEindex);
   end

case 'press'
   % PRESS
   RMSE= mdev.TSstatistics.RPRESS(:,ind);
   PRESSRMSEindex = 3;
   Pooled_RMSE= mdev.TSstatistics.Summary(ind,PRESSRMSEindex);

end

ch= children(mdev);

if XVar==1
   x= 1:length(RMSE);
   Xname= 'Obs. Number';
else
   x= ch(1).getdata('X');
   Xind=XVar-1;
   if Xind<=size(x,2)
      Xname= get(ch(1).model,'symbol');
      Xname= Xname{Xind};
      x= double(x(:,Xind));
   else   
      XVar= XVar-size(x,2)-1;
      x= double(ch(XVar).getdata('Y'));
      Xname= ch(XVar).name;
   end
end
cla(Ax);

ColorIndex = Ax.ColorOrderIndex;
h= plot(x,RMSE,'.',...
    'Tag','main line','Parent',Ax,'MarkerSize',15);

if ~isempty(SNo);
    hL = line('XData',x(SNo),'YData',RMSE(SNo),...
        'Color','r',...
        'Marker','o',...
        'Parent',Ax);
    xregGui.setLegendData(hL, false);
end

np= get(Ax,'NextPlot');
set(Ax,'NextPlot','add')
% make sure next plots have the same colors as the first
Ax.ColorOrderIndex =ColorIndex;
hL = plot(get(Ax,'XLim')',[Pooled_RMSE Pooled_RMSE]',...
   'Parent',Ax);
xregGui.setLegendData(hL, false);

set(Ax,'XGrid','on','YGrid','on','NextPlot',np)

set(get(Ax,'XLabel'),'String',Xname,'Interpreter','none')
set(get(Ax,'YLabel'),'String','RMSE')