jm.sim: Simulate from joint models

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/JMsim.R

Description

This function simlates longitudinal responses and event times from joint models. Available options are Weibull and log-logistic for the time-to-event submodel, and LME for the longitudinal process, with a simple linear model for the random-effects component (i.e., b_0 + b_1 * times, where b_0 and b_1 are the random intercept and random slope, respectively).

Usage

1
2
jm.sim(surv.formula, surv.par, surv.model, lme.formula, lme.par, times,
  timevar, Data)

Arguments

surv.formula

a one-sided formula of the form ~ z1 + z2 + ... + zp, where z1, z2, ..., zp are baseline covariates for the time-to-event process.

surv.par

a list of the form list(beta = a vector, phi = a scalar, logrho = a scalar, logkappa = a scalar, status.rho = a scalar) for the time-to-event model parameters, where beta is the vector of regression coefficients for the baseline covariates as specified in surv.formula (without an intercept), phi is the association parameter, logrho is the log of the rate parameter of the time-to-event distribution (Weibull or log-logistic), logkappa is the log of the shape parameter of the time-to-event distribution (Weibull or log-logistic), and status.rho is the rate parameter of the exponential distribution from which censored data are generated. Note that surv.par must be a named list as above. See survreg.fit for parameterizations of the time-to-event distributions.

surv.model

the AFT model to be used to describe the event process. Available options are "weibull" and "llogistic" for Weibull and log-logistic distributions, respectively.

lme.formula

a one-sided formula of the form ~ x1 + x2 + ... + xq + times, where x1, ..., xq are time-independent covariates for the longitudinal process and times is the time variable (time points at which longitudinal measurements are taken).

lme.par

a list of the form list(alpha = a vector, sigma2 = a scalar, Sigma = a 2 x 2 covariance matrix) for the longitudinal model parameters, where alpha is the vector of fixed-effects regression coefficients as specified in lme.formula (includes an intercept), sigma2 is the variance of measurement errors, and Sigma is the covariance matrix of the random effects b_{i0} and b_{i1} (only a simple linear model b_{i0} + b_{i1} * times is allowed for random effects). Note that lme.par must be a named list as above.

times

a numeric vector for the time points at which longitudinal measurements are planned to be taken.

timevar

the time variable (a character string) of the longitudinal model. For example, if lme.formula = ~ x1 + times, then timevar = "times".

Data

a data frame containing the baseline covariates z's for the time-to-event model and the time-independent covariates x's for the longitudinal model. For n subjects, it must must have n rows.

Details

This function simlates longitudinal responses and event times from joint models. Available options are Weibull and log-logistic for the time-to-event submodel, and LME for the longitudinal process, with a simple linear model for the random-effects component (i.e., b_0 + b_1 * times, where b_0 and b_1 are the random intercept and random slope, respectively). The survival function of the time-to-event model is of the form S_0(\int_0^t exp[-(β_1 z_1 + β_2 z_2 + ... + β_p z_p)-φ(b_0 + b_1 u)]du), and the longitudinal model is of the form y = α_0 + α_1 x_1 + ... + α_q x_q + α_{q+1} times + b_0 + b_1 times + ε. The amount of censoring can be controlled by changing the value of status.rho.

Value

A list with components:

b: random effects (a matrix).

long.data: simulated longitudinal data.

surv.data: simulated event time data.

Author(s)

Shahedul Khan <khan@math.usask.ca>

See Also

jmreg.aft

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  n<-200  # number of subjects
  surv.formula<- ~z1+z2 
  lme.formula<- ~x1+times 
# correlation matrix for random-effects
  cor.mat<-matrix(c(1,-0.2,-0.2,1),ncol=2,byrow=TRUE) 
# sd of random effects 
  sd<-c(0.5,0.1) 
# covariance matrix for random-effects
  Sigma<-(sd %*% t(sd))*cor.mat
# parameter values for lme (a named list) 
  lme.par<-list(alpha=c(10,1,-1),sigma2=0.5,Sigma=Sigma) 
# parameter values for the survival model (a named list)
  surv.par<-list(beta=c(-0.5,0.5),phi=-0.25,logrho=log(0.25),
      logkappa=log(2),status.rho=0.095) 
  set.seed(54566)
  z1<-rbinom(n,1,0.5)
  z2<-rnorm(n) 
# data with all covariate information 
  Data<-data.frame(z1=z1,z2=z2,x1=z1) 
# time points at which longitudinal measurements are planned to be taken
  times<-c(0,1,2,3,4) 
# simulate data with Weibull time-to-event model
  jmsim.dat<-jm.sim(surv.formula=surv.formula,surv.par=surv.par,
      surv.model="weibull",lme.formula=lme.formula,lme.par=lme.par,
      times=times,timevar="times",Data=Data) 
  surv.data<-jmsim.dat$surv.data
  long.data<-jmsim.dat$long.data
  surv.fit<-coxph(Surv(st,status)~z1+z2,data=surv.data,x=TRUE) 
  lme.fit<-lme(y~x1+times,random=~times | id,data=long.data) 
# Fit the joint model
  jmfit.w<-jmreg.aft(surv.fit=surv.fit,lme.fit=lme.fit,
      surv.model="weibull",rand.model="simple",timevar="times",
      n.chain=2,n.adapt =5000,n.burn=15000,n.iter=50000,n.thin = 5)
  sum.w<-jm.summary(jmfit.w,density.plot=TRUE,trace.plot=TRUE)
  sum.w

sa4khan/AFTjmr documentation built on March 12, 2020, 1:24 a.m.