www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xreggpr/stats.m
function s = stats(m,RequiredStats,x,y) %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 2015-2015 The MathWorks, Inc. % 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 if isfitted(m) nobs = length(y); % RMSE in natural units % ynat = yinv(m,y); yhat = yinv(m, resubPredict(m.StatsGPR)); if length(yhat)==length(y) rn = ynat - yhat; % Use MLE RMSE rmse = sqrt(sum(rn.^2)/length(rn)); if strcmpi(m.StatsGPR.PredictMethod,'Exact') [rp,neff]=postFitStatisticsExact(m.StatsGPR.Impl,true); % MBC should report natural pressRMSE rpNatural = ynat - yinv(m, y - rp); pressRMSE = sqrt(sum( rpNatural.^2 )/nobs); % [Nobs, nParams, Trans, pressRMSE RMSE] s = [nobs neff get(m,'boxcox') pressRMSE rmse ]; else % PRESS RMSE not defined n = length(m.StatsGPR.Alpha) + length(m.StatsGPR.Beta); s = [nobs n get(m,'boxcox') NaN rmse ]; end else s = NaN(1,5); end else s = NaN(1,5); end otherwise % no other options supported anymore error(message('mbc:xreglinear:InvalidArgument5')) end