naginterfaces.library.surviv.logrank

naginterfaces.library.surviv.logrank(t, ic, grp, ngrp, ifreq=None, wt=None, ldn=None)[source]

logrank calculates the rank statistics, which can include the logrank test, for comparing survival curves.

For full information please refer to the NAG Library document for g12ab

https://support.nag.com/numeric/nl/nagdoc_30/flhtml/g12/g12abf.html

Parameters
tfloat, array-like, shape

The observed failure and censored times; these need not be ordered.

icint, array-like, shape

contains the censoring code of the th observation, for .

the th observation is a failure time.

the th observation is right-censored.

grpint, array-like, shape

contains a flag indicating which group the th observation belongs in, for .

ngrpint

, the number of groups.

ifreqNone or int, array-like, shape , optional

Note: the required length for this argument is determined as follows: if : ; otherwise: .

Optionally, the frequency (number of observations) that each entry in corresponds to. If then each entry in is assumed to correspond to a single observation, i.e., a frequency of is assumed.

wtNone or float, array-like, shape , optional

Note: the required length for this argument is determined as follows: if : ; otherwise: .

Optionally, the weights, , where is the number of distinct failure times. If then for all .

ldnNone or int, optional

Note: if this argument is None then a default value will be used, determined as follows: .

The size of arrays and . As , if is not known a priori then a value of can safely be used for .

Returns
tsfloat

, the test statistic.

dfint

, the degrees of freedom.

pfloat

, when , i.e., the probability associated with .

obsdfloat, ndarray, shape

, the observed number of failures in each group.

exptfloat, ndarray, shape

, the expected number of failures in each group.

ndint

, the number of distinct failure times.

diint, ndarray, shape

The first elements of contain , the number of failures, across all groups, at time .

niint, ndarray, shape

The first elements of contain , the size of the risk set, across all groups, at time .

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, all the times in are the same.

(errno )

On entry, .

Constraint: or .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: or .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: or .

(errno )

On entry, .

Constraint: .

(errno )

The degrees of freedom are zero.

(errno )

On entry, .

Constraint: .

(errno )

On entry, all observations are censored.

(errno )

On entry, group has no observations.

Notes

A survivor function, , is the probability of surviving to at least time . Given a series of failure or right-censored times from groups logrank calculates a rank statistic for testing the null hypothesis

where is the largest observed time, against the alternative hypothesis

at least one of the differ, for some .

Let , for , denote the list of distinct failure times across all groups and a series of weights. Let denote the number of failures at time in group and denote the number of observations in the group that are known to have not failed prior to time , i.e., the size of the risk set for group at time . If a censored observation occurs at time then that observation is treated as if the censoring had occurred slightly after and, therefore, the observation is counted as being part of the risk set at time . Finally let

The (weighted) number of observed failures in the th group, , is, therefore, given by

and the (weighted) number of expected failures in the th group, , by

If denotes the vector of differences and

where if and otherwise, then the rank statistic, , is calculated as

where denotes a generalized inverse of the matrix . Under the null hypothesis, where the degrees of freedom, , is taken as the rank of the matrix .

References

Gross, A J and Clark, V A, 1975, Survival Distributions: Reliability Applications in the Biomedical Sciences, Wiley

Kalbfleisch, J D and Prentice, R L, 1980, The Statistical Analysis of Failure Time Data, Wiley

Rostomily, R C, Duong, D, McCormick, K, Bland, M and Berger, M S, 1994, Multimodality management of recurrent adult malignant gliomas: results of a phase II multiagent chemotherapy study and analysis of cytoreductive surgery, Neurosurgery (35), 378