Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

SurvExpand

Convert a data frame of non-equal interval continuous observations into equal interval continuous observations


Description

SurvExpand convert a data frame of non-equal interval continuous observations into equal interval continuous observations. This is useful for creating time-interactions with tvc.

Usage

SurvExpand(
  data,
  GroupVar,
  Time,
  Time2,
  event,
  PartialData = TRUE,
  messages = TRUE
)

Arguments

data

a data frame.

GroupVar

a character string naming the unit grouping variable.

Time

a character string naming the variable with the interval start time.

Time2

a character string naming the variable with the interval end time.

event

a character string naming the event variable. Note: must be numeric with 0 indicating no event.

PartialData

logical indicating whether or not to keep only the expanded data required to find the Cox partial likelihood.

messages

logical indicating if you want messages returned while the function is working.

Details

The function primarily prepares data from the creation of accurate time-interactions with the tvc command. Note: the function will work best if your original time intervals are recorded in whole numbers. It also currently does not support repeated events data.

Value

Returns a data frame where observations have been expanded into equally spaced time intervals.

References

Gandrud, Christopher. 2015. simPH: An R Package for Illustrating Estimates from Cox Proportional Hazard Models Including for Interactive and Nonlinear Effects. Journal of Statistical Software. 65(3)1-20.

See Also

Examples

# Load Golub & Steunenberg (2007) Data
data("GolubEUPData")

# Subset PURELY TO SPEED UP THE EXAMPLE
GolubEUPData <- GolubEUPData[1:500, ]

# Expand data
GolubEUPDataExpand <- SurvExpand(GolubEUPData, GroupVar = 'caseno',
                       Time = 'begin', Time2 = 'end', event = 'event')

simPH

Simulate and Plot Estimates from Cox Proportional Hazards Models

v1.3.13
GPL-3
Authors
Christopher Gandrud [aut, cre]
Initial release
2021-01-09

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.