Library: | hazreg |
See also: | hazdat hazrisk |
Quantlet: | haznar | |
Description: | calculates the size of the risk set at each point of the censored survival time data. |
Usage: | nar = haznar(data) | |
Input: | ||
data | n x (p+4) matrix of cosorted time-to-event data: column 1: sorted observed times t_i column 2: cosorted censoring indicator delta_i column 3: cosorted original observation labels i (i=1,...,n) column 4: cosorted number of tied observations at time t_i columns 5 through (p+4): cosorted covariate matrix z This data matrix may be obtained through hazdat.xpl. | |
Output: | ||
nar | n x 1 vector, the ith entry is the size of the risk set at time t_i. |
library("hazreg") randomize(1) y = -log(1-uniform(20)) ; exponential survival c = 2*uniform(20) ; uniform censoring t = min(y~c,2) ; censored time delta =(y<=c) ; censoring indicator {data,ties} = hazdat(t,delta) ; preparing data nar = haznar(data) ; calculating the ; number at risk nar
The size of each risk set is listed as a vector in the same order of the sorted data. Contents of nar [ 1,] 20 [ 2,] 19 [ 3,] 18 [ 4,] 17 [ 5,] 16 [ 6,] 15 [ 7,] 14 [ 8,] 13 [ 9,] 12 [10,] 11 [11,] 10 [12,] 9 [13,] 8 [14,] 7 [15,] 6 [16,] 5 [17,] 4 [18,] 3 [19,] 2 [20,] 1
library("hazreg") y = 2|1|3|2|4|7|1|3|2 ; hypothetical survival c = 3|1|5|6|1|6|2|4|5 ; hypothetical censoring t = min(y~c,2) ; censored time delta =(y<=c) ; censoring indicator {data,ties} = hazdat(t,delta) ; preparing data nar = haznar(data) ; calculating the number ; at risk nar
The same risk set size vector, but this time there are ties in the vector: three 9's, three 6's, two 3's. Contents of nar [1,] 9 [2,] 9 [3,] 9 [4,] 6 [5,] 6 [6,] 6 [7,] 3 [8,] 3 [9,] 1