Learn R Programming

SimHaz (version 0.1)

tdSim.method1: Simulate 1 dataframe (1 simulation) of time-dep exposure under method 1

Description

This function generates a simulated dataset with time-dependent exposure under method 1 with a user-specified list of parameters as input. Survival times and censoring times are generated from the exponential distribution.

Usage

tdSim.method1(N, duration = 24, lambda, rho = 1, beta, rateC, exp.prop, 
    prop.fullexp  = 0, maxrelexptime = 1, min.futime = 0, min.postexp.futime = 0)

Arguments

N
Number of subjects needs to be screened
duration
Length of the study in Months. The default value is 24 (months)
lambda
Scale parameter of the Weibull distribution, which is calculated as log(2) / median time to event for control group
rho
Shape parameter of the Weibull distribution, which is defaulted as 1, as we generate survival times by using the exponential distribution
beta
A numeric value that represents the exposure effect, which is the regression coefficient (log hazard ratio) that represent the magnitude of the relationship between the exposure covariate and the risk of an event
rateC
Rate of the exponential distribution to generate censoring times, which is calculated as log(2) / median time to censoring
exp.prop
A numeric value between 0 and 1 (not include 0 and 1) that represents the proportion of subjects that are assigned with an exposure
prop.fullexp
A numeric value in interval [0, 1) that represents the proportion of exposed subjects that are fully exposed from the beginning to the end of the study. The default value is 0, which means all exposed subjects have an exposure status transition at some po
maxrelexptime
A numeric value in interval (0, 1] that represents the maximum relative exposure time. Suppose this value is p, the exposure time for each subject is then uniformly distributed from 0 to p*subject's time in the study. The default value is 1, which means a
min.futime
A numeric value that represents minimum follow-up time (in months). The default value is 0, which means no minimum follow-up time is considered. If it has a positive value, this argument will help exclude subjects that only spend a short amount of time in
min.postexp.futime
A numeric value that represents minimum post-exposure follow-up time (in months). The default value is 0, which means no minimum post-exposure follow-up time is considered. If it has a positive value, this argument will help exclude subjects that only spe

Value

  • idInteger that represents a subject's identification number
  • startFor counting process formulation. Represents the start of each time interval
  • stopFor counting process formulation. Represents the end of each time interval
  • statusIndicator of event. status = 1 when event occurs and 0 otherwise
  • xIndicator of exposure. x = 1 when exposed and 0 otherwise

Details

If no minimum follow-up time or minimum post-exposure follow-up time is considered (min.fut = 0 and min.postexp.fut = 0), then the output data frame will have N subjects. If we consider minimum follow-up time or both, then the output data frame will have at most N subjects.

References

Therneau and C. Crowson (2015). Using Time Dependent Covariates and Time Dependent Coefficients in the Cox Model.

https://cran.r-project.org/web/packages/survival/vignettes/timedep.pdf

Examples

Run this code
# Simulate a dataset of 600 subjects with time-dependent exposure without
# considering minimum follow-up time or minimum post-exposure follow-up time.
# Specifically, set the duration of the study to be 24 months; the median time to
# event for control group to be 24 months; exposure effect to be 0.3; median time
# to censoring to be 14 months; and exposure proportion to be 20%.

df1 <- tdSim.method1(N = 600, duration = 24, lambda = log(2)/24, rho = 1, 
   beta = 0.3, rateC = log(2)/14, exp.prop = 0.2, prop.fullexp  = 0, 
   maxrelexptime = 1, min.fut = 0, min.postexp.fut = 0)

# Simulate a dataset of 600 subjects with time-dependent exposure with
# both minimum follow-up time (4 months) and minimum post-exposure
# follow-up time (4 months) imposed. Other parameters remain the same as
# in the first case.

df2 <- tdSim.method1(N = 600, duration = 24, lambda = log(2)/24, rho = 1, 
   beta = 0.3, rateC = log(2)/14, exp.prop = 0.2, prop.fullexp  = 0, 
   maxrelexptime = 1, min.fut = 4, min.postexp.fut = 4)

# Simulate a dataset of 600 subjects with time-dependent exposure with
# both minimum follow-up time (4 months) and minimum post-exposure
# follow-up time (4 months) imposed. Also consider a quick exposure after
# entering the study for each exposed subject. Set the maximum relative
# exposure time to be 1/6. Other parameters remain the same as in the first case.

df3 <- tdSim.method1(N = 600, duration = 24, lambda = log(2)/24, rho = 1, 
   beta = 0.3, rateC = log(2)/14, exp.prop = 0.2, prop.fullexp  = 0,
   maxrelexptime = 1/6, min.fut = 4,min.postexp.fut = 4)

Run the code above in your browser using DataLab