Description Usage Arguments Details Value Author(s) References Examples
This function simulates longitudinal and timetoevent data from a joint model.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 
n 
the number of subjects to simulate data for. 
model 
a character string specifying the type of latent association.
This defaults to the intercept and slope version as seen in Wulfsohn and
Tsiatis (1997). For association via the random intercept only, choose

sepassoc 
logical value: if 
ntms 
the maximum number of (discrete) time points to simulate repeated longitudinal measurements at. 
b1 
a vector specifying the coefficients of the fixed effects in the longitudinal submodel. The order in each row is intercept, a continuous covariate, covariate, a binary covariate, the measurement time. 
b2 
a vector of 
gamma 
a vector of specifying the latent association parameter(s) for
the longitudinal outcome. It must be of length 1 if 
sigu 
a positivedefinite matrix specifying the variancecovariance
matrix. If 
vare 
a numeric value specifying the residual standard error. 
theta0, theta1 
parameters controlling the failure rate. See Details. 
censoring 
logical: if 
censlam 
a scale (>0) parameter for an exponential distribution
used to simulate random censoring times for when 
truncation 
logical: if 
trunctime 
a truncation time for use when 
gridstep 
the stepsize for the grid used to simulate event times when

The function simjoint
simulates data from a joint model,
similar to that performed in Henderson et al. (2000). It works by first
simulating longitudinal data for all possible followup times using random
draws for the multivariate Gaussian random effects and residual error
terms. Data can be simulated assuming either randomintercepts only
(model = "int"
) in each of the longitudinal submodels;
randomintercepts and randomslopes (model = "intslope"
); or
quadratic random effects structures (model = "quad"
). The failure
times are simulated from proportional hazards timetoevent models, using
the following methodologies:
model = "int"
The baseline hazard function is specified to be an exponential distribution with
λ_0(t) = \exp{θ_0}.
Simulation is conditional on known timeindependent effects, and the methodology of Bender et al. (2005) is used to simulate the failure time.
model = "intslope"
The baseline hazard function is specified to be a Gompertz distribution with
λ_0(t) = \exp{θ_0 + θ_1 t}.
In the usual representation of the Gompertz distribution, θ_1 is the shape parameter, and the scale parameter is equivalent to \exp(θ_0). Simulation is conditional on on a predictable (linear) timevarying process, and the methodology of Austin (2012) is used to simulate the failure time.
model="quad"
The baseline hazard function is specified as per
model="intslope"
. The integration technique used for the above two
cases is complex in quadratic (and higher order) models, therefore we use a
different approach. We note that hazard function can be written as
\lim_{dt \rightarrow 0} λ(t) dt = \lim_{dt \rightarrow 0} P[t ≤ T ≤ t + dt  T ≥ t].
In the simulation routine the parameter gridstep
acts as dt in
that we choose a nominally small value, which multiplies the hazard and
this scaled hazard is equivalent to the probability of having an event in
the interval (t, t + dt), or equivalently (t, t +
gridstep
). A vector of possible times is set up for each
individual, ranging from 0 to trunctime
in increments of dt (or
gridstep
). The failure probability at each time is compared to an
independent U(0, 1) draw, and if the probability does not exceed the
random draw then the survival time is set as trunctime
, otherwise it
is the generated time from the vector of candidate times. The minimum of
these candidate times (i.e. when we deem the event to have first happened)
is taken as the survival time.
A list of 2 data.frame
s: one recording the requisite
longitudinal outcomes data, and one recording the timetoevent data.
Pete Philipson
Austin PC. Generating survival times to simulate Cox proportional hazards models with timevarying covariates. Stat Med. 2012; 31(29): 39463958.
Bender R, Augustin T, Blettner M. Generating survival times to simulate Cox proportional hazards models. Stat Med. 2005; 24: 17131723.
Henderson R, Diggle PJ, Dobson A. Joint modelling of longitudinal measurements and event time data. Biostatistics. 2000; 1(4): 465480.
1 
Loading required package: survival
90% experienced event
$longitudinal
id Y time intercept ctsxl binxl ltime
1 1 3.02286464 0 1 0.53853824 0 0
2 1 2.56739365 1 1 0.53853824 0 1
3 2 0.37887665 0 1 0.87010820 0 0
4 2 0.62445689 1 1 0.87010820 0 1
5 2 0.79691682 2 1 0.87010820 0 2
6 2 0.83935060 3 1 0.87010820 0 3
7 2 1.10916654 4 1 0.87010820 0 4
8 3 1.02812010 0 1 0.53117302 0 0
9 3 0.73377986 1 1 0.53117302 0 1
10 4 1.82009714 0 1 0.05398401 0 0
11 4 4.29024221 1 1 0.05398401 0 1
12 4 6.92207504 2 1 0.05398401 0 2
13 5 0.77686279 0 1 0.14287524 0 0
14 5 1.96727196 1 1 0.14287524 0 1
15 5 3.28054386 2 1 0.14287524 0 2
16 5 4.65646695 3 1 0.14287524 0 3
17 6 0.58549813 0 1 0.65451963 0 0
18 6 0.32350394 1 1 0.65451963 0 1
19 6 0.04780583 2 1 0.65451963 0 2
20 6 0.42113495 3 1 0.65451963 0 3
21 7 1.38670192 0 1 0.17176097 1 0
22 7 1.32335838 1 1 0.17176097 1 1
23 7 3.97374685 2 1 0.17176097 1 2
24 7 6.59571886 3 1 0.17176097 1 3
25 8 1.07622025 0 1 1.09697154 0 0
26 8 0.81536925 1 1 1.09697154 0 1
27 8 2.64830669 2 1 1.09697154 0 2
28 8 4.71079180 3 1 1.09697154 0 3
29 8 6.51770420 4 1 1.09697154 0 4
30 9 2.15771113 0 1 1.27944478 1 0
31 9 1.57054830 1 1 1.27944478 1 1
32 10 0.81335295 0 1 1.85527181 1 0
33 10 1.93939639 1 1 1.85527181 1 1
34 10 2.80191817 2 1 1.85527181 1 2
$survival
id survtime cens ctsx binx
1 1 1.194932 1 0.53853824 0
2 2 4.047252 1 0.87010820 0
3 3 1.933055 0 0.53117302 0
4 4 2.202683 1 0.05398401 0
5 5 3.293996 1 0.14287524 0
6 6 3.974561 1 0.65451963 0
7 7 3.749802 1 0.17176097 1
8 8 5.586596 1 1.09697154 0
9 9 1.834924 1 1.27944478 1
10 10 2.742520 1 1.85527181 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.