create_countprocess_data: Create count process data set, eg, for use in time-dependent...

Description Usage Arguments Value See Also Examples

View source: R/create_countprocess_data.R

Description

Note that Zhiguo (Alex) Zhao wrote the majority of this code, with later edits by Cole Beck and minor ones by me. It is here for my convenience, since Alex shared it with me and to my knowledge it is not available elsewhere, not in an attempt to take credit.

Usage

1
2
3
create_countprocess_data(org.data, id.var, record.var, time.var, event.var,
  event.string, data.set, out.strings = c("Alive through end of interval",
  "Died at end of interval"))

Arguments

org.data

Original data frame with multiple records per patient

id.var

Variable name for subject identifier (eg, ID)

record.var

Variable name for record identifier (eg, study day)

time.var

Variable indicating end of records (eg, day of death)

event.var

Variable indicating whether event happened (eg, "died.yn")

event.string

Level of event variable indicating whether event happened (eg, "yes")

data.set

Data set (one record/pt) containing time/event variables

out.strings

Labels for 0/1 values of outcome variable

Value

data.frame containing reference, comparison, effect, lower and upper confidence limits, variable name and indicator for whether row contains reference:reference comparison.

See Also

Terry Therneau et al's vignette on time-dependent Cox models, survival package.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Create longitudinal data frame
longdf <- data.frame(id = c(rep(1, 8), rep(2, 10)),
                     day = c(1:8, 1:10),
                     v1 = sample(1:5, size = 18, replace = TRUE),
                     v2 = sample(LETTERS[1:5], size = 18, replace = TRUE))

## Create data frame with event status and times
eventdf <- data.frame(id = 1:2,
                      died = c('Yes', 'No'),
                      days.deathorend = c(8, 10))

## Create count process data set
create_countprocess_data(org.data = longdf,
                         id.var = 'id',
                         record.var = 'day',
                         time.var = 'days.deathorend',
                         event.var = 'died',
                         event.string = 'Yes',
                         data.set = eventdf)

jenniferthompson/JTHelpers documentation built on May 19, 2019, 4:04 a.m.