MATLAB Examples

book_3_67.m

Compare loess parameters.

load melanoma

%  Scale Year for better fitting.
offsetYear = Year-Year(1);

%  Compute smooth fit.
lambda = 1;
el = 30;
alpha = el/length(Year);
fit = loess(offsetYear,Incidence,offsetYear,alpha,lambda)';
residualIncidence = Incidence(:)-fit(:);

% Compute a not so smooth fit
lambda = 2;
el = 9;
alpha = el/length(Year);
residualFit = loess(offsetYear,residualIncidence,offsetYear,alpha,lambda)';

plot(Year,residualIncidence,'o',Year,residualFit,'-',[min(Year) max(Year)],[0 0],'--')
xlabel('Year')
ylabel({'Residual Incidence'})
title('Melanoma')
bank45(Year,residualFit)