fig6_3.m 647 B

1234567891011121314151617
  1. % Local Regression and Likelihood, Figure 6.3.
  2. % Author: Catherine Loader
  3. %
  4. % Local smooth of CO2 dataset. Estimate the main trend,
  5. % then use periodic smoothing of the residuals to estimate
  6. % the annual effect.
  7. %
  8. % A periodic smooth is specified by 'style','a'.
  9. % Note that year+month/12 scales the predictor to have a period
  10. % of 1. The 'scale' argument to locfit() is period/(2*pi).
  11. load co2;
  12. fit1 = locfit(year+month/12,co2,'alpha',0.5,'deg',1);
  13. res = residuals(fit1);
  14. fit2 = locfit(year+month/12,res,'alpha',[0 2],'style','a','scale',1/(2*pi));
  15. figure('Name','fig6_3: CO2 Dataset: Local smoothing' );
  16. lfplot(fit2,'nodata');