0
|
1 function lfband(fit,varargin)
|
|
2
|
|
3 % adds confidence bands around the plot of a locfit() fit.
|
|
4 %
|
|
5 % for 2-d fits, produces separate surface plots of upper and
|
|
6 % lower confidence limits.
|
|
7 %
|
|
8 % Bands are based on 95% pointwise coverage, using a single
|
|
9 % (i.e. global) estimate of sigma^2.
|
|
10
|
|
11 xfit = lfmarg(fit);
|
|
12 % placing 'band','g' before varargin{:} ensures that
|
|
13 % user-provided 'band' has precedence.
|
|
14 ypp = predict(fit,xfit,'band','g',varargin{:});
|
|
15 yfit = ypp{1};
|
|
16 se = ypp{2};
|
|
17 bands = ypp{3};
|
|
18
|
|
19 data = fit.data;
|
|
20 xdata = data.x;
|
|
21 p = size(xdata,2);
|
|
22 cv = 1.96;
|
|
23 fali = fit.fit_points.family_link;
|
|
24 cl = invlink(bands(:,1),fali);
|
|
25 cu = invlink(bands(:,2),fali);
|
|
26
|
|
27 if (p==1)
|
|
28 hold on;
|
|
29 plot(xfit{1},cu,':');
|
|
30 plot(xfit{1},cl,':');
|
|
31 hold off;
|
|
32 end;
|
|
33
|
|
34 if (p==2)
|
|
35 x1 = xfit{1};
|
|
36 x2 = xfit{2};
|
|
37 figure(1);
|
|
38 surf(x1,x2,reshape(cl,length(x1),length(x2))');
|
|
39 figure(2);
|
|
40 surf(x1,x2,reshape(cu,length(x1),length(x2))');
|
|
41 end;
|
|
42
|
|
43 return;
|