This function is used to generate simulated data under various settings. Let \(Z\) be a \(p\)-dimensional vector of possible time-dependent covariates and \(\beta\) be the vector of regression coefficient. The survival times (\(T\)) are generated from the hazard function specified as follow:

Scenario 1.1

Proportional hazards model: $$\lambda(t|Z) = \lambda_0(t) e^{-0.5 Z_1 + 0.5 Z_2 - 0.5 Z_3 ... + 0.5 Z_{10}},$$

where \lambda_0(t) = 2t.
Scenario 1.2

Proportional hazards model with noise variable: $$\lambda(t|Z) = \lambda_0(t) e^{2Z_1 + 2Z_2 + 0Z_3 + ... + 0Z_{10}},$$

where \lambda_0(t) = 2t.
Scenario 1.3

Proportional hazards model with nonlinear covariate effects: $$\lambda(t|Z) = \lambda_0(t) e^{[2\sin(2\pi Z_1) + 2|Z_2 - 0.5|]},$$

where \lambda_0(t) = 2t.
Scenario 1.4

Accelerated failure time model: $$\log(T) = -2 + 2Z_1 + 2Z_2 + \epsilon,$$ where \(\epsilon\) follows \(N(0, 0.5^2).\)

Scenario 1.5

Generalized gamma family: $$T = e^{\sigma\omega},$$ where \(\omega = \log(Q^2 g) / Q\), \(g\) follows Gamma(\(Q^{-2}, 1\)), \(\sigma = 2Z_1, Q = 2Z_2.\)

Scenario 2.1

Dichotomous time dependent covariate with at most one change in value: $$\lambda(t|Z(t)) = \lambda_0(t)e^{2Z_1(t) + 2Z_2},$$ where \(Z_1(t)\) is the time-dependent covariate: \(Z_1(t) = \theta I(t \ge U_0) + (1 - \theta) I(t < U_0)\), ,\(\theta\) is a Bernoulli variable with equal probability, and \(U_0\) follows a uniform distribution over \([0, 1]\).

Scenario 2.2

Dichotomous time dependent covariate with multiple changes: $$\lambda(t|Z(t)) = e^{2Z_1(t) + 2Z_2},$$ where \(Z_1(t) = \theta[I(U_1\le t < U_2) + I(U_3 \le t)] + (1 - \theta)[I(t < U_1) + I(U_2\le t < U_3)]\), \(\theta\) is a Bernoulli variable with equal probability, and \(U_1\le U_2\le U_3\) are the first three terms of a stationary Poisson process with rate 10.

Scenario 2.3

Proportional hazard model with a continuous time dependent covariate: $$\lambda(t|Z(t)) = 0.1 e^{Z_1(t) + Z_2},$$ where \(Z_1(t) = kt + b\), \(k\) and \(b\) are independent uniform random variables over \([1, 2]\).

Scenario 2.4

Non-proportional hazards model with a continuous time dependent covariate: $$\lambda(t|Z(t)) = 0.1 \cdot[1 + \sin\{Z_1(t) + Z_2\}],$$ where \(Z_1(t) = kt + b\), \(k\) and \(b\) follow independent uniform distributions over \([1, 2]\).

Scenario 2.5

Non-proportional hazards model with a nonlinear time dependent covariate: $$\lambda(t|Z(t)) = 0.1 \cdot[1 + \sin\{Z_1(t) + Z_2\}],$$ where \(Z_1(t) = 2kt\cdot \{I(t > 5) - 1\} + b\), \(k\) and \(b\) follow independent uniform distributions over \([1, 2]\).

The censoring times are generated from an independent uniform distribution over [0, c], where c was tuned to yield censoring percentages of 25% and 50%.
simu(n, cen, scenario, summary = FALSE)

trueHaz(dat)

trueSurv(dat)

Arguments

n

an integer value indicating the number of subjects.

cen

is a numeric value indicating the censoring percentage; three levels, 0%, 25%, 50%, are allowed.

scenario

can be either a numeric value or a character string. This indicates the simulation scenario noted above.

summary

a logical value indicating whether a brief data summary will be printed.

dat

is a data.frame prepared by simu.

Value

simu returns a data.frame. The returned data.frame consists of columns:

id

is the subject id.

Y

is the observed follow-up time.

death

is the death indicator; death = 0 if censored.

z1--z10

is the possible time-independent covariate.

k, b, U

are the latent variables used to generate $Z_1(t)$ in Scenario 2.1 -- 2.5.

