fit.models {survHE} | R Documentation |
Fit parametric survival analysis for health economic evaluations
Description
Runs the survival analysis with several useful options, using either MLE
(via flexsurv) or a Bayesian approach (via R-INLA or rstan)
Usage
fit.models(formula = NULL, data, distr = NULL, method = "mle", ...)
Arguments
formula |
a formula specifying the model to be used, in the form
Surv(time,event)~treatment[+covariates] for flexsurv, or
inla.surv(time,event)~treatment[+covariates] for INLA
|
data |
A data frame containing the data to be used for the analysis.
This must contain data for the 'event' variable. In case there is no
censoring, then event is a column of 1s.
|
distr |
a (vector of) string(s) containing the name(s) of the model(s)
to be fitted. Available options are:
flexsurv :
"exponential","gamma","genf","gengamma","gompertz","weibull",
"weibullPH","loglogistic","lognormal" INLA :
"exponential","weibull","lognormal","loglogistic" hmc :
"exponential","gamma","genf","gengamma","gompertz","weibull","weibullPH",
"loglogistic","lognormal"
|
method |
A string specifying the inferential method ('mle' ,
'inla' or 'hmc' ). If method is set to 'hmc' ,
then survHE will write suitable model code in the Stan language
(according to the specified distribution), prepare data and initial values
and then run the model.
|
... |
Additional options (for INLA or HMC).
INLA specific options dz = defines the step length for the grid
search over the hyperparameters space (default = 0.1) diff.logdens =
defines the difference in the log-density for the hyperparameters to stop
integration (default = 5) control.fixed = defines the default for the
priors, unless specified by the user. Default values are prior mean = 0 for
all fixed effects prior var = 1000 for all fixed effects prior mean = 0
for the intercept prior prec -> 0 for the intercept control.family =
a list of options. If distr is a vector, then can be provided as a named
list of options, for example something like this:
control.family=list(weibull=list(param=c(.1,.1)),lognormal=list(initial=2))
the names of the elements of the list need to be the same as those given in
the vector distr
HMC specific options chains = number of chains to run in the HMC
(default = 2) iter = total number of iterations (default = 2000)
warmup = number of warmup iterations (default = iter/2) thin =
number of thinning (default = 1) control = a list specifying
Stan-related options, eg control=list(adapt_delta=0.85) (default =
NULL) seed = the random seed (to make things replicable) pars
= a vector of parameters (string, default = NA) include = a logical
indicator (if FALSE, then the pars are not saved; default = TRUE)
priors = a list (of lists) specifying the values for the parameters
of the prior distributions in the models save.stan = a logical
indicator (default = FALSE). If TRUE, then saves the data list for Stan and
the model file(s)
|
Details
On object in the class survHE
containing the following elements
Value
models |
A list containing the fitted models. These contain
the output from the original inference engine (flexsurv , INLA
or rstan ). Can be processed using the methods specific to the
original packages, or via survHE -specific methods (such as
plot , print ) or other specialised functions (eg to extrapolate
the survival curves, etc).
|
model.fitting |
A list containing the
output of the model-fit statistics (AIC, BIC, DIC). The AIC and BIC are
estimated for all methods, while the DIC is only estimated when using
Bayesian inference.
|
method |
A string indicating the method used to
fit the model, ie 'mle' , 'inla' or 'hmc' .
|
misc |
A list containing the time needed to run the model(s) (in
seconds), the formula used, the results of the Kaplan-Meier analysis (which
is automatically performed using npsurv ) and the original data frame.
|
Author(s)
Gianluca Baio
References
G Baio (2019). survHE: Survival analysis for health economic evaluation
and cost-effectiveness modelling. Journal of Statistical Software (2020). vol 95,
14, 1-47. doi:10.18637/jss.v095.i14
See Also
make.surv
Examples
## Not run:
# Loads an example dataset from 'flexsurv'
data(bc)
# Fits the same model using the 3 inference methods
mle = fit.models(formula=Surv(recyrs,censrec)~group,data=bc,
distr="exp",method="mle")
inla = fit.models(formula=Surv(recyrs,censrec)~group,data=bc,
distr="exp",method="inla")
hmc = fit.models(formula=Surv(recyrs,censrec)~group,data=bc,
distr="exp",method="hmc")
# Prints the results in comparable fashion using the survHE method
print(mle)
print(inla)
print(hmc)
# Or visualises the results using the original packages methods
print(mle,original=TRUE)
print(inla,original=TRUE)
print(hmc,original=TRUE)
# Plots the survival curves and estimates
plot(mle)
plot(mle,inla,hmc,labs=c("MLE","INLA","HMC"),colors=c("black","red","blue"))
## End(Not run)
[Package
survHE version 2.0.2
Index]