sim_data | R Documentation |
sim_data
is used to simulate longitudinal time-to-event data.
Users are allowed to specify the sample size, event rate and number of time-independent noise variables.
Currently, only one time-dependent covariate can be incorporated. The inclusion of multiple
time-dependent covariates will be permitted in the future versions.
Users can also generate long dataset at user-specified time-points.
The event time can be generated from two different distributions, either
from a proportional hazard model or an accelerated failure time model.
sim_data(n, er, dist = "PH", noise = 0, time_points = NULL)
n |
the sample size |
er |
the event rate (range 0-1) |
dist |
a character variable that specify the distribution of event time. "PH" for proportional hazard model (Default), "AFT" for accelerated failure time model. |
noise |
the number of time-independent noise variables. |
time_points |
an optional numeric vector containing the user-specified time points. |
a list of three objects relating simulated time-to-event data with time-dependent covariates.
T_failure
is a subject-level dataframe that contains the underlying non-censored event time
and observation status (1: non-censored; 0: censored).
Z
is the longitudinal dataset of time-dependent covariates at unique event time
or user-specified time points (when the argument time_point
is supplied).
Data points are preserved even for subjects who are no longer at risk.
The last four columns, in order, are time, event status (1:event; 0:non-event), unique identifier for subject
and at-risk status (1:at risk; 0: not at risk). The rest leading columns are time-dependent covariates.
T_90
is the 90th percentile of event time.
set.seed(1236) dat <- sim_data(n=100, er=0.6) dat <- sim_data(n=200, er=0.3, dist="AFT", noise=10) dat <- sim_data(n=100, er=0.6, time_points = seq(from=0.1, to=1, by=0.1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.