Be the first to rate this file! 126 downloads (last 30 days) File Size: 4.11 KB File ID: #22317

Logrank

by Giuseppe Cardillo

 

04 Dec 2008 (Updated 09 Sep 2009)

Code covered by BSD License  

Comparing survival curves of two groups using the log rank test

Download Now | Watch this File

File Information
Description

Comparison of two survival curves can be done using a statistical hypothesis test called the log rank test. It is used to test the null hypothesis that there is no difference between the population survival curves (i.e. the probability of an event occurring at any time point is the same for each population). This function use the Kaplan-Meier procedure to estimate the survival function, so it is mandatory to download
KMPLOT (http://www.mathworks.com/matlabcentral/fileexchange/22293).

Required Products Statistics Toolbox
MATLAB release MATLAB 7.6 (R2008a)
Other requirements KMPLOT (http://www.mathworks.com/matlabcentral/fileexchange/22293).
Zip File Content  
Other Files license.txt,
logrank.m,
logrankdata.mat
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (9)
19 May 2009 En Bl

I get this error:
Matrix dimensions must agree.

Error in ==> logrank at 157
    K=find((table12(:,1)<table(c(I),1) & table12(:,1)>=table(J,1)),1,'last');

I debugged it and J=[] .

22 May 2009 Giuseppe Cardillo

Perhaps, if you email me the data I can understand the error. I think that your input data matrix are in a wrong format.

30 May 2009 En Bl

Here is the data:
x1 =
3010 1
1733 1
2797 1
334 0
3678 1
3314 1
4378 1
3253 1
1672 0
3709 1
1642 1
3040 1
2827 1
 and x2 =
1955 1
1808 1
2037 1
3136 1
938 0
3497 1
2858 1
3832 1
3256 0
2933 0
5054 1
927 0
3795 0
4155 1
3304 0

sorry for the late reply.

08 Jun 2009 Giuseppe Cardillo

I have corrected the bug and uploaded the new version. Anyway, with all these censored data, it is difficult to assess differences....

12 Jun 2009 En Bl

Thanks.

08 Sep 2009 the cyclist

It seems to me that this function does not work for the case when none of the data are censored. (That shouldn't be a problem, should it?) For example, using only the first columns of your sample x1 and x2:

>> logrank(x1(:,1),x2(:,1))

causes a crash for me.

09 Sep 2009 Giuseppe Cardillo

You are partially right. If you use only the first column, the routine crashes because the informations in the second column are mandatory. If you want no censored data:
>> x1(:,2)=0; x2(:,2)=0; logrank(x1,x2);

Anyway, a bug was present but I fixed it and upload the new version.

09 Sep 2009 the cyclist

Thanks for the really quick reply. I appreciate it.

However, the program still crashes for me, with the same error, when I try the syntax you suggest. Maybe the version on the File Exchange is not quite the same as yours?

09 Sep 2009 Giuseppe Cardillo

At the moment, there is not on FEX the new uploaded file (this takes 1-2 days). If you contact me in private, I'll send you the file as an attach

Please login to add a comment or rating.
Updates
05 Dec 2008

changes in help section for correct citation

08 Jun 2009

correction when the first value is censored

28 Jul 2009

Correction to avoid NaN in Standard error computation

09 Sep 2009

Correction of a bug that occurs when data are not censored

Tag Activity for this File
Tag Applied By Date/Time
logrank test Giuseppe Cardillo 04 Dec 2008 16:02:05
kaplanmeier Giuseppe Cardillo 04 Dec 2008 16:02:05
survival function Giuseppe Cardillo 04 Dec 2008 16:02:05
statistics Cristina McIntire 05 Dec 2008 14:33:08
probability Cristina McIntire 05 Dec 2008 14:33:08
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com