Home > chronux > locfit > m > lfband.m

lfband

PURPOSE ^

adds confidence bands around the plot of a locfit() fit.

SYNOPSIS ^

function lfband(fit,varargin)

DESCRIPTION ^

 adds confidence bands around the plot of a locfit() fit.

 for 2-d fits, produces separate surface plots of upper and
 lower confidence limits.

 Bands are based on 95% pointwise coverage, using a single
 (i.e. global) estimate of sigma^2.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function lfband(fit,varargin)
0002 
0003 % adds confidence bands around the plot of a locfit() fit.
0004 %
0005 % for 2-d fits, produces separate surface plots of upper and
0006 % lower confidence limits.
0007 %
0008 % Bands are based on 95% pointwise coverage, using a single
0009 % (i.e. global) estimate of sigma^2.
0010 
0011 xfit = lfmarg(fit);
0012 % placing 'band','g' before varargin{:} ensures that
0013 % user-provided 'band' has precedence.
0014 ypp = predict(fit,xfit,'band','g',varargin{:});
0015 yfit = ypp{1};
0016 se = ypp{2};
0017 bands = ypp{3};
0018 
0019 data = fit.data;
0020 xdata = data.x;
0021 p = size(xdata,2);
0022 cv = 1.96;
0023 fali = fit.fit_points.family_link;
0024 cl = invlink(bands(:,1),fali);
0025 cu = invlink(bands(:,2),fali);
0026 
0027 if (p==1)
0028   hold on;
0029   plot(xfit{1},cu,':');
0030   plot(xfit{1},cl,':');
0031   hold off;
0032 end;
0033 
0034 if (p==2)
0035   x1 = xfit{1};
0036   x2 = xfit{2};
0037   figure(1);
0038   surf(x1,x2,reshape(cl,length(x1),length(x2))');
0039   figure(2);
0040   surf(x1,x2,reshape(cu,length(x1),length(x2))');
0041 end;
0042 
0043 return;

Generated on Fri 28-Sep-2012 12:34:30 by m2html © 2005