The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


Statistics::LogRank - Perl module to perform the log rank test (also know as the Mantel-Haenszel or Mantel-Cox test) on survival data.


    use Statistics::LogRank;

    @group_1_survival = (99,98,95,90,90,87);
    @group_1_deaths   = ( 1, 0, 3, 4, 0, 3);

    @group_2_survival = (100,97,93,90,88,82);
    @group_2_deaths   = (  0, 2, 4, 1, 2, 6);

    my $log_rank = new LogRank;
    $log_rank->load_data('group 1 survs',@group_1_survival);
    $log_rank->load_data('group 1 deaths',@group_1_deaths);
    $log_rank->load_data('group 2 survs',@group_2_survival);
    $log_rank->load_data('group 2 deaths',@group_2_deaths);

    my ($log_rank_stat,$p_value) = $log_rank->perform_log_rank_test('group 1 survs','group 1 deaths','group 2 survs','group 2 deaths');

    print "log rank statistic for test is $log_rank_stat\n";
    print "p value for test is $p_value\n";


This module performs the log rank statistical test on survival data. The log rank test is also known as the Mantel-Cox test and the Mantel-Haenszel test. It takes 2 groups of survival and death data (we separate the two to cope with censure, subjects that drop out of the study before completion) and compares if the two groups are identical.


Martin Lee, Star Technology Group (