annotate rDiff/src/locfit/m/lfband.m @ 1:08d3a6143873

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