censor_at: Censor time to event end point at a given time/period of...

View source: R/censor_at.R

censor_atR Documentation

Censor time to event end point at a given time/period of follow up.

Description

Censor time to event end point at a given time. Implemented for right-censored dataset.

Usage

censor_at(time = NULL, status = NULL, censoring_time = NULL)

Arguments

time

time variable

status

status variable

censoring_time

censoring time

Details

The algorithm works as follow. If time of censoring is higher than (or equal to) patient's time, does nothing and returns time and status as they are. Otherwise:

- if the patients didn't experienced the event at full follow up, he/she didn't experienced even at the previous censoring time: therefore the algorithm should set censored time but leave indicator variable unchanged - if the patients experienced the event at time t, we hyphotize he/she was without event at time t-1 (aka an event is experienced the same day which is registered in the dataset), therefore the algorithm set 0 to indicator variable and set time to censoring time

... synthesizing, in both cases set indicator variable to 0 and time to censoring time.

Value

A data frame to be used with cbind

Examples


ctimes <- c(160, 150, 125, 75)

## Example 1:
time   <- c(100,150, 200)
status <- c(  0,  1,  NA)
cbind(data.frame(time, status), # original
      censor_at(time = time, status = status, censoring_time = ctimes))

## Example 2
time   <- c(100,150, NA)
status <- c(  1,  0,  0)
cbind(data.frame(time, status), # original
      censor_at(time = time, status = status, censoring_time = ctimes))

lbraglia/lbsurv documentation built on June 19, 2022, 11:13 p.m.