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

    function [m,OK]= InitModel(m,x,y,~,IsCoded,doRinvCalc) %#ok<INUSD>
%INITMODEL default initmodel method (initialises pev)
%
% [m,OK]= InitModel(m,x,y);            % coded data assumed
% [m,OK]= InitModel(m,x,y,Wc);         % coded data assumed. Use Wc=[] to
%                                        specify no weights
% [m,OK]= InitModel(m,x,y,Wc,IsCoded); % specify whether data is coded or
%                                        uncoded.

%  Copyright 2015-2015 The MathWorks, Inc.

if iscell(m.StatsGPR)
    % used following xreggpr/update with localmulti
    
    if nargin>4 && ~IsCoded
        [x,y]= checkdata(m,x,y);
    end
    
    if size(x,1)>m.LargeScale.Threshold
        % large scale fit/predict method
        Args = {'PredictMethod',m.LargeScale.PredictMethod};
    else
        Args = {};
    end
    
    try
        %  use name/value pairs in m.StatsGPR and FitMethod of none
        m.StatsGPR = fitrgp(x,y,...
            'KernelFunction',m.Kernel,...
            'BasisFunction',m.Basis,...
            'FitMethod','none',...
            m.StatsGPR{:},...
            Args{:},...
            'PredictorNames',get(m,'symbols'),...
            'ResponseName',varname(m));
        m = var(m,[],m.StatsGPR.Sigma^2,Inf);
    catch ME
        m = comments(m, ME.message);
    end
end

OK = isfitted(m);

end