simjointmeta: Simulation of multi-study joint data

Description Usage Arguments Details Value References See Also Examples

View source: R/simjointmeta.R

Description

Function to allow the simulation of a correlated single continuous longitudinal outcome and a single survival outcome for data from multiple studies. The longitudinal sub-model contains a fixed intercept, time (slope) term and a binary treatment assignment covariate, whilst the survival sub-model contains only a binary treatment assignment covariate.

Usage

1
2
3
4
5
6
7
simjointmeta(k = 5, n = rep(500, 5), sepassoc = FALSE, ntms = 5,
  longmeasuretimes = c(0, 1, 2, 3, 4), beta1 = c(1, 1, 1), beta2 = 1,
  rand_ind = c("intslope", "int"), rand_stud = c("int", "inttreat", "treat",
  NULL), gamma_ind = 1, gamma_stud = NULL, sigb_ind, sigb_stud = NULL,
  vare = 0.01, theta0 = -3, theta1 = 1, censoring = TRUE,
  censlam = exp(-3), truncation = FALSE,
  trunctime = max(longmeasuretimes))

Arguments

k

the number of studies to be simulated

n

a vector of length equal to k denoting the number of individuals to simulate per study

sepassoc

a logical taking value FALSE if proportional association is required, TRUE if a separate association parameter is required for each random effect shared between the sub-models

ntms

the maximum possible number of longitudinal measurements - should equal the length of the supplied longmeasuretimes

longmeasuretimes

a vector giving the exact times of the longitudinal measurement times. If this is not specified in the function call then the measurement times of the longitudinal outcome are set to start at 0 then take integer values up to and including ntms - 1.

beta1

a vector of the fixed effects for the longitudinal sub-model. Here the first element gives the coefficient for a fixed or population intercept, the second gives the coefficient for the binary treatment assignment covariate and the third element gives the covariate for the time (slope) covariate

beta2

the coefficient for the binary treatment assignment covariate

rand_ind

a character string specifying the individual level random effects structure. If rand_ind = 'intslope' then there is an individual specific random intercept and random time (slope) term included in the model. If rand_ind = 'int' then the model includes only a individual specific random intercept.

rand_stud

a character string specifying the study level random effects structure. If this is set to NULL or not specified in the function call then no study level random effects are included in the model that the data is simulated from. There are three options if data is to be simulated with random effects at the study level. If a study level random intercept only is to be included, then set rand_stud = 'int'. Else if a study level random treatment assignment term only is to be included then set rand_stud = 'treat'. Finally if both a study level random intercept and a study level random treatment effect is to be included, then set rand_stud = 'inttreat'.

gamma_ind

parameter specifying the level of association between the longitudinal and survival outcomes attributable to the individual deviation from the population longitudinal trajectory. If different association parameters are required for each study then a list of length equal to the number of studies should be supplied to gamma_ind. If sepassoc = TRUE then gamma_ind should be either a vector of values of length equal to the number of individual level random effects, or a list of vectors each of length equal to the number of individual level random effects. However if sepassoc = FALSE then gamma_ind should be supplied as a single value, or a list of single values.

gamma_stud

parameter specifying the level of association between the longitudinal and survival outcomes attributable to the study level deviation from the overall population longitudinal trajectory. If different association parameters are required for each study then a list of length equal to the number of studies should be supplied to gamma_stud. If sepassoc = TRUE then gamma_stud should be either a vector of values of length equal to the number of study level random effects, or a list of vectors each of length equal to the number of study level random effects. However if sepassoc = FALSE then gamma_stud should be supplied as a single value, or a list of single values. This parameter should only be present if rand_stud is specified in the function call.

sigb_ind

the covariance matrix for the individual level random effects. This should have number of rows and columns equal to the number of individual level random effects.

sigb_stud

the covariance matrix for the study level random effects. This should have number of rows and columns equal to the number of study level random effects. This should only be specified if rand_stud is specified in the function call.

vare

the variance of the measurement error term

theta0

parameter defining the distribution of the survival times. A separate parameter can be defined per study or a common parameter across all studies. See Bender et al 2005 for advice on approximating appropriate values for theta0 and theta1 the using extreme value distribution.

theta1

parameter defining the distribution of the survival times. A separate parameter can be defined per study or a common parameter across all studies. See Bender et al 2005 for advice on approximating appropriate values for theta0 and theta1 the using extreme value distribution.

censoring

a logical indicating whether the simulated survival times should be censored or not

censlam

the lambda parameter controlling the simulated exponentially distributed censoring times. This can either be supplied as one value for all studies simulated, or a vector of length equal to the number of studies in the dataset.

