fig9_2.m 536 B

1234567891011121314151617181920
  1. % Local Regression and Likelihood, Figure 9.2.
  2. %
  3. % Hardle's Motorcycle accelaration dataset.
  4. % Local Variance Estimation.
  5. %
  6. % Author: Catherine Loader
  7. %
  8. % NEED: lfknots function to extract fit points.
  9. load mcyc;
  10. fit = locfit(time,'y',accel,'nn',0.1);
  11. y = -2*predict(fit,'fitp','what','lik');
  12. w = predict(fit,'fitp','what','rdf');
  13. x = fit.fit_points.evaluation_points';
  14. [x y w]
  15. fitv = locfit(x,y,'weights',w,'family','gamma','nn',0.4);
  16. figure('Name','fig9_2: Motorcycle acceleration');
  17. lfplot(fitv);
  18. xlabel('Time');
  19. ylabel('Variance');