flexsurvmix  R Documentation 
In a mixture model for competing events, an individual can experience one of a set of different events. We specify a model for the probability that they will experience each event before the others, and a model for the time to the event conditionally on that event occurring first.
flexsurvmix( formula, data, event, dists, pformula = NULL, anc = NULL, partial_events = NULL, initp = NULL, inits = NULL, fixedpars = NULL, dfns = NULL, method = "direct", em.control = NULL, optim.control = NULL, aux = NULL, sr.control = survreg.control(), integ.opts, hess.control = NULL, ... )
formula 
Survival model formula. The left hand side is a Alternatively, A list of formulae may also be used to indicate that for particular individuals, different events may be observed in different ways, with different censoring mechanisms. Each list component specifies the data and censoring scheme for that mixture component. For example, suppose we are studying people admitted to hospital,and the competing states are death in hospital and discharge from hospital. At time t we know that a particular individual is still alive, but we do not know whether they are still in hospital, or have been discharged. In this case, if the individual were to die in hospital, their death time would be right censored at t. If the individual will be (or has been) discharged before death, their discharge time is completely unknown, thus intervalcensored on (0,Inf). Therefore, we need to store different event time and status variables in the data for different alternative events. This is specified here as
where for this individual, The "dot" notation commonly used to indicate "all remaining variables" in a
formula is not supported in 
data 
Data frame containing variables mentioned in 
event 
Variable in the data that specifies which of the alternative
events is observed for which individual. If the individual's followup is
rightcensored, or if the event is otherwise unknown, this variable must
have the value Ideally this should be a factor, since the mixture components can then be
easily identified in the results with a name instead of a number. If this
is not already a factor, it is coerced to one. Then the levels of the
factor define the required order for the components of the list arguments

dists 
Vector specifying the parametric distribution to use for each
component. The same distributions are supported as in

pformula 
Formula describing covariates to include on the component membership proabilities by multinomial logistic regression. The first component is treated as the baseline. The "dot" notation commonly used to indicate "all remaining variables" in a formula is not supported. 
anc 
List of componentspecific lists, of length equal to the number of components. Each componentspecific list is a list of formulae representing covariate effects on parameters of the distribution. If there are covariates for one component but not others, then a list
containing one null formula on the location parameter should be supplied
for the component with no covariates, e.g Covariates on the location parameter may also be supplied here instead of
in 
partial_events 
List specifying the factor levels of For example, suppose there are three alternative events called

initp 
Initial values for component membership probabilities. By default, these are assumed to be equal for each component. 
inits 
List of componentspecific vectors. Each componentspecific
vector contains the initial values for the parameters of the
componentspecific model, as would be supplied as the 
fixedpars 
Indexes of parameters to fix at their initial values and
not optimise. Arranged in the order: baseline mixing probabilities,
covariates on mixing probabilities, timetoevent parameters by mixing
component. Within mixing components, timetoevent parameters are ordered
in the same way as in If Not currently supported when using the EM algorithm. 
dfns 
List of lists of userdefined distribution functions, one for
each mixture component. Each list component is specified as the

method 
Method for maximising the likelihood. Either 
em.control 
List of settings to control EM algorithm fitting. The only options currently available are
For example, 
optim.control 
List of options to pass as the 
aux 
A named list of other arguments to pass to custom distribution
functions. This is used, for example, by 
sr.control 
For the models which use 
integ.opts 
List of named arguments to pass to

hess.control 
List of options to control inversion of the Hessian to
obtain a covariance matrix. Available options are The Hessian is positive definite, thus invertible, at the maximum
likelihood. If the Hessian computed after optimisation convergence can't
be inverted, this is either because the converged result is not the
maximum likelihood (e.g. it could be a "saddle point"), or because the
numerical methods used to obtain the Hessian were inaccurate. If you
suspect that the Hessian was computed wrongly enough that it is not
invertible, but not wrongly enough that the nearest valid inverse would be
an inaccurate estimate of the covariance matrix, then these tolerance
values can be modified (reducing 
... 
Optional arguments to the generalpurpose optimisation routine

This differs from the more usual "competing risks" models, where we specify "causespecific hazards" describing the time to each competing event. This time will not be observed for an individual if one of the competing events happens first. The event that happens first is defined by the minimum of the times to the alternative events.
The flexsurvmix
function fits a mixture model to data consisting of a
single time to an event for each individual, and an indicator for what type
of event occurs for that individual. The time to event may be observed or
censored, just as in flexsurvreg
, and the type of event may be
known or unknown. In a typical application, where we follow up a set of
individuals until they experience an event or a maximum followup time is
reached, the event type is known if the time is observed, and the event type
is unknown when followup ends and the time is rightcensored.
The model is fitted by maximum likelihood, either directly or by using an
expectationmaximisation (EM) algorithm, by wrapping
flexsurvreg
to compute the likelihood or to implement the E
and M steps.
Some worked examples are given in the package vignette about multistate
modelling, which can be viewed by running vignette("multistate", package="flexsurv")
.
List of objects containing information about the fitted model. The
important one is res
, a data frame containing the parameter
estimates and associated information.
Jackson, C. H. and Tom, B. D. M. and Kirwan, P. D. and Mandal, S. and Seaman, S. R. and Kunzmann, K. and Presanis, A. M. and De Angelis, D. (2022) A comparison of two frameworks for multistate modelling, applied to outcomes after hospital admissions with COVID19. Statistical Methods in Medical Research 31(9) 16561674.
Larson, M. G., & Dinse, G. E. (1985). A mixture model for the regression analysis of competing risks data. Journal of the Royal Statistical Society: Series C (Applied Statistics), 34(3), 201211.
Lau, B., Cole, S. R., & Gange, S. J. (2009). Competing risk regression models for epidemiologic data. American Journal of Epidemiology, 170(2), 244256.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.