Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

major rewrite of bcea() and ceac.plot() #21

Merged
merged 58 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e4acb55
comment with ideas to refactor and test bcea()
n8thangreen May 17, 2020
da2d3c4
start abstracting out bcea() into sub-functions
n8thangreen May 17, 2020
06e9c22
some more TODO commments
n8thangreen May 18, 2020
c21865c
some error tests
n8thangreen May 19, 2020
cc180eb
# now passes all error tests
n8thangreen May 22, 2020
c766e61
more basic tests
n8thangreen Jun 3, 2020
6561c8b
compute incremental function complete and tested
n8thangreen Jun 4, 2020
c54370b
delete old code in bcea()
n8thangreen Jun 4, 2020
164b653
compute_CEAC()
n8thangreen Jun 4, 2020
d0d9f6e
outlines all the bcea subfunctions. need to finish evpi ones and writ…
n8thangreen Jun 5, 2020
5a38cb7
finished writing functions and seems to work ok.
n8thangreen Jun 5, 2020
797d5ae
a bit of commenting
n8thangreen Jun 5, 2020
0578888
created constructor and helper for bcea()
n8thangreen Jun 8, 2020
19ad15b
fixed all tests
n8thangreen Jun 8, 2020
af22b5a
dont export helper functions
n8thangreen Jun 8, 2020
2a4fdea
Kmax exist seems superfluous so deleted
n8thangreen Jun 8, 2020
c243d9f
fix step value
n8thangreen Jun 8, 2020
c624842
tidy stop()s
n8thangreen Jun 8, 2020
68d273f
starting to edit graphing functions and their documentation. Basic re…
n8thangreen Jun 25, 2020
d6eb17f
some more tidying and extracting out plotting functions.
n8thangreen Jun 25, 2020
8e03df1
ceac.plot refactoring. doesnt run yet
n8thangreen Jun 26, 2020
0fb6d28
using lists and modifylist() to simplify ceac.plot
n8thangreen Jun 29, 2020
ea45583
ggplot cec.plot version works for one comparitor. Finishing for > 1.
n8thangreen Jun 30, 2020
9709c1b
sort out elipsis to ceac.plot ggplot eg line colour, title
n8thangreen Jun 30, 2020
655a360
finish ceac.plot for ggplot dispatch. need to add tests.
n8thangreen Jul 1, 2020
a8e01ed
createInputs() simple refactoring
n8thangreen Jul 1, 2020
2ab2eea
write own theme ceac function
n8thangreen Jul 2, 2020
9f56b97
Merge pull request #1 from n8thangreen/plots
n8thangreen Jul 2, 2020
8025bf1
include a ggplot test using vdiffr
n8thangreen Jul 3, 2020
e67e4d4
finished ceac.plot_base(). need to add tests. its still a bit messy b…
n8thangreen Jul 3, 2020
ecb366f
refactored sim.table()
n8thangreen Jul 4, 2020
88bc642
finished sim.table() refactor
n8thangreen Jul 6, 2020
d451ca7
createInputs() as S3 object
n8thangreen Jul 6, 2020
6d70b94
first attempt to tidy and organise evppi functions. Lots of work to d…
n8thangreen Jul 6, 2020
f49a1e8
added a NEWS doc. Needs to be filled in for latest release.
n8thangreen Jul 8, 2020
f32b549
frame ceplane.plot to refactor as ceac.plot
n8thangreen Jul 16, 2020
0e8efaf
dispatch ceac.plot on whether multiple comparisons. Pulled ceac.multi…
n8thangreen Jul 16, 2020
e33b2fd
a lot of refactoring (and breaking the code!)
n8thangreen Jul 17, 2020
7b37f2c
finished resstructuring and _mostly_ morking ceac plots.
n8thangreen Jul 17, 2020
f29cc60
file name change
n8thangreen Jul 17, 2020
5ecfb7e
typo
n8thangreen Jul 17, 2020
7f5fdfc
finished base ceac rewrite and written vignette. need to finish ggplo…
n8thangreen Jul 17, 2020
10ca71b
refactor diag.evppi()
n8thangreen Jul 17, 2020
41fde75
bit more diag.evppi refactoring
n8thangreen Jul 17, 2020
f97f3b2
bug fix:
n8thangreen Jul 20, 2020
d30426b
update README and add MIT licence
n8thangreen Jul 20, 2020
cd87aff
update NEWS and documentation
n8thangreen Jul 20, 2020
4a40b0b
fix: document build
n8thangreen Jul 20, 2020
4d6d249
finished dispatch ceaec_plot_ggplot with ce.multi
n8thangreen Jul 20, 2020
898ccf4
delete deprecated ceac_multi_ggplot
n8thangreen Jul 20, 2020
42e573a
move options(scipen=...) into .onLoad()
n8thangreen Jul 21, 2020
bbf7c72
test newline
n8thangreen Jul 21, 2020
d0bcd85
Merge pull request #8 from n8thangreen/plots
n8thangreen Jul 21, 2020
cf7befd
Change license to GPL
n8thangreen Jul 21, 2020
25e09b6
Merge pull request #11 from n8thangreen/plots
n8thangreen Jul 21, 2020
ea53634
update data docs
n8thangreen Jul 21, 2020
44f69b1
Merge pull request #12 from n8thangreen/plots
n8thangreen Jul 21, 2020
d80308d
Merge branch 'dev' into dev
giabaio Jul 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed ..travis.yml.swp
Binary file not shown.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
^\.Rproj\.user$
^\.travis\.yml$
^appveyor\.yml$
^LICENSE\.md$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.RData
.Ruserdata
*.Rproj
inst/doc
2 changes: 1 addition & 1 deletion BCEA.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ LaTeX: pdfLaTeX
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate
PackageRoxygenize: rd,collate,vignette
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ Suggests:
Imports: MASS, dplyr, rlang
Additional_repositories: https://inla.r-inla-download.org/R/stable/
Description: Produces an economic evaluation of a Bayesian model in the form of MCMC simulations. Given suitable variables of cost and effectiveness / utility for two or more interventions, This package computes the most cost-effective alternative and produces graphical summaries and probabilistic sensitivity analysis.
License: GPL (>=2)
License: GPL-3
URL: http://www.statistica.it/gianluca/BCEA,
http://www.statistica.it/gianluca,
https://github.com/giabaio/BCEA
Depends: R (>= 2.10)
NeedsCompilation: no
RoxygenNote: 6.1.1
RoxygenNote: 7.1.0
Encoding: UTF-8
VignetteBuilder: knitr
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2020
COPYRIGHT HOLDER: G Baio
595 changes: 595 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ S3method(bcea, default)
S3method(evppi, default)
export(BCEAweb)
export(CEriskav)
export(CreateInputs)
export(createInputs)
export(bcea)
export(ceac.plot)
export(ceaf.plot)
Expand All @@ -26,7 +26,6 @@ export(evi.plot)
export(evppi)
export(ib.plot)
export(info.rank)
export(mce.plot)
export(mixedAn)
export(multi.ce)
export(plot.CEriskav)
Expand Down
120 changes: 120 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# BCEA 2.3-2