The returned data.frame can be supply to trueHaz and trueSurv to generate the true cumulative hazard function and the survival function, respectively.

Examples

set.seed(1) simu(10, 0.25, 1.2, TRUE)
#> Summary results: #> Number of subjects: 10 #> Number of subjects experienced death: 9 #> Number of covariates: 10 #> Time independent covaraites: z1 z2 z3 z4 z5 z6 z7 z8 z9 z10 #> Number of unique observation times: 10 #> Median survival time: 0.2983867 #>
#> id Time death z1 z2 z3 z4 z5 #> 1 1 0.08224125 0 0.26550866 0.2059746 0.93470523 0.4820801 0.8209463 #> 2 1 0.12310252 0 0.26550866 0.2059746 0.93470523 0.4820801 0.8209463 #> 3 1 0.23784796 0 0.26550866 0.2059746 0.93470523 0.4820801 0.8209463 #> 4 1 0.23935211 0 0.26550866 0.2059746 0.93470523 0.4820801 0.8209463 #> 5 1 0.24961223 0 0.26550866 0.2059746 0.93470523 0.4820801 0.8209463 #> 6 1 0.34716119 1 0.26550866 0.2059746 0.93470523 0.4820801 0.8209463 #> 7 2 0.08224125 0 0.37212390 0.1765568 0.21214252 0.5995658 0.6470602 #> 8 2 0.12310252 0 0.37212390 0.1765568 0.21214252 0.5995658 0.6470602 #> 9 2 0.23784796 0 0.37212390 0.1765568 0.21214252 0.5995658 0.6470602 #> 10 2 0.23935211 0 0.37212390 0.1765568 0.21214252 0.5995658 0.6470602 #> 11 2 0.24961223 0 0.37212390 0.1765568 0.21214252 0.5995658 0.6470602 #> 12 2 0.34716119 0 0.37212390 0.1765568 0.21214252 0.5995658 0.6470602 #> 13 2 0.39845315 0 0.37212390 0.1765568 0.21214252 0.5995658 0.6470602 #> 14 2 0.42105595 0 0.37212390 0.1765568 0.21214252 0.5995658 0.6470602 #> 15 2 0.57282451 0 0.37212390 0.1765568 0.21214252 0.5995658 0.6470602 #> 16 2 0.60754167 1 0.37212390 0.1765568 0.21214252 0.5995658 0.6470602 #> 17 3 0.08224125 0 0.57285336 0.6870228 0.65167377 0.4935413 0.7829328 #> 18 3 0.12310252 0 0.57285336 0.6870228 0.65167377 0.4935413 0.7829328 #> 19 3 0.23784796 0 0.57285336 0.6870228 0.65167377 0.4935413 0.7829328 #> 20 3 0.23935211 0 0.57285336 0.6870228 0.65167377 0.4935413 0.7829328 #> 21 3 0.24961223 1 0.57285336 0.6870228 0.65167377 0.4935413 0.7829328 #> 22 4 0.08224125 1 0.90820779 0.3841037 0.12555510 0.1862176 0.5530363 #> 23 5 0.08224125 0 0.20168193 0.7698414 0.26722067 0.8273733 0.5297196 #> 24 5 0.12310252 0 0.20168193 0.7698414 0.26722067 0.8273733 0.5297196 #> 25 5 0.23784796 0 0.20168193 0.7698414 0.26722067 0.8273733 0.5297196 #> 26 5 0.23935211 0 0.20168193 0.7698414 0.26722067 0.8273733 0.5297196 #> 27 5 0.24961223 0 0.20168193 0.7698414 0.26722067 0.8273733 0.5297196 #> 28 5 0.34716119 0 0.20168193 0.7698414 0.26722067 0.8273733 0.5297196 #> 29 5 0.39845315 1 0.20168193 0.7698414 0.26722067 0.8273733 0.5297196 #> 30 6 0.08224125 0 0.89838968 0.4976992 0.38611409 0.6684667 0.7893562 #> 31 6 0.12310252 1 0.89838968 0.4976992 0.38611409 0.6684667 0.7893562 #> 32 7 0.08224125 0 0.94467527 0.7176185 0.01339033 0.7942399 0.0233312 #> 33 7 0.12310252 0 0.94467527 0.7176185 0.01339033 0.7942399 0.0233312 #> 34 7 0.23784796 1 0.94467527 0.7176185 0.01339033 0.7942399 0.0233312 #> 35 8 0.08224125 0 0.66079779 0.9919061 0.38238796 0.1079436 0.4772301 #> 36 8 0.12310252 0 0.66079779 0.9919061 0.38238796 0.1079436 0.4772301 #> 37 8 0.23784796 0 0.66079779 0.9919061 0.38238796 0.1079436 0.4772301 #> 38 8 0.23935211 0 0.66079779 0.9919061 0.38238796 0.1079436 0.4772301 #> 39 8 0.24961223 0 0.66079779 0.9919061 0.38238796 0.1079436 0.4772301 #> 40 8 0.34716119 0 0.66079779 0.9919061 0.38238796 0.1079436 0.4772301 #> 41 8 0.39845315 0 0.66079779 0.9919061 0.38238796 0.1079436 0.4772301 #> 42 8 0.42105595 1 0.66079779 0.9919061 0.38238796 0.1079436 0.4772301 #> 43 9 0.08224125 0 0.62911404 0.3800352 0.86969085 0.7237109 0.7323137 #> 44 9 0.12310252 0 0.62911404 0.3800352 0.86969085 0.7237109 0.7323137 #> 45 9 0.23784796 0 0.62911404 0.3800352 0.86969085 0.7237109 0.7323137 #> 46 9 0.23935211 1 0.62911404 0.3800352 0.86969085 0.7237109 0.7323137 #> 47 10 0.08224125 0 0.06178627 0.7774452 0.34034900 0.4112744 0.6927316 #> 48 10 0.12310252 0 0.06178627 0.7774452 0.34034900 0.4112744 0.6927316 #> 49 10 0.23784796 0 0.06178627 0.7774452 0.34034900 0.4112744 0.6927316 #> 50 10 0.23935211 0 0.06178627 0.7774452 0.34034900 0.4112744 0.6927316 #> 51 10 0.24961223 0 0.06178627 0.7774452 0.34034900 0.4112744 0.6927316 #> 52 10 0.34716119 0 0.06178627 0.7774452 0.34034900 0.4112744 0.6927316 #> 53 10 0.39845315 0 0.06178627 0.7774452 0.34034900 0.4112744 0.6927316 #> 54 10 0.42105595 0 0.06178627 0.7774452 0.34034900 0.4112744 0.6927316 #> 55 10 0.57282451 0 0.06178627 0.7774452 0.34034900 0.4112744 0.6927316 #> z6 z7 z8 z9 z10 #> 1 0.47761962 0.91287592 0.3390729 0.4346595 0.23962942 #> 2 0.47761962 0.91287592 0.3390729 0.4346595 0.23962942 #> 3 0.47761962 0.91287592 0.3390729 0.4346595 0.23962942 #> 4 0.47761962 0.91287592 0.3390729 0.4346595 0.23962942 #> 5 0.47761962 0.91287592 0.3390729 0.4346595 0.23962942 #> 6 0.47761962 0.91287592 0.3390729 0.4346595 0.23962942 #> 7 0.86120948 0.29360337 0.8394404 0.7125147 0.05893438 #> 8 0.86120948 0.29360337 0.8394404 0.7125147 0.05893438 #> 9 0.86120948 0.29360337 0.8394404 0.7125147 0.05893438 #> 10 0.86120948 0.29360337 0.8394404 0.7125147 0.05893438 #> 11 0.86120948 0.29360337 0.8394404 0.7125147 0.05893438 #> 12 0.86120948 0.29360337 0.8394404 0.7125147 0.05893438 #> 13 0.86120948 0.29360337 0.8394404 0.7125147 0.05893438 #> 14 0.86120948 0.29360337 0.8394404 0.7125147 0.05893438 #> 15 0.86120948 0.29360337 0.8394404 0.7125147 0.05893438 #> 16 0.86120948 0.29360337 0.8394404 0.7125147 0.05893438 #> 17 0.43809711 0.45906573 0.3466835 0.3999944 0.64228826 #> 18 0.43809711 0.45906573 0.3466835 0.3999944 0.64228826 #> 19 0.43809711 0.45906573 0.3466835 0.3999944 0.64228826 #> 20 0.43809711 0.45906573 0.3466835 0.3999944 0.64228826 #> 21 0.43809711 0.45906573 0.3466835 0.3999944 0.64228826 #> 22 0.24479728 0.33239467 0.3337749 0.3253522 0.87626921 #> 23 0.07067905 0.65087047 0.4763512 0.7570871 0.77891468 #> 24 0.07067905 0.65087047 0.4763512 0.7570871 0.77891468 #> 25 0.07067905 0.65087047 0.4763512 0.7570871 0.77891468 #> 26 0.07067905 0.65087047 0.4763512 0.7570871 0.77891468 #> 27 0.07067905 0.65087047 0.4763512 0.7570871 0.77891468 #> 28 0.07067905 0.65087047 0.4763512 0.7570871 0.77891468 #> 29 0.07067905 0.65087047 0.4763512 0.7570871 0.77891468 #> 30 0.09946616 0.25801678 0.8921983 0.2026923 0.79730883 #> 31 0.09946616 0.25801678 0.8921983 0.2026923 0.79730883 #> 32 0.31627171 0.47854525 0.8643395 0.7111212 0.45527445 #> 33 0.31627171 0.47854525 0.8643395 0.7111212 0.45527445 #> 34 0.31627171 0.47854525 0.8643395 0.7111212 0.45527445 #> 35 0.51863426 0.76631067 0.3899895 0.1216919 0.41008408 #> 36 0.51863426 0.76631067 0.3899895 0.1216919 0.41008408 #> 37 0.51863426 0.76631067 0.3899895 0.1216919 0.41008408 #> 38 0.51863426 0.76631067 0.3899895 0.1216919 0.41008408 #> 39 0.51863426 0.76631067 0.3899895 0.1216919 0.41008408 #> 40 0.51863426 0.76631067 0.3899895 0.1216919 0.41008408 #> 41 0.51863426 0.76631067 0.3899895 0.1216919 0.41008408 #> 42 0.51863426 0.76631067 0.3899895 0.1216919 0.41008408 #> 43 0.66200508 0.08424691 0.7773207 0.2454885 0.81087024 #> 44 0.66200508 0.08424691 0.7773207 0.2454885 0.81087024 #> 45 0.66200508 0.08424691 0.7773207 0.2454885 0.81087024 #> 46 0.66200508 0.08424691 0.7773207 0.2454885 0.81087024 #> 47 0.40683019 0.87532133 0.9606180 0.1433044 0.60493329 #> 48 0.40683019 0.87532133 0.9606180 0.1433044 0.60493329 #> 49 0.40683019 0.87532133 0.9606180 0.1433044 0.60493329 #> 50 0.40683019 0.87532133 0.9606180 0.1433044 0.60493329 #> 51 0.40683019 0.87532133 0.9606180 0.1433044 0.60493329 #> 52 0.40683019 0.87532133 0.9606180 0.1433044 0.60493329 #> 53 0.40683019 0.87532133 0.9606180 0.1433044 0.60493329 #> 54 0.40683019 0.87532133 0.9606180 0.1433044 0.60493329 #> 55 0.40683019 0.87532133 0.9606180 0.1433044 0.60493329
set.seed(1) simu(10, 0.50, 2.2, TRUE)
#> Summary results: #> Number of subjects: 10 #> Number of subjects experienced death: 7 #> Number of covariates: 2 #> Time independent covaraites: z1. #> Time dependent covaraites: z2. #> Number of unique observation times: 10 #> Median survival time: 0.04646691 #>
#> id Time death z1 z2 e u1 u2 u3 #> 1 1 0.001833644 0 0 0.2059746 1 0.10352439 0.10946831 0.21174090 #> 2 1 0.005359356 0 0 0.2059746 1 0.10352439 0.10946831 0.21174090 #> 3 1 0.006044053 0 0 0.2059746 1 0.10352439 0.10946831 0.21174090 #> 4 1 0.007712142 0 0 0.2059746 1 0.10352439 0.10946831 0.21174090 #> 5 1 0.033465278 0 0 0.2059746 1 0.10352439 0.10946831 0.21174090 #> 6 1 0.046466912 0 0 0.2059746 1 0.10352439 0.10946831 0.21174090 #> 7 1 0.067509341 0 0 0.2059746 1 0.10352439 0.10946831 0.21174090 #> 8 1 0.075695619 0 0 0.2059746 1 0.10352439 0.10946831 0.21174090 #> 9 1 0.093982057 0 0 0.2059746 1 0.10352439 0.10946831 0.21174090 #> 10 1 0.264169949 0 1 0.2059746 1 0.10352439 0.10946831 0.21174090 #> 11 2 0.001833644 0 1 0.1765568 0 0.18760352 0.24547476 0.27564886 #> 12 2 0.005359356 0 1 0.1765568 0 0.18760352 0.24547476 0.27564886 #> 13 2 0.006044053 0 1 0.1765568 0 0.18760352 0.24547476 0.27564886 #> 14 2 0.007712142 0 1 0.1765568 0 0.18760352 0.24547476 0.27564886 #> 15 2 0.033465278 0 1 0.1765568 0 0.18760352 0.24547476 0.27564886 #> 16 2 0.046466912 0 1 0.1765568 0 0.18760352 0.24547476 0.27564886 #> 17 2 0.067509341 0 1 0.1765568 0 0.18760352 0.24547476 0.27564886 #> 18 2 0.075695619 0 1 0.1765568 0 0.18760352 0.24547476 0.27564886 #> 19 2 0.093982057 1 1 0.1765568 0 0.18760352 0.24547476 0.27564886 #> 20 3 0.001833644 0 0 0.6870228 1 0.06547466 0.46136795 0.53388938 #> 21 3 0.005359356 0 0 0.6870228 1 0.06547466 0.46136795 0.53388938 #> 22 3 0.006044053 0 0 0.6870228 1 0.06547466 0.46136795 0.53388938 #> 23 3 0.007712142 0 0 0.6870228 1 0.06547466 0.46136795 0.53388938 #> 24 3 0.033465278 0 0 0.6870228 1 0.06547466 0.46136795 0.53388938 #> 25 3 0.046466912 0 0 0.6870228 1 0.06547466 0.46136795 0.53388938 #> 26 3 0.067509341 0 1 0.6870228 1 0.06547466 0.46136795 0.53388938 #> 27 3 0.075695619 1 1 0.6870228 1 0.06547466 0.46136795 0.53388938 #> 28 4 0.001833644 0 1 0.3841037 0 0.03369335 0.15102456 0.22617883 #> 29 4 0.005359356 0 1 0.3841037 0 0.03369335 0.15102456 0.22617883 #> 30 4 0.006044053 1 1 0.3841037 0 0.03369335 0.15102456 0.22617883 #> 31 5 0.001833644 0 1 0.7698414 0 0.05884797 0.15852927 0.18203201 #> 32 5 0.005359356 0 1 0.7698414 0 0.05884797 0.15852927 0.18203201 #> 33 5 0.006044053 0 1 0.7698414 0 0.05884797 0.15852927 0.18203201 #> 34 5 0.007712142 0 1 0.7698414 0 0.05884797 0.15852927 0.18203201 #> 35 5 0.033465278 0 1 0.7698414 0 0.05884797 0.15852927 0.18203201 #> 36 5 0.046466912 1 1 0.7698414 0 0.05884797 0.15852927 0.18203201 #> 37 6 0.001833644 0 1 0.4976992 0 0.23645153 0.37998006 0.48796817 #> 38 6 0.005359356 1 1 0.4976992 0 0.23645153 0.37998006 0.48796817 #> 39 7 0.001833644 1 1 0.7176185 0 0.06418926 0.06791611 0.17074080 #> 40 8 0.001833644 0 1 0.9919061 0 0.02941204 0.06181305 0.19103922 #> 41 8 0.005359356 0 1 0.9919061 0 0.02941204 0.06181305 0.19103922 #> 42 8 0.006044053 0 1 0.9919061 0 0.02941204 0.06181305 0.19103922 #> 43 8 0.007712142 1 1 0.9919061 0 0.02941204 0.06181305 0.19103922 #> 44 9 0.001833644 0 0 0.3800352 1 0.05658655 0.18863335 0.31394388 #> 45 9 0.005359356 0 0 0.3800352 1 0.05658655 0.18863335 0.31394388 #> 46 9 0.006044053 0 0 0.3800352 1 0.05658655 0.18863335 0.31394388 #> 47 9 0.007712142 0 0 0.3800352 1 0.05658655 0.18863335 0.31394388 #> 48 9 0.033465278 0 0 0.3800352 1 0.05658655 0.18863335 0.31394388 #> 49 10 0.001833644 0 1 0.7774452 0 0.01060726 0.03095830 0.08642244 #> 50 10 0.005359356 0 1 0.7774452 0 0.01060726 0.03095830 0.08642244 #> 51 10 0.006044053 0 1 0.7774452 0 0.01060726 0.03095830 0.08642244 #> 52 10 0.007712142 0 1 0.7774452 0 0.01060726 0.03095830 0.08642244 #> 53 10 0.033465278 0 1 0.7774452 0 0.01060726 0.03095830 0.08642244 #> 54 10 0.046466912 0 1 0.7774452 0 0.01060726 0.03095830 0.08642244 #> 55 10 0.067509341 0 1 0.7774452 0 0.01060726 0.03095830 0.08642244