artifCens: Artificial censoring

Description Usage Arguments Examples

View source: R/reformatFns.R

Description

Artificially impose censoring at either earliest censoring time or a user defined time.

Usage

1
artifCens(total.data, censtime = NA)

Arguments

total.data
censtime

Fraction of time between smallest and largest administrative censoring times [0,1]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (total.data, censtime = NA) 
{
    mix.disdteMax <- max(total.data$hes_disdte[total.data$infstatus == 
        0], na.rm = TRUE)
    inf.disdteMax <- max(total.data$hes_disdte[total.data$infstatus == 
        1], na.rm = TRUE)
    artifCens.time <- min(mix.disdteMax, inf.disdteMax)
    if (is.numeric(censtime) & !is.na(censtime)) {
        artifCens.time <- artifCens.time + (max(mix.disdteMax, 
            inf.disdteMax) - artifCens.time) * censtime
    }
    artifCens.dis <- total.data$hes_disdte > artifCens.time
    total.data$hes_dismethdescription[artifCens.dis] <- "Not applicable patient still in hospital"
    total.data$hes_dischargeddeadoralive[artifCens.dis] <- ""
    total.data$hes_disdte[artifCens.dis] <- artifCens.time
    total.data$missingType[artifCens.dis] <- 0
    artifCens.spec <- total.data$lab_Specimendate > artifCens.time
    total.data$infstatus[artifCens.spec] <- 0
    total.data$adm_diff_specdate[artifCens.spec] <- total.data$dis_diff_specdate[artifCens.spec] <- total.data$lab_Specimendate[artifCens.spec] <- NA
    total.data$adm_diff_dis <- with(total.data, hes_disdte - 
        hes_admdte)
    total.data
  }

n8thangreen/HESmanip documentation built on March 21, 2020, 12:20 a.m.