Kaplan Meier for right and/or left and/or interval censored data
% INPUT ARGUMENTS:
% times: An n by 2 matrix which refer to the time data. The two columns
% define the interval in which the event occured. If in one row the two
% "times" elements are equal then this corresponds to an event time. If the
% left column time point is finite and the right column time point is Inf
% then we have right censoring. If the left time point is -Inf and the
% right time point is finite then we have left censoring. For example:
%
%
% 5 Inf -> right censored observation
% -Inf 8 -> left censored observation
% 8 11 -> interval censoring
% 9 9 -> fully (exactly) observed
%
% Note that, since negative time values are also allowed, for left censored
% values you need to specify the left limit as -Inf. To be clear, Infs and
% -Infs are replaced as "NA" in the corresponding survfit R function.
%
%OUTPUT ARGUMENTS:
%time: the time points for which the survival is evaluated
%S : the survival estimate
%SE : the standard error of the estimate
%L : the lower limit of the corresponding 95% confidence interval for the
% survival
%U : the upper limit of the corresponding 95% confidence interval for the
% survival
%
%see also the example file.
%
%If only right censoring is present then the usual Kaplan Meier is employed
%and there is no need to use this code since MATLAB has already the built
%in function "ecdf" which will be faster. If left/interval censoring is
%present the Turnbull algorithm is employed. This algorithm is also
%described in detail in:
%
%"Klein and Moeschberger (2003), Survival Analysis (Techniques for censored
%and truncated data), Springer-Verlag, New York."
%
%This program does nothing more than calling the corresponding R functions.
%It is necessary to download MATLAB R-link and follow all instructions
%described therein:
%
%http://www.mathworks.com/matlabcentral/fileexchange/5051-matlab-r-link
%
%This means that you also have to download and install Randfriends:
%
%http://rcom.univie.ac.at/download.html
%
%This works for both 32bit and 64bit machines.
%Please try to also run the demo included in the MATLAB R-link package, and
%make sure that everything works before trying this code.
%After that, you must download and install the packages "survival"
%and "matlab" in R. The analysis provided by this code is in fact the
%output as provided by the corresponding survival package (survfit)
%provided by prof. Terry Therneau.
%
%
%
%References:
%
%Turnbull, B. W. Nonparametric Estimation of a Survivorship Function with Doubly
%Censored Data. Journal of the American Statistical Association 69 (1974): 169–173.
%
%Turnbull, B. W. The Empirical Distribution Function with Arbitrarily Grouped, Censored
%and Truncated Data. Journal of the Royal Statistical Society B 38 (1976): 290–295.
%
%Klein and Moeschberger (2003), Survival Analysis (Techniques for censored
%and truncated data), Springer-Verlag, New York."
%
%R survival package by Terry Therneau. see also:
%http://cran.r-project.org/web/packages/survival/survival.pdf
%
%
Cite As
Leonidas Bantis (2024). Kaplan Meier for right and/or left and/or interval censored data (https://www.mathworks.com/matlabcentral/fileexchange/41325-kaplan-meier-for-right-and-or-left-and-or-interval-censored-data), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- AI and Statistics > Statistics and Machine Learning Toolbox > Industrial Statistics >
- MATLAB > External Language Interfaces > Other languages > R Language >
Tags
Acknowledgements
Inspired by: MATLAB R-link
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
KM/
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |