Statistics Toolbox | ![]() ![]() |
Empirical (Kaplan-Meier) cumulative distribution function
Syntax
Description
[f,x] = ecdf(y)
calculates the Kaplan-Meier estimate of the cumulative distribution function (cdf), also known as the empirical cdf. y
is a vector of data values. f
is a vector of values of the empirical cdf evaluated at x
.
[f,x,flo,fup] = ecdf(y)
also returns lower and upper confidence bounds for the cdf. These bounds are calculated using Greenwood's formula, and are not simultaneous confidence bounds.
[...] = ecdf(y,'param1',value1,'param2',value2,...)
specifies additional parameter name-value pairs chosen from the following:
Examples
Generate random failure times and random censoring times, and compare the empirical cdf with the known true cdf.
y = exprnd(10,50,1); % Random failure times are exponential(10) d = exprnd(20,50,1); % Drop-out times are exponential(20) t = min(y,d); % Observe the minimum of these times censored = (y>d); % Observe also whether the subject failed % Calculate and plot the empirical cdf and confidence bounds [f,x,flo,fup] = ecdf(t,'censoring',censored); stairs(x,f); hold on; stairs(x,flo,'r:'); stairs(x,fup,'r:'); % Superimpose a plot of the known true cdf xx = 0:.1:max(t); yy = 1-exp(-xx/10); plot(xx,yy,'g-') hold off;
See Also
References
[1] Cox, D.R. and D. Oakes, Analysis of Survival Data, Chapman & Hall, London, 1984.
![]() | dummyvar | errorbar | ![]() |