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

    function [ci_hi,ci_lo,yhat]= cicalc(TS,Xs,alpha,Trans)
% MODEL/CICALC - calculate the confidence interval for a model on a set of data
%
% [ci_hi,ci_lo,yhat]= cicalc(TS,Xs,alpha,Trans)

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




% why is Ys requ'd?

df=dferror(TS);
if ~isfinite(df)
	ni = norminv(1-(1-alpha)/2);
else
	ni = tinv(1-(1-alpha)/2,df);
end

IT2= nfactors(TS.Local)==1 | ~all(InputFactorTypes(TS.Local)==1);

if Trans
	PEVArgs= {0,0};
else
	PEVArgs= {0};
end
if IT2
	[V,~,~,yhat]= pevgrid(TS,Xs,PEVArgs{:});
else
	[V,yhat]= pev(TS,Xs,PEVArgs{:});
end

if Trans
	yhat= ytrans(TS,yhat(:));
else
	yhat= yhat(:);
end

ts= ni*sqrt(V(:));

ci_lo= yhat(:)-ts;
ci_hi= yhat(:)+ts;