simsurvdata | R Documentation |
Generates right censored time-to-event data. Latent event times are drawn from a Weibull distribution, while censoring times are generated from an exponential distribution.
simsurvdata(a, b, n, betas, censperc, tmax = NULL)
a, b |
The shape parameter 'a>0' and scale parameter 'b>0' of the Weibull. |
n |
Sample size. |
betas |
A numeric vector of regression coefficients. Allowed components of 'betas' are in the interval [-1 ,1] and the total number of components cannot exceed 5. |
censperc |
A numeric value in [0,100] corresponding to the targeted percentage of censoring. |
tmax |
A maximum upper bound for the generated latent event times. Especially useful for a simulation study in which the observed event times are constrained to be generated in a fixed range. |
The Weibull baseline hazard is parameterized as follows (see Hamada et al. 2008 pp. 408-409) :
h_0(t) = (a/(b^a)) t^(a-1), t > 0.
The ith latent event time is denoted by T_i and is generated following Bender et al. (2005) as follows:
T_i = b (-log(U_i) exp(-β^T x_i))^(1/a),
where U_i is a uniform random variable obtained with 'runif(1)' , x_i is the ith row of a covariate matrix X of dimension 'c(n, length(betas))' where each component is generated from a standard Gaussian distribution and β is the vector of regression coefficients given by 'betas'.
An object of class 'simsurvdata' which is a list with the following components:
sample.size |
Sample size. |
censoring |
Censoring scheme. Either No censoring or Exponential. |
num.events |
Number of events. |
censoring.percentage |
The effective censoring percentage. |
survdata |
A data frame containing the simulated data. |
regcoeffs |
The true regression coefficients used to simulate the data. |
S0 |
The baseline survival function under the chosen Weibull parameterization. |
h0 |
The baseline hazard function under the chosen Weibull parameterization. |
Weibull.mean |
The mean of the Weibull used to generate latent event times. |
Weibull.variance |
The variance of the Weibull used to generate latent event times. |
The 'print' method summarizes the generated right censored data and the 'plot' method produces a graph with time on the x axis and horizontal bars on the y axis corresponding either to an event or a right censored observation. If 'n > 25', only the 25 first observations are plotted.
Oswaldo Gressani oswaldo_gressani@hotmail.fr.
Bender, R., Augustin, T. and Blettner, M. (2005). Generating survival times to simulate Cox proportional hazards models, Statistics in Medicine 24(11): 1713-1723.
Hamada, M. S., Wilson, A., Reese, C. S. and Martz, H. (2008). Bayesian Reliability. Springer Science and Business Media.
set.seed(10) sim <- simsurvdata(a = 2, b = 1, n = 300, betas = c(0.8, -0.6), censperc = 25) sim plot(sim)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.