* Added a `NEWS.md` file to track changes to the package.
* Major refactoring of code base
* Testing suite written

## Feature updates

* Deprecated `mce.plot()`. Now dispatched on `ceac.plot()` for both `multi.ce()` and `bcea()` outputs.
* `new_bcea()` constructor


## Fixes

# BCEA 2.3-1.1
26 Aug 2019

# BCEA 2.3-1<sup>^</sup>

# BCEA 2.2-6<sup>^</sup>
* Fix in `evppi` to allow N to be selected in all methods
* Fix `diag.evppi`

# BCEA 2.2-5<sup>^</sup>

* Some changes to EVPPI

# BCEA v2.2.4
Nov 2016

* Fixes for new ggplot2 version (`legend.spacing()` and `plot.title` hjust argument)

# BCEA 2.2-3<sup>^</sup>
May 2016

* Major update for the EVPPI to include PFC
* Fixed issues with info.rank

# BCEA 2.2-2<sup>^</sup>
January 2016

* Minor change to `ceef.plot` to align with ggplot2 v2.0.0

# BCEA v2.2.1
October 2015

* Adds the info-rank plot

# BCEA v2.2
October 2015

* Cleaned up and aligned with R's settings
* `EVPPI` function polished up

# BCEA 2.1-1<sup>^</sup>
April/July 2015

