md.censor: Censoring simulated survival data

Description Usage Arguments Value Examples

View source: R/library.R

Description

The md.censor function takes the data set simulated by the md.simulate and transforms it into a right censored sample by adding two columns to the original data set:
- time specifies the time to event or censoring, whichever comes first, specified in days and
- status specifies the censoring indicator and equals 0 if the individual is censored or <>0 in case of event.

Usage

1
md.censor(data, start, end, eventcolumns)

Arguments

data

data.frame containig event times and covariates

start

column name specifying start dates (left censoring)

end

column name specifying end dates (right censoring)

eventcolumns

vector of column names specifying a single event time or multiple event times (in case of competing risks)

Value

data.frame containing original data and columns time, maxtime and status

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
library(missDeaths)

sim = md.simparams() +
  md.sex("sex", 0.5) + 
    md.uniform("birth", as.Date("1915-1-1"), as.Date("1930-1-1")) +
      md.uniform("start", as.Date("2000-1-1"), as.Date("2005-1-1")) +
        md.death("death", survexp.us, "sex", "birth", "start") +
          md.eval("age", "as.numeric(start - birth)/365.2425", 80, FALSE) + 
            md.exp("event", "start", c("age", "sex"), c(0.1, 2), 0.05/365.2425)
            
data = md.simulate(sim, 1000)
complete = md.censor(data, "start", as.Date("2010-1-1"), c("event", "death"))

## End(Not run)

missDeaths documentation built on Oct. 23, 2020, 6:39 p.m.