Title: | Survival Analysis in Health Economic Evaluation |
---|---|
Description: | Contains a suite of functions for survival analysis in health economics. These can be used to run survival models under a frequentist (based on maximum likelihood) or a Bayesian approach (both based on Integrated Nested Laplace Approximation or Hamiltonian Monte Carlo). To run the Bayesian models, the user needs to install additional modules (packages), i.e. 'survHEinla' and 'survHEhmc'. These can be installed using 'remotes::install_github' from their GitHub repositories: (<https://github.com/giabaio/survHEhmc> and <https://github.com/giabaio/survHEinla/> respectively). 'survHEinla' is based on the package INLA, which is available for download at <https://inla.r-inla-download.org/R/stable/>. The user can specify a set of parametric models using a common notation and select the preferred mode of inference. The results can also be post-processed to produce probabilistic sensitivity analysis and can be used to export the output to an Excel file (e.g. for a Markov model, as often done by modellers and practitioners). <doi:10.18637/jss.v095.i14>. |
Authors: | Gianluca Baio [aut, cre], Andrea Berardi [ctb], Philip Cooney [ctb], Andrew Jones [ctb], Nathan Green [ctb] |
Maintainer: | Gianluca Baio <[email protected]> |
License: | GPL (>= 3) |
Version: | 2.0.2 |
Built: | 2024-11-04 06:24:16 UTC |
Source: | CRAN |
A dataset containing fictional data from a trial, where the main outcome is in terms of time-to-event and censoring indicator and with additional covariates.
data
data
A data frame with 367 rows and 8 variables:
The individual level identifier
The observed time at which the event happens
An indicator to describe whether the event is fully observed or censored
An indicator for the treatment arm, with 0 = control and 1 = active treatment
An indicator for the individual's sex, with 0 = male and 1 = female
A numeric variable with the individual's age
A categorical variable representing a measure of area-level social deprivation
A categorical variable representing the individual's ethnic group, as measured from a Census
Produces txt files with Kaplan Meier and individual level survival data from digitised Kaplan Meier curves obtained by DigitizeIT
digitise( surv_inp, nrisk_inp, km_output = "KMdata.txt", ipd_output = "IPDdata.txt" )
digitise( surv_inp, nrisk_inp, km_output = "KMdata.txt", ipd_output = "IPDdata.txt" )
surv_inp |
a txt file obtained for example by DigitizeIT and containing the input survival times from graph reading. This file contains 3 columns 'ID' = the row-ID 'time' = the vector of times captured by the digitisation process 'survival' = the vector of survival probabilities captured by the digitisation process |
nrisk_inp |
a txt file obtained by DigitizeIT and containing the reported number at risk. This contains the following columns: 'Interval' = the ID of the various intervals included in the analysis ( eg 1, 2, 3, ...) 'Time' = the actual time shown on the x-axis in the digitsed graph 'Lower' = the row of the extracted co-ordinates that the time corresponds to 'Upper' = the row of the extracted co-ordinates for which the time is less than the following time at which we have a number at risk 'nrisk' = the actual number at risk as specified in the original data |
km_output |
the name of the file to which the KM data will be written |
ipd_output |
the name of the file to which the individual level data data will be written |
Patricia Guyot and Gianluca Baio
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
## Not run: # Defines the txt files to be used as inputs surv.inp <- system.file("extdata", "survival.txt", package = "survHE") nrisk.inp <- system.file("extdata", "nrisk.txt", package = "survHE") # Runs 'digitise' to create the relevant output files digitise(surv.inp, nrisk.inp) ## End(Not run)
## Not run: # Defines the txt files to be used as inputs surv.inp <- system.file("extdata", "survival.txt", package = "survHE") nrisk.inp <- system.file("extdata", "nrisk.txt", package = "survHE") # Runs 'digitise' to create the relevant output files digitise(surv.inp, nrisk.inp) ## End(Not run)
Runs the survival analysis with several useful options, using either MLE (via flexsurv) or a Bayesian approach (via R-INLA or rstan)
fit.models(formula = NULL, data, distr = NULL, method = "mle", ...)
fit.models(formula = NULL, data, distr = NULL, method = "mle", ...)
formula |
a formula specifying the model to be used, in the form
|
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 |
distr |
a (vector of) string(s) containing the name(s) of the model(s) to be fitted. Available options are:
|
method |
A string specifying the inferential method ( |
... |
Additional options (for INLA or HMC). INLA specific options HMC specific options |
On object in the class survHE
containing the following elements
models |
A list containing the fitted models. These contain
the output from the original inference engine ( |
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 |
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 |
Gianluca Baio
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
make.surv
## 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)
## 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)
Takes as input an individual-level dataset including data on both
progression and death time (jointly) and manipulates it using
dplyr
functions to create a full "multi-state" dataset, in
which all the transitions are tracked. This can then be used
to fit survival models and compute all the estimates for the
whole set of transition probabilities
make_data_multi_state( data, id = "id", prog = "prog", death = "death", prog_t = "prog_t", death_t = "death_t", keep = NULL, ... )
make_data_multi_state( data, id = "id", prog = "prog", death = "death", prog_t = "prog_t", death_t = "death_t", keep = NULL, ... )
data |
dataset containing the full ILD with information on both progression and death. Can be a data.frame or a tibble |
id |
The column with the individual identifier. Can be NULL (in which case, it will be created from scratch) |
prog |
The progression indicator: takes value 1 if the individual has progressed and 0 otherwise. Defaults to the column named 'prog' in the dataset |
death |
The death indicator: takes value 1 if the individual has died and 0 otherwise. Defaults to the column named 'death' in the dataset |
prog_t |
The progression time. Defaults to the column named 'prog_t' in the dataset |
death_t |
The death time. Defaults to the column named 'death_t' in the dataset |
keep |
A vector of strings with the names of the additional variables from the original dataset to keep into the multistate dataset. If 'NULL' (default), then keeps all |
... |
additional arguments. |
A tibble containing the event history for each individual and with the following variables: id = Patients ID; from = Initial state (1=Pre-progression, 2=Progression, 3=Death); to = End state (1=Pre-progression, 2=Progression, 3=Death); trans = Transition ID: 1=Pre-progression -> Progression; 2=Pre-Progression -> Death; 3=Progression -> Death; Tstart = Entry time (either entry or progression); Tstop = Exit time (time of event or censoring time); status = Event indicator (1=yes, 0=censored), for the specific event under consideration; treat = Treatment indicator All the other original variables are appended to these, but can be removed
Something will go here
Gianluca Baio
Something will go here
Something will go here
## Not run: # Something will go here ## End(Not run)
## Not run: # Something will go here ## End(Not run)
Creates a 'newdata' list to modify the plots for specific individual profiles (with respect to the covariates)
make_newdata(data, vars, conts = NULL)
make_newdata(data, vars, conts = NULL)
data |
The original dataset that has been used as input to the call to 'fit.models' |
vars |
A vector of strings, including the names of the variables that are to be used to construct specific profiles of individual covariates |
conts |
A subset of 'vars', which include the named covariates that are continuous. These will be averaged over, while for the remaining covariates (assumed to be factors), the specific profiles will be listed. Defaults to NULL |
newdata |
The list 'newdata' to be passed as optional argument to a call to the 'plot' method |
labs |
A vector of labels (say to use in the plot, for each profile) |
Something will go here
Gianluca Baio
## Not run: data(bc) # Fits a model using the 'bc' data mle = fit.models(formula=Surv(recyrs,censrec)~group,data=bc, distr="exp",method="mle") # Now makes the default plot plot(mle) # Now creates a 'newdata' list to modify the plot for selected profiles newdata=make_newdata(data=bc,vars="group") # And can plot, say, only two of the three treatment arms plot(mle,newdata=newdata$newdata[c(1,3)],lab.profile=newdata$labs[c(1,3)]) ## End(Not run)
## Not run: data(bc) # Fits a model using the 'bc' data mle = fit.models(formula=Surv(recyrs,censrec)~group,data=bc, distr="exp",method="mle") # Now makes the default plot plot(mle) # Now creates a 'newdata' list to modify the plot for selected profiles newdata=make_newdata(data=bc,vars="group") # And can plot, say, only two of the three treatment arms plot(mle,newdata=newdata$newdata[c(1,3)],lab.profile=newdata$labs[c(1,3)]) ## End(Not run)
Piles in the simulated IPD resulting from running digitise for more than one treatment arm
make.ipd(ipd_files, ctr = 1, var.labs = c("time", "event", "arm"))
make.ipd(ipd_files, ctr = 1, var.labs = c("time", "event", "arm"))
ipd_files |
a list including the names of the IPD files created as output of digitise |
ctr |
the index of the file associated with the control arm (default, the first file). This will be coded as 0 |
var.labs |
a vector of labels for the column of the resulting data matrix. NB these should match the arguments to the formula specified for fit.models. The user can specify values. These should be 4 elements (ID, TIME, EVENT, ARM) |
Gianluca Baio
Something will go here
Something will go here
## Not run: # Defines the txt files to be used as inputs surv.inp <- system.file("extdata", "survival.txt", package = "survHE") nrisk.inp <- system.file("extdata", "nrisk.txt", package = "survHE") # Runs 'digitise' to create the relevant output files digitise(surv.inp, nrisk.inp, ipd_output = "IPD.txt") # Now uses 'make.ipd' to create the pseudo-data make.ipd("IPD.txt", ctr = 1, var.labs = c("time", "event", "arm")) ## End(Not run)
## Not run: # Defines the txt files to be used as inputs surv.inp <- system.file("extdata", "survival.txt", package = "survHE") nrisk.inp <- system.file("extdata", "nrisk.txt", package = "survHE") # Runs 'digitise' to create the relevant output files digitise(surv.inp, nrisk.inp, ipd_output = "IPD.txt") # Now uses 'make.ipd' to create the pseudo-data make.ipd("IPD.txt", ctr = 1, var.labs = c("time", "event", "arm")) ## End(Not run)
Creates the survival curves for the fitted model(s)
make.surv(fit, mod = 1, t = NULL, newdata = NULL, nsim = 1, ...)
make.surv(fit, mod = 1, t = NULL, newdata = NULL, nsim = 1, ...)
fit |
the result of the call to the |
mod |
the index of the model. Default value is 1, but the user can
choose which model fit to visualise, if the call to |
t |
the time vector to be used for the estimation of the survival curve |
newdata |
a list (of lists), specifying the values of the covariates
at which the computation is performed. For example
|
nsim |
The number of simulations from the distribution of the survival
curves. Default at |
... |
Additional options |
Gianluca Baio
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
fit.models
, psa.plot
, write.surv
## 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") p.mle <- make.surv(mle) psa.plot(p.mle) # Can also use the main 'plot' function to visualise the survival curves # and include uncertainty by using a number 'nsim' of simulations plot(mle, nsim=10) ## End(Not run)
## 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") p.mle <- make.surv(mle) psa.plot(p.mle) # Can also use the main 'plot' function to visualise the survival curves # and include uncertainty by using a number 'nsim' of simulations plot(mle, nsim=10) ## End(Not run)
Computes the transition probabilities (to be passed to a Markov model) from
the cumulative hazard curves obtained using fit.models
, using the formula
p(t)=1-exp(H(t-k)/H(t)), where k is the Markov model cycle length (or the
difference across two consecutive times) and t is a generic time
make.transition.probs(fit, labs = NULL, ...)
make.transition.probs(fit, labs = NULL, ...)
fit |
an object obtained as output of the call to |
labs |
a vector with labels to identify the 'profiles' ie the combination of covariates that have been passed onto the model formula. If 'NULL' (default), then figures it out from the 'survHE' object. |
... |
additional arguments. Includes the standard inputs to the
call to |
A tibble 'lambda' with an indicator for the treatment arm,
the times at which the probabilities have been computed and nsim
columns each with a simulation of the transition probabilities for
all the times specified by the user
Something will go here
Gianluca Baio
Something will go here
## Not run: # Something will go here ## End(Not run)
## Not run: # Something will go here ## End(Not run)
Plots the Markov Trace from an object generated using three_state_mm
markov_trace(mm, interventions = NULL, ...)
markov_trace(mm, interventions = NULL, ...)
mm |
The output of a call to |
interventions |
A vector of labels for the interventions |
... |
additional arguments. |
Plot
Something will go here
Gianluca Baio
Something will go here
make.surv, three_state_mm
## Not run: # Something will go here ## End(Not run)
## Not run: # Something will go here ## End(Not run)
Plots a summary of the model fit for all the models fitted
model.fit.plot(..., type = "aic", scale = "absolute", stacked = FALSE)
model.fit.plot(..., type = "aic", scale = "absolute", stacked = FALSE)
... |
Optional inputs. Must include at least one |
type |
should the AIC, the BIC or the DIC plotted? (values = |
scale |
If |
stacked |
Should the bars be stacked and grouped by survHE object? (default=F) |
Something will go here
A plot with the relevant model fitting statistics
Gianluca Baio
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
fit.models
## Not run: data(bc) mle = fit.models(formula=Surv(recyrs,censrec)~group,data=bc, distr=c("exp","wei","lno"),method="mle") model.fit.plot(mle) ## End(Not run)
## Not run: data(bc) mle = fit.models(formula=Surv(recyrs,censrec)~group,data=bc, distr=c("exp","wei","lno"),method="mle") model.fit.plot(mle) ## End(Not run)
These are the same data contained in NICE TA174, as
made publicly available as part of the supplementary
material for Williams et al (2017). Medical Decision
Making, 37;427-439. However, the data have been
restructured (by using the function make_data_multi_state()
)
to be used for multi-state analysis
msmdata
msmdata
A tibble with 1868 rows and 16 variables:
A numeric patient identifier
An indicator of the starting state. 1=Pre-progression; 2=Progression; 3=Death
An indicator for the arriving state
A code for the actual transition considered. 1=Pre-progression -> Progression; 2=Pre-progression -> Death; 3=Progression -> Death
The time of entry into the observation
The time of exit from observation
The observed time until even (progression or death), or censoring occurs
The event indicator; takes value 1 if the underlying event (which varies depending on which transition is being considered) happens and 0 otherwise
The treatment indicator. 1=rituximab in combination with fludarabine andcyclophosphamide (RFC); 0=fludarabine and cyclo-phosphamide alone (FC)
The original numeric patient identifier
The original indicator to describe whether the patient has experience a progression
The original indicator to describe whether the patient has experience death
The original observed time at progression, or the time at which the patient has been censored; measured in months
The original observed time at death, or the time at which the patient has been censored; measured in months
The original observed time at progression, or the time at which the patient has been censored; measured in years
The original observed time at death, or the time at which the patient has been censored; measured in years
Perform an exploratory investigation for linearity of transformed survival models.
plot_transformed_km(fit, mod = 1, add_legend = FALSE, graph = "base", ...)
plot_transformed_km(fit, mod = 1, add_legend = FALSE, graph = "base", ...)
fit |
An object of class survHE. |
mod |
Index or name of a model in fit. Defaults to 1. |
add_legend |
If |
graph |
Type of plot: base or ggplot2. |
... |
Further arguments, passed on to plot. |
For the Weibull, twice taking logs of the survivor function
A plot of against
would give an approximately
straight line if the Weibull assumption is reasonable.
The plot could also be used to give a rough estimate of the parameters.
Similarly, for the log-logistic distribution
For the log-normal distribution
We can also check the assumption made with using the Cox regression model of proportional hazards by inspecting the log-cumulative hazard plot.
The transformed curves for different values of the explanatory variables will be parallel if PH holds.
Diagnostic plot
William Browne, Nathan Green
Collett (2015) Modelling Survival Data in Medical Research, CRC Press
data(bc) form <- formula("Surv(recyrs, censrec) ~ group") # exponential distribution fit_exp <- fit.models(form, data = bc, distr = "exp", method = "mle") plot_transformed_km(fit_exp) plot_transformed_km(fit_exp, graph = "ggplot2") # weibull distribution fit_wei <- fit.models(form, data = bc, distr = "weibull", method = "mle") plot_transformed_km(fit_wei) plot_transformed_km(fit_wei, graph = "ggplot2") # loglogistic distribution fit_llog <- fit.models(form, data = bc, distr = "loglogistic", method = "mle") plot_transformed_km(fit_llog) plot_transformed_km(fit_llog, graph = "ggplot2") # lognormal distribution fit_lnorm <- fit.models(form, data = bc, distr = "lognormal", method = "mle") plot_transformed_km(fit_lnorm) plot_transformed_km(fit_lnorm, graph = "ggplot2") ## for only one group form <- formula("Surv(recyrs, censrec) ~ 1") fit_exp <- fit.models(form, data = bc, distr = "exp", method = "mle") plot_transformed_km(fit_exp) plot_transformed_km(fit_exp, graph = "ggplot2")
data(bc) form <- formula("Surv(recyrs, censrec) ~ group") # exponential distribution fit_exp <- fit.models(form, data = bc, distr = "exp", method = "mle") plot_transformed_km(fit_exp) plot_transformed_km(fit_exp, graph = "ggplot2") # weibull distribution fit_wei <- fit.models(form, data = bc, distr = "weibull", method = "mle") plot_transformed_km(fit_wei) plot_transformed_km(fit_wei, graph = "ggplot2") # loglogistic distribution fit_llog <- fit.models(form, data = bc, distr = "loglogistic", method = "mle") plot_transformed_km(fit_llog) plot_transformed_km(fit_llog, graph = "ggplot2") # lognormal distribution fit_lnorm <- fit.models(form, data = bc, distr = "lognormal", method = "mle") plot_transformed_km(fit_lnorm) plot_transformed_km(fit_lnorm, graph = "ggplot2") ## for only one group form <- formula("Surv(recyrs, censrec) ~ 1") fit_exp <- fit.models(form, data = bc, distr = "exp", method = "mle") plot_transformed_km(fit_exp) plot_transformed_km(fit_exp, graph = "ggplot2")
fit.models
Plots the results of model fit.
## S3 method for class 'survHE' plot(...)
## S3 method for class 'survHE' plot(...)
... |
Must include at least one result object saved as
the call to the
|
Gianluca Baio
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
## Not run: data(bc) 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") plot(MLE=mle,INLA=inla) ## End(Not run)
## Not run: data(bc) 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") plot(MLE=mle,INLA=inla) ## End(Not run)
fit.models
Prints the summary table for the model(s) fitted, with the estimate of the parameters
## S3 method for class 'survHE' print(x, mod = 1, ...)
## S3 method for class 'survHE' print(x, mod = 1, ...)
x |
the |
mod |
is the index of the model. Default value is 1, but the user can choose which model fit to visualise, if the call to fit.models has a vector argument for distr (so many models are fitted & stored in the same object) |
... |
additional options, including: |
Gianluca Baio
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
## Not run: data(bc) mle = fit.models(formula=Surv(recyrs,censrec)~group,data=bc, distr="exp",method="mle") print(mle) ## End(Not run)
## Not run: data(bc) mle = fit.models(formula=Surv(recyrs,censrec)~group,data=bc, distr="exp",method="mle") print(mle) ## End(Not run)
Plots the survival curves for all the PSA simulations. The function is
actually deprecated - similar graphs can be obtained directly using
the plot
method (with options), which allows a finer depiction
of the results.
psa.plot(psa, ...)
psa.plot(psa, ...)
psa |
the result of the call to the function |
... |
Optional graphical parameters, such as:
|
Gianluca Baio
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
## Not run: 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") p.mle = make.surv(mle,nsim=100) psa.plot(p.mle) ## End(Not run)
## Not run: 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") p.mle = make.surv(mle,nsim=100) psa.plot(p.mle) ## End(Not run)
Calculates the mean survival time as the area under the survival curve
## S3 method for class 'survHE' summary(object, mod = 1, t = NULL, nsim = 1000, ...)
## S3 method for class 'survHE' summary(object, mod = 1, t = NULL, nsim = 1000, ...)
object |
a |
mod |
the model to be analysed (default = 1) |
t |
the vector of times to be used in the computation. Default = NULL, which means the observed times will be used. NB: the vector of times should be: i) long enough so that S(t) goes to 0; and ii) dense enough so that the approximation to the AUC is sufficiently precise |
nsim |
the number of simulations from the survival curve distributions to be used (to compute interval estimates) |
... |
Additional options |
A list comprising of the following elements
mean.surv |
A matrix with the simulated values for the mean survival times |
tab |
A summary table |
Gianluca Baio
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
fit.models
, make.surv
## Not run: data(bc) mle = fit.models(formula=Surv(recyrs,censrec)~group,data=bc, distr="exp",method="mle") summary(mle,nsim=100) ## End(Not run)
## Not run: data(bc) mle = fit.models(formula=Surv(recyrs,censrec)~group,data=bc, distr="exp",method="mle") summary(mle,nsim=100) ## End(Not run)
A dataset containing the data used for NICE TA174, as made publicly available as part of the supplementary material for Williams et al (2017). Medical Decision Making, 37;427-439.
ta174
ta174
A tibble with 810 rows and 8 variables:
A numeric patient identifier
The treatment indicator. 1=rituximab in combination with fludarabine andcyclophosphamide (RFC); 0=fludarabine and cyclo-phosphamide alone (FC)
An indicator to describe whether the patient has experience a progression
An indicator to describe whether the patient has experience death
The observed time at progression, or the time at which the patient has been censored; measured in months
The observed time at death, or the time at which the patient has been censored; measured in months
The observed time at progression, or the time at which the patient has been censored; measured in years
The observed time at death, or the time at which the patient has been censored; measured in years
General purpose function to run a standard three-state Markov model (typically used in cancer modelling). The states are typically 'Pre-progression', 'Progressed' and 'Death'. No backward transition from 'Progressed' to 'Pre-progression' is allowed and 'Death' is obviously an absorbing state. All other transitions are possible. The crucial assumption is that individual-level data are available recording an indicator and the time of progression and death for each individual. The function returns the full transition matrix
three_state_mm( m_12, m_13, m_23, nsim = 1, start = c(1000, 0, 0), basecase = FALSE, ... )
three_state_mm( m_12, m_13, m_23, nsim = 1, start = c(1000, 0, 0), basecase = FALSE, ... )
m_12 |
A 'survHE' object (output to a call to |
m_13 |
A 'survHE' object (output to a call to |
m_23 |
A 'survHE' object (output to a call to |
nsim |
The number of simulations for the model parameters that are
used to compute the survival curves. Defaults to |
start |
A vector of initial state occupancy. By default assumes 1000 individuals, all initially allocated to 'Pre-progression' |
basecase |
Should the base case be computed as well, based on the point estimate of the underlying model parameters? (Default=FALSE) |
... |
additional arguments. |
A list including the state occupancy simulations in an object 'm'.
This is a tibble with the number of individuals in each of the 3 states
at each of the times specified by the user. If nsim
>1, then the tibble
also contains a simulation index to keep track of that. The list also
includes the computation time to obtain the state occupancy tibble (in the
object 'running_time'). If basecase==TRUE
, then the function also
computes the "base case scenario" (based on 1 simulation from of the
underlying survival curves, i.e. the point estimate of the model parameters)
and stores it in the object 'base_case'
Something will go here
Gianluca Baio
Something will go here
make.transition.probs make_data_multi_state
## Not run: # Something will go here ## End(Not run)
## Not run: # Something will go here ## End(Not run)
Writes the survival summary to an excel file (helpful to then call the values in the Markov model)
write.surv(object, file, sheet = NULL, what = "surv")
write.surv(object, file, sheet = NULL, what = "surv")
object |
a summary.flexsurvreg object containing the survival curves (with times, estimates and interval limits) |
file |
a string with the full path to the file name to be saved |
sheet |
a string with the name of the sheet to be created |
what |
a string to describe what to be exported. Can either be 'surv' (default), which outputs the simulation(s) for the survival curves or 'sim', which outputs the simulation(s) for the underlying model parameters. If there are several 'profiles', they get written in separate spreadsheets and a clear indication is given as the name of the spreadsheet |
Something will go here
A spreadsheet file with the simulation(s) of the relevant quantity
Gianluca Baio
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
make.surv
## 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") p.mle = make.surv(mle) write.surv(p.mle,file="test.xlsx") ## End(Not run)
## 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") p.mle = make.surv(mle) write.surv(p.mle,file="test.xlsx") ## End(Not run)