* New function for EVPPI using SPDE-INLA
* Modifications to the EVPPI functions
* Documentation updated
* Allows xlim & ylim in the `ceplane.plot`, `contour` and `contour2` functions
* It is now possible to run bcea for a scalar wtp
* Old evppi function and method has been renamed `evppi0`, which means there's also a new `plot.evppi0` method

# BCEA 2.1-0<sup>^</sup>
October 2014

* Migrated from `if(require())` to `if(requireNamespace(,quietly=TRUE))`
* Documentation updated
* Added threshold argument to `ceef.plot` function

# BCEA v2.1.0-pre2
October 2014

* modifications to `ceef.plot`, `createInputs`, `struct.psa`

# BCEA v2.1-0-pre1
September 2014

* Documentation updated
* Smoking dataset and `ceef.plot` function included, additional modifications

# BCEA v2.0-2c
July, 2014

# BCEA v2.0-2b
February 2014

* `ceac.plot` and `eib.plot`: option comparison included for base graphics

# BCEA 2.0-2<sup>^</sup>
November 2013

# BCEA 2.0-1<sup>^</sup>
July, 2013

# BCEA 2.0<sup>^</sup>

## Feature updates

* Implements two quick and general methods to compute the EVPPI
* Function `CreateInputs()`, which takes as input an object in the class rjags or bugs
* Compute the EVPPI for one or more parameters calling the function `evppi()`
* Results can be visualised using the specific method plot for the class evppi and show the overall EVPI with the EVPPI for the selected parameter(s)

# BCEA 1.3-1

# BCEA 1.3-0<sup>^</sup>
June 2013

# BCEA 1.2
17 September 2012

# BCEA 1.1.1<sup>^</sup>

# BCEA 1.1<sup>^</sup>
14 September 2012

# BCEA 1.0<sup>^</sup>
4 January 2012
155 changes: 10 additions & 145 deletions R/BCEA-package.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@


#' BCEA: A package for Bayesian Cost-Effectiveness Analysis
#'
#' A package to post-process the results of a Bayesian health economic model
Expand All @@ -12,163 +11,29 @@
#' variables of costs and clinical benefits for two or more interventions,
#' produces a health economic evaluation. Compares one of the interventions
#' (the "reference") to the others ("comparators"). Produces many summary and
#' plots to analyse the results
#' plots to analyse the results.
#'
#' @name BCEA-package
#' @aliases BCEA-package BCEA
#' @docType package
#'
#' @author Gianluca Baio, Andrea Berardi, Anna Heath
#' #' Maintainer: Gianluca Baio <gianluca@@stats.ucl.ac.uk>
#'
#' Maintainer: Gianluca Baio <gianluca@@stats.ucl.ac.uk>
#' @references Baio, G., Dawid, A. P. (2011). Probabilistic Sensitivity
#' Analysis in Health Economics. Statistical Methods in Medical Research
#' doi:10.1177/0962280211419832.
#'
#' Baio G. (2012). Bayesian Methods in Health Economics. CRC/Chapman Hall,
#' London
#' London.
#'
#' Baio G., Berardi A., Heath A. (forthcoming). Bayesian Cost Effectiveness
#' Analysis with the R package BCEA. Springer
#' @keywords Bayesian models Health economic evaluation
NULL





