Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 Quantlet: hazrisk Description: determines which observations are at risk at the time point t_i.

Reference(s):
Cox, D. R. and Oakes, D. (1984): Analysis of Survival Data, Chapman and Hall, London.

 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.

Example:
```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

```
Result:
```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
```
Example:
```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

```
Result:
```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
```

Author: L. Yang, 19990601 license MD*Tech
(C) MD*TECH Method and Data Technologies, 05.02.2006