truncation

a logical value to specify whether the simulated survival times should be truncated at a specified time or not.

trunctime

if truncation = TRUE then the survival times will be truncated at the specified trunctime

Details

This function allows the simulation of a single continuous longitudinal and a single survival outcome which are potentially correlated. The model simulates data under a joint model with a zero mean random effects only sharing structure. The longitudinal sub-model is adjusted by a fixed or population intercept, time (slope) term and a binary treatment assignment covariate. The survival sub-model is adjusted by only the fixed or population binary treatment assignment covariate.

Random effects can be specified at either just the individual level, or at both the individual and study level. For the options for the random effects see the above parameter definitions.

The parameters controlling the distributions for the survival times and the censoring times can be identical across the studies, or separate values can be supplied for each study. Similarly the association parameters can be identical across studies, or unique to each study.

The simulated longitudinal information is capped at each individual's survival time. If truncation= TRUE then the survival times are truncated at the specified trunctime.

For description of the methodology of simulating this data see Bender et al 2005, and Austin 2012.

Note that this function does not return data in a jointdata format. Function tojointdata can help to reformat this data into a jointdata format.

Value

This function returns a list with three named elements. The first element is named 'longdat', the second 'survdat', the third 'percentevent'. Each of these elements is a list of length equal to the number of studies specified to simulate in the function call.

The element 'longdat' is a list of the simulated longitudinal data sets. Each longitudinal dataset contains the following variables:

id

a numeric id variable

Y

the continuous longitudinal outcome

time

the numeric longitudinal time variable

study

a study membership variable

intercept

an intercept term

treat

a treatment assignment variable to one of two treatment groups

ltime

a duplicate of the longitudinal time variable

The element 'survdat' is a list of the simulated survival data sets. Each survival dataset contains the following variables:

id

a numeric id variable

survtime

the numeric survival times

cens

the censoring indicator

study

a study membership variable

treat

a treatment assignment variable to one of two treatment groups

The element 'percentevent' is a list of the percentage of events over censorings seen in the simulated survival data.

References

Bender et al (2005) Generating survival times to simulate Cox proportional hazards models. Statistics in Medicine 24:1713–1723

Austin (2012) Generating survival times to simulate Cox proportional hazards models with time-varying covariates. Statistics in Medicine 31: 3946–3958

See Also

tojointdata

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
 #simulated data without study level variation specified
 exampledat1<-simjointmeta(k = 5, n = rep(500, 5), sepassoc = FALSE,
              ntms = 5, longmeasuretimes = c(0, 1, 2, 3, 4),
              beta1 = c(1, 2, 3), beta2 = 1, rand_ind = 'intslope',
              rand_stud = NULL, gamma_ind = 1,
              sigb_ind = matrix(c(1,0.5,0.5,1.5),nrow=2), vare = 0.01,
              theta0 = -3, theta1 = 1, censoring = TRUE, censlam = exp(-3),
              truncation = FALSE, trunctime = max(longmeasuretimes))

 #simulated data with different parameters for each study for the
 #association parameters, censoring distribution parameters and survival time
 #parameters
 gamma_ind_set<-list(c(0.5, 1), c(0.4, 0.9), c(0.6, 1.1), c(0.5, 0.9),
                     c(0.4, 1.1))
 gamma_stud_set<-list(c(0.6, 1.1), c(0.5, 1), c(0.5, 0.9), c(0.4, 1.1),
                     c(0.4, 0.9))
 censlamset<-c(exp(-3), exp(-2.9), exp(-3.1), exp(-3), exp(-3.05))
 theta0set<-c(-3, -2.9, -3, -2.9, -3.1)
 theta1set<-c(1, 0.9, 1.1, 1, 0.9)

 exampledat2<-simjointmeta(k = 5, n = rep(500, 5), sepassoc = TRUE, ntms = 5,
                           longmeasuretimes = c(0, 1, 2, 3, 4),
                           beta1 = c(1, 2, 3), beta2 = 1,
                           rand_ind = 'intslope', rand_stud = 'inttreat',
                           gamma_ind = gamma_ind_set,
                           gamma_stud = gamma_stud_set,
                           sigb_ind = matrix(c(1, 0.5, 0.5, 1.5), nrow = 2),
                           sigb_stud = matrix(c(1, 0.5, 0.5, 1.5), nrow = 2),
                           vare = 0.01, theta0 = theta0set,
                           theta1 = theta1set, censoring = TRUE,
                           censlam = censlamset, truncation = FALSE,
                           trunctime = max(longmeasuretimes))

mesudell/joineRmeta documentation built on Jan. 24, 2020, 6:06 p.m.