Home > chronux_1_15 > locfit > 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.

 Usage: lfband(fit,varargin)

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

Generated on Tue 15-Aug-2006 22:51:57 by m2html © 2003