fig7_1.m 1.0 KB

12345678910111213141516171819202122232425262728
  1. % Local Regression and Likelihood, Figure 7.1.
  2. %
  3. % Estimating the hazard rate for censored survival (or
  4. % failure time) data. Hazard rate estimation is specified
  5. % by 'family','hazard'.
  6. %
  7. % The censoring indicator variable is passed as the 'cens'
  8. % argument. This should be a vector of 0's and 1's, with 1
  9. % indicating a censored observation, 0 uncensored.
  10. %
  11. % The 'xlim' argument specifies bounds on the domain of the
  12. % x variable (survival times). Usually, survival times are
  13. % non-negative (lower bound 0), but with theoretically no
  14. % upper bound. The specification [0;10000] gives the lower
  15. % bound of 0, and the upper bound is effectively infinite.
  16. %
  17. % Author: Catherine Loader
  18. %
  19. % NEEDS: m argument to lfplot.
  20. % Also, lfplot symbols should distinguish between censored and
  21. % uncensored data points.
  22. load heart;
  23. fit = locfit(surv,'cens',cens,'family','hazard','alpha',0.4,'xlim',[0;10000]);
  24. figure('Name','fig7_1: Hazard rate for censored data' );
  25. lfplot(fit);
  26. xlabel('Survival Time');
  27. ylabel('Hazard Rate');