fit.models: Fit parametric survival analysis for health economic...

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

View source: R/survHE.R

Description

Runs the survival analysis with several useful options, using either MLE (via flexsurv) or a Bayesian approach (via R-INLA or rstan)

Usage

1
fit.models(formula=NULL,data,distr,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.

Note

Something will go here

Author(s)

Gianluca Baio

References

Something will go here

See Also

Something will go here

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
# 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"))

giabaio/survHE documentation built on Dec. 2, 2017, 10:10 a.m.