#' Data set for the Bayesian model for the cost-effectiveness of smoking
#' cessation interventions
#'
#' This data set contains the results of the Bayesian analysis used to model
#' the clinical output and the costs associated with the health economic
#' evaluation of four different smoking cessation interventions.
#'
#'
#' @name Smoking
#' @aliases Smoking data life.years pi smoking smoking_output
#' @docType data
#' @format A data list including the variables needed for the smoking cessation
#' cost-effectiveness analysis. The variables are as follows: \describe{
#' \item{list("c")}{a matrix of 500 simulations from the posterior distribution
#' of the overall costs associated with the four strategies}
#' \item{list("data")}{a dataset containing the characteristics of the smokers
#' in the UK population} \item{list("e")}{a matrix of 500 simulations from the
#' posterior distribution of the clinical benefits associated with the four
#' strategies} \item{list("life.years")}{a matrix of 500 simulations from the
#' posterior distribution of the life years gained with each strategy}
#' \item{list("pi")}{a matrix of 500 simulations from the posterior
#' distribution of the event of smoking cessation with each strategy}
#' \item{list("smoking")}{a data frame containing the inputs needed for the
#' network meta-analysis model. The \code{data.frame} object contains:
#' \code{nobs}: the record ID number, \code{s}: the study ID number, \code{i}:
#' the intervention ID number, \code{r_i}: the number of patients who quit
#' smoking, \code{n_i}: the total number of patients for the row-specific arm
#' and \code{b_i}: the reference intervention for each study}
#' \item{list("smoking_output")}{a \code{rjags} object obtained by running the
#' network meta-analysis model based on the data contained in the
#' \code{smoking} object} \item{list("smoking_mat")}{a matrix obtained by
#' running the network meta-analysis model based on the data contained in the
#' \code{smoking} object} \item{list("treats")}{a vector of labels associated
#' with the four strategies} }
#' @references Baio G. (2012). Bayesian Methods in Health Economics.
#' CRC/Chapman Hall, London
#' @source Effectiveness data adapted from Hasselblad V. (1998). Meta-analysis
#' of Multitreatment Studies. Medical Decision Making 1998;18:37-43.
#'
#' Cost and population characteristics data adapted from various sources:
#' \itemize{ \item Taylor, D.H. Jr, et al. (2002). Benefits of smoking
#' cessation on longevity. American Journal of Public Health 2002;92(6) \item
#' ASH: Action on Smoking and Health (2013). ASH fact sheet on smoking
#' statistics, \cr \code{http://ash.org.uk/files/documents/ASH_106.pdf} \item
#' Flack, S., et al. (2007). Cost-effectiveness of interventions for smoking
#' cessation. York Health Economics Consortium, January 2007 \item McGhan,
#' W.F.D., and Smith, M. (1996). Pharmacoeconomic analysis of smoking-cessation
#' interventions. American Journal of Health-System Pharmacy 1996;53:45-52 }
#' @keywords datasets
#' @examples
#'
#' data(Smoking)
#'
#' \donttest{
#' m=bcea(e,c,ref=4,interventions=treats,Kmax=500)
#' }
#'
NULL





