R: Simulate 1 dataframe (1 simulation) of time-dep exposure...
tdSim.method1
R Documentation
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.
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 point during the study
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 all exposed subjects have an exposure status transition at any point during the time in study.
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 the study
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 spend a short amount of time in the study after their exposure
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.
Value
A data.frame object with columns corresponding to
id
Integer that represents a subject's identification number
start
For counting process formulation. Represents the start of each time interval
stop
For counting process formulation. Represents the end of each time interval
status
Indicator of event. status = 1 when event occurs and 0 otherwise
x
Indicator of exposure. x = 1 when exposed and 0 otherwise
# 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)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(SimHaz)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SimHaz/tdSim.method1.Rd_%03d_medium.png", width=480, height=480)
> ### Name: tdSim.method1
> ### Title: Simulate 1 dataframe (1 simulation) of time-dep exposure under
> ### method 1
> ### Aliases: tdSim.method1
> ### Keywords: Simulation
>
> ### ** Examples
>
> # 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)
>
>
>
>
>
> dev.off()
null device
1
>