# survHE: Survival analysis in health economic evaluation

## Survival analysis in health economic evaluation

Contains a suite of functions to systematise the workflow involving survival analysis in health economic evaluation. survHE can fit a large range of survival models using both a frequentist approach (by calling the R package flexsurv) and a Bayesian perspective. For a selected range of models, both Integrated Nested Laplace Integration (via the R package INLA) and Hamiltonian Monte Carlo (via the R package rstan) are possible. HMC models are pre-compiled so that they can run in a very efficient and fast way. In addition to model fitting, survHE provides a set of specialised functions, for example to perform Probabilistic Sensitivity Analysis, export the results of the modelling to a spreadsheet, plotting survival curves and uncertainty around the mean estimates.

survHE can take care of the following modelling aspects:

• Reconstruct individual level dataset from digitised data (e.g. from Kaplan-Meier curves)
• Analyse datasets using a hybrid of R formula and specialised commands, i.e. fit.models, which allow the user to select the inferential engine required (mle, inla or hmc), for a range of parametric models (as suggested e.g. by NICE guidelines)
• Perform Probabilistic Sensitivity Analysis directly on the computed parametric survival curves
• Export the output of the statistical model to e.g. a spreadsheet, to complete the economic evaluation (e.g. using Markov models) — of course this step is not necessary and the whole analysis can be embedded in a much bigger (Bayesian) model and performed directly in R!
# Loads the package
library(survHE)
# Loads some data (Breast Cancer from the package 'flexsurv')
data(bc)
# Fits a model with treatment arm ('group') as the only covariate and
# accounting for censoring ('censrec') using MLE, INLA or HMC
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")
# Now prints & plots the output
print(mle); print(inla); print(hmc)
plot(mle,inla,hmc,labs=c("MLE","INLA", "HMC"))


Model fit for the Exponential model, obtained using Flexsurvreg
(Maximum Likelihood Estimate). Running time: 0.014 seconds

mean         se      L95%      U95%
rate        0.0603838 0.00845542 0.0458911 0.0794534
groupMedium 0.8180219 0.17122084 0.4824352 1.1536086
groupPoor   1.5375232 0.16280169 1.2184378 1.8566087

Model fitting summaries
Akaike Information Criterion (AIC)....: 1668.212
Bayesian Information Criterion (BIC)..: 1681.805

Model fit for the Exponential model, obtained using INLA (Bayesian inference via
Integrated Nested Laplace Approximation). Running time: 0.77906 seconds

mean        se      L95%      U95%
rate        0.063607 0.0100161 0.0469064 0.0835491
groupMedium 0.778186 0.1803857 0.4114451 1.0541718
groupPoor   1.499270 0.1809584 1.1823481 1.8189660

Model fitting summaries
Akaike Information Criterion (AIC)....: 1668.198
Bayesian Information Criterion (BIC)..: 1681.765
Deviance Information Criterion (DIC)..: 1668.198

Model fit for the Exponential model, obtained using Stan (Bayesian inference via
Hamiltonian Monte Carlo). Running time: 3.0472 seconds

mean         se      L95%      U95%
rate        0.060679 0.00834334 0.0457192 0.0786731
groupMedium 0.815634 0.17151089 0.4914473 1.1532508
groupPoor   1.534941 0.16007586 1.2225653 1.8461065

Model fitting summaries
Akaike Information Criterion (AIC)....: 1670.218
Bayesian Information Criterion (BIC)..: 1688.341
Deviance Information Criterion (DIC)..: 1668.096

A full documentation is available here.

## Installation

There are two ways of installing survHE. A “stable” version is packaged and binary files are available for Windows and as source. To install the stable version on a Windows machine, run the following commands

install.packages("survHE",
repos=c("http://www.statistica.it/gianluca/R",
"https://cran.rstudio.org",
"https://www.math.ntnu.no/inla/R/stable"),
dependencies=TRUE
)

Note that you need to specify a vector of repositories - the first one hosts survHE, while the second one should be an official CRAN mirror. You can select whichever one you like, but a CRAN mirror must be provided, so that install.packages() can also install the “dependencies” (e.g. other packages that are required for survHE to work). The third one is used to install the package INLA, which is used to do one version of the Bayesian analysis. This process can be quite lengthy, if you miss many of the relevant packages.

To install from source (e.g. on a Linux machine), run

install.packages("survHE",
repos=c("http://www.statistica.it/gianluca/R",
"https://cran.rstudio.org",
type="source",
dependencies=TRUE
)

The second way involves using the “development” version of survHE - this will usually be updated more frequently and may be continuously tested. On Windows machines, you need to install a few dependencies, including Rtools first, e.g. by running

pkgs <- c("flexsurv","Rcpp","rms","xlsx","rstan","INLA","Rtools","devtools")
install.packages(pkgs,repos=repos,dependencies = "Depends")

before installing the package using devtools:

devtools::install_github("giabaio/survHE")

Under Linux or MacOS, it is sufficient to install the package via devtools:

install.packages("devtools")
devtools:install_github("giabaio/survHE")

### Installation issues

Installation of the development version via devtools:install_github() can fail in a MS Windows environment with the following error message:

Error in .shlib_internal(args) : C++14 standard requested but CXX14 is not defined

This is due to known issues (see for example here) with new(er) versions of rstan (which survHE uses for full Bayesian modelling). rstan uses by default version 14 of the C++ compiler, so R needs to know and act accordingly. This can be solved by running the following code

dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR))
dir.create(dotR)
M <- file.path(dotR, "Makevars.win")
if (!file.exists(M))
file.create(M)
cat("\nCXX14FLAGS=-O3 -Wno-unused-variable -Wno-unused-function",
"CXX14 = $(BINPREF)g++ -m$(WIN) -std=c++1y",
"CXX11FLAGS=-O3 -Wno-unused-variable -Wno-unused-function",
file = M, sep = "\n", append = TRUE)
Last updated: Thursday 19 December 2019