#' Data set for the Bayesian model for the cost-effectiveness of influenza
#' vaccination
#'
#' This data set contains the results of the Bayesian analysis used to model
#' the clinical output and the costs associated with an influenza vaccination.
#'
#'
#' @name Vaccine
#' @aliases Vaccine c cost.GP cost.hosp cost.otc cost.time.off cost.time.vac
#' cost.travel cost.trt1 cost.trt2 cost.vac e N N.outcomes N.resources
#' QALYs.adv QALYs.death QALYs.hosp QALYs.inf QALYs.pne treats vaccine
#' @docType data
#' @format A data list including the variables needed for the influenza
#' vaccination. The variables are as follows:
#'
#' \describe{ \item{list("c")}{a matrix of simulations from the posterior
#' distribution of the overall costs associated with the two treatments}
#' \item{list("cost.GP")}{a matrix of simulations from the posterior
#' distribution of the costs for GP visits associated with the two treatments}
#' \item{list("cost.hosp")}{a matrix of simulations from the posterior
#' distribution of the costs for hospitalisations associated with the two
#' treatments} \item{list("cost.otc")}{a matrix of simulations from the
#' posterior distribution of the costs for over-the-counter medications
#' associated with the two treatments} \item{list("cost.time.off")}{a matrix of
#' simulations from the posterior distribution of the costs for time off work
#' associated with the two treatments} \item{list("cost.time.vac")}{a matrix of
#' simulations from the posterior distribution of the costs for time needed to
#' get the vaccination associated with the two treatments}
#' \item{list("cost.travel")}{a matrix of simulations from the posterior
#' distribution of the costs for travel to get vaccination associated with the
#' two treatments} \item{list("cost.trt1")}{a matrix of simulations from the
#' posterior distribution of the overall costs for first line of treatment
#' associated with the two interventions} \item{list("cost.trt2")}{a matrix of
#' simulations from the posterior distribution of the overall costs for second
#' line of treatment associated with the two interventions}
#' \item{list("cost.vac")}{a matrix of simulations from the posterior
#' distribution of the costs for vaccination} \item{list("e")}{a matrix of
#' simulations from the posterior distribution of the clinical benefits
#' associated with the two treatments} \item{list("N")}{the number of subjects
#' in the reference population} \item{list("N.outcomes")}{the number of
#' clinical outcomes analysed} \item{list("N.resources")}{the number of
#' health-care resources under study} \item{list("QALYs.adv")}{a vector from
#' the posterior distribution of the QALYs associated with advert events}
#' \item{list("QALYs.death")}{a vector from the posterior distribution of the
#' QALYs associated with death} \item{list("QALYs.hosp")}{a vector from the
#' posterior distribution of the QALYs associated with hospitalisation}
#' \item{list("QALYs.inf")}{a vector from the posterior distribution of the
#' QALYs associated with influenza infection} \item{list("QALYs.pne")}{a vector
#' from the posterior distribution of the QALYs associated with penumonia}
#' \item{list("treats")}{a vector of labels associated with the two treatments}
#' \item{list("vaccine")}{a \code{rjags} object containing the simulations for
#' the parameters used in the original model} \item{list("vaccine_mat")}{a
#' matrix containing the simulations for the parameters used in the original
#' model} }
#' @references Baio, G., Dawid, A. P. (2011). Probabilistic Sensitivity
#' Analysis in Health Economics. Statistical Methods in Medical Research
#' doi:10.1177/0962280211419832.
#' @source Adapted from Turner D, Wailoo A, Cooper N, Sutton A, Abrams K,
#' Nicholson K. The cost-effectiveness of influenza vaccination of healthy
#' adults 50-64 years of age. Vaccine. 2006;24:1035-1043.
#' @keywords datasets
#' @examples
#'
#' data(Vaccine)
#'
#' \donttest{
#' m=bcea(e,c,ref=1,interventions=treats)
#' }
#' @docType package
#' @name BCEA-package
#'
#' @import dplyr
#' @import ggplot2
#' @import purrr
#' @import reshape2
NULL



4 changes: 2 additions & 2 deletions R/BCEAweb.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ BCEAweb <- function(e=NULL,c=NULL,parameters=NULL,...) {
if(exists("launch.browser",exArgs)) {launch.browser=exArgs$launch.browser} else {launch.browser=TRUE}

# This makes the possible inputs available to the webapp!
# First uses BCEA::CreateInputs to process the simulations for the model parameters
# First uses BCEA::createInputs to process the simulations for the model parameters
# (this means the user can pass a BUGS, JAGS, Stan, or xls object and BCEA will know what to do. Also eliminates need with further dependencies).
if(!is.null(parameters)){parameters=CreateInputs(parameters)$mat}
if(!is.null(parameters)){parameters = createInputs(parameters)$mat}
if(!is.null(e)){e=as.matrix(e)}
if(!is.null(c)){c=as.matrix(c)}

Expand Down
5 changes: 1 addition & 4 deletions R/CEriskav.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
###CEriskav###################################################################################################


#' Cost-effectiveness analysis including a parameter of risk aversion
#'
#' Extends the standard cost-effectiveness analysis to modify the utility
#' function so that risk aversion of the decision maker is explicitly accounted
#' for
#'
#' for.
#'
#' @aliases CEriskav CEriskav.default
#' @param he A \code{bcea} object containing the results of the Bayesian
Expand Down
Loading