fig13_1.m 622 B

123456789101112131415161718192021222324252627
  1. % Local Regression and Likelihood, Figure 13.1
  2. %
  3. % Author: Catherine Loader
  4. load mmsamp;
  5. figure('Name','fig13_1a');
  6. plot(x,y,'o');
  7. hold on;
  8. fit = locfit(x,y,'deg',1,'kern','minmax','alpha',4000,'ev','grid','mg',200,'ll',0,'ur',1);
  9. xev = fit.fit_points.evaluation_points';
  10. yev = predict(fit,'fitp');
  11. plot(xev,yev);
  12. fit = locfit(x,y,'deg',1,'h',0.05,'ev','grid','mg',100,'ll',0,'ur',1);
  13. xev = fit.fit_points.evaluation_points';
  14. yev = predict(fit,'fitp');
  15. plot(xev,yev,'red');
  16. xx = 0:0.01:1;
  17. yy = 2-5*xx+5*exp(-(20*xx-10).*(20*xx-10));
  18. plot(xx,yy,'green');
  19. legend('Data','Minimax','Constant h','True Mean');
  20. hold off;