www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xreglinear/stats.m

    function s = stats(m,RequiredStats,Xv,Yv)
%STATS main statistics calculations
% 
% s= stats(m,'summary',Xv,Yv)
%
%  Inputs
%    m              xreglinear object (or child)
%    RequiredStats  String specifying required stats
%                     'summary'   [Nobs, NumParams, BoxCox, PRESS RMSE, RMSE (natural)]

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


%% Main routine
OK= true;
if nargin>2
    [m,OK]= InitModel(m,Xv,Yv);
end
if ~isempty(m.Store) && OK
    % data in store
    x= m.Store.D;
    y= m.Store.y;
else
    error(message('mbc:xreglinear:InvalidState5'));
end

yhat = eval(m,x);

%% Summary Stats
switch lower(RequiredStats)
    case 'summary'
        % main summary statistics
        % [Nobs, nParams, Trans, PRESS RMSE, RMSE]

        % called from xregmodel/FitSummary (main use)
        %   mv_stepwise - summary history table
        %   xregdynlolimot/fitmodel
        %   @xregMdlGui\@rbfprune\drawLines.m	41
        %   @xregrbf\centerexchange.m

        nobs = length(y);
        rmse = NaturalRMSE(m,x,y,yhat);
        rmsep= NaturalPressRMSE(m,x,y,yhat);

        % [Nobs, nParams, Trans, PRESS RMSE, RMSE]
        s = [nobs numParams(m) get(m,'boxcox') rmsep rmse];
    otherwise
        % no other options supported anymore
        error(message('mbc:xreglinear:InvalidArgument5'))
end