Internal function to simulate joint data with random effect at the both
individual level and the study level. Used inside
simjointmeta.
simdat2randlevels(
k,
n,
rand_ind,
rand_stud,
sepassoc,
ntms,
longmeasuretimes,
beta1,
beta2,
gamma,
sigb_ind,
sigb_stud,
vare,
theta0,
theta1,
censoring,
censlam,
truncation,
trunctime,
q,
r
)the number of studies to be simulated
a vector of length equal to k denoting the number of individuals to simulate per study
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.
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'.
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
the maximum possible number of longitudinal measurements - should
equal the length of the supplied 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.
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
the coefficient for the binary treatment assignment covariate
are the association parameters. If different association
parameters are supplied for each study in the dataset, this is a list of
vectors each of length equal to the total number of random effects. If the
same association parameters are supplied for each study in the dataset then
this is a vector of length equal to the number of random effects. If
separate association parameters are defined for different random effects
(i.e. if sepassoc = TRUE) then the elements in each of these vectors
are not necessarily identical. If sepassoc = FALSE then the
association parameters within each vector are identical. In each vector of
association parameters the first q values are the association
parameters for the individual level random effects, and the remaining
values are the association parameters for the study level random effects.
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.
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.
the variance of the measurement error term
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.
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.
a logical indicating whether the simulated survival times should be censored or not
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.
a logical value to specify whether the simulated survival times should be truncated at a specified time or not.
if truncation = TRUE then the survival times will be
truncated at the specified trunctime
the number of individual level random effects
the number of study level random effects
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:
ida numeric id variable
Ythe continuous longitudinal outcome
timethe numeric longitudinal time variable
studya study membership variable
interceptan intercept term
treata treatment assignment variable to one of two treatment groups
ltimea 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:
ida numeric id variable
survtimethe numeric survival times
censthe censoring indicator
studya study membership variable
treata 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.