Library: | hazreg |
See also: | hazdat haznar |
Quantlet: | hazrisk | |
Description: | determines which observations are at risk at the time point t_i. |
Usage: | inrisk = hazrisk(data,i) | |
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. | |
i | integer, index for time point t_i, 1<=i<=n. | |
Output: | ||
inrisk | n x 1 vector, the jth entry is 1 if the jth observation is at risk at time t_i, 0 otherwise. |
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 inrisk = hazrisk(data,5) ; the risk set at observation 5 inrisk
The risk set at observation 5 is listed as a vector where 1 indicates risk and 0 otherwise. Contents of inrisk [ 1,] 0 [ 2,] 0 [ 3,] 0 [ 4,] 0 [ 5,] 1 [ 6,] 1 [ 7,] 1 . . . . . . [18,] 1 [19,] 1 [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 inrisk = hazrisk(data,3) ; the risk set at observation 3 inrisk
The risk set at observation 3 is listed as a vector where 1 indicates risk and 0 otherwise. Contents of inrisk [1,] 1 [2,] 1 [3,] 1 [4,] 1 [5,] 1 [6,] 1 [7,] 1 [8,] 1 [9,] 1