├── .Rbuildignore
├── .github
├── .gitignore
├── ISSUE_TEMPLATE.md
└── workflows
│ ├── check-standard.yaml
│ ├── pkgdown.yaml
│ └── rhub.yaml
├── .gitignore
├── .httr-oauth
├── BCEA.Rproj
├── CITATION.cff
├── CONDUCT.md
├── CONTRIBUTING.md
├── CRAN-SUBMISSION
├── DESCRIPTION
├── LICENSE.md
├── NAMESPACE
├── NEWS.md
├── R
├── BCEA-deprecated.R
├── BCEA-package.R
├── CEriskav.R
├── CEriskav.default.R
├── CEriskav_plot_graph.R
├── CreateInputs.R
├── GrassmannOptim.R
├── add_ceplane_xxx.R
├── add_contour_quadrants.R
├── add_contours.R
├── base_methods.R
├── bcea.R
├── bcea.default.R
├── bcea_plot.R
├── bcea_setters.R
├── best_interv_given_k.R
├── bf.R
├── ce_table.R
├── ceac.plot.R
├── ceac_boot.R
├── ceac_plot_graph.R
├── ceaf.plot.R
├── ceef.plot.R
├── ceef.summary.R
├── ceef_plot_graph.R
├── ceplane.plot.R
├── ceplane_base_params.R
├── ceplane_base_params_xxx.R
├── ceplane_geom_params.R
├── ceplane_ggplot_params.R
├── ceplane_legend_manual.R
├── ceplane_plot_graph.R
├── compute_eib_cri.R
├── compute_xxx.R
├── contour.R
├── contour2.R
├── contour_ggplot_params.R
├── contour_graph.R
├── convert_pts_to_mm.R
├── core.R
├── data.R
├── diag.evppi.R
├── eib.plot.R
├── eib_legend_base.R
├── eib_params_base.R
├── eib_params_cri.R
├── eib_params_ggplot.R
├── eib_plot_graph.R
├── evi.plot.R
├── evi.plot.mixedAn.R
├── evi_plot_graph.R
├── evppi.R
├── evppi.default.R
├── evppi_plot_base.R
├── evppi_plot_ggplot.R
├── evppi_plot_helpers.R
├── filter_by.R
├── geom_cri.R
├── helper_base_params.R
├── helper_ggplot_params.R
├── ib.plot.R
├── ib_plot_base.R
├── ib_plot_ggplot.R
├── info.rank.R
├── info_rank_graph.R
├── inforank_params.R
├── kstar_vlines.R
├── lad.R
├── ldr.R
├── ldr.slices.R
├── line_labels.R
├── list_methods.R
├── make.report.R
├── make_legend_base.R
├── make_legend_ggplot.R
├── make_legend_plotly.R
├── mce.plot.R
├── misc_helpers.R
├── mixedAn.R
├── mixedAn.default.R
├── multi.ce.R
├── multiplot.R
├── new_bcea.R
├── num_lines.R
├── orthonorm.R
├── pfc.R
├── plot.CEriskav.R
├── plot.bcea.R
├── plot.evppi.R
├── plot.mixedAn.R
├── plot_eib_cri.R
├── prep_ceplane_params.R
├── prep_contour_params.R
├── prep_eib_params.R
├── prep_frontier_data.R
├── prepare_ceac_params.R
├── prepare_ceac_params_multi.R
├── quadrant_params.R
├── select_plot_type.R
├── setComparisons.R
├── sim_table.R
├── struct.psa.R
├── summary.bcea.R
├── summary.mixedAn.R
├── summary.pairwise.R
├── themes_ggplot.R
├── validate_bcea.R
├── xy_params.R
└── zzz.R
├── README.md
├── _pkgdown.yml
├── cran-comments.md
├── data
├── Smoking.RData
├── Vaccine.RData
├── datalist
├── statins_HC.RData
└── statins_base.RData
├── inst
├── CITATION
├── REFERENCES.bib
├── extdata
│ ├── smoking_output.RData
│ ├── statins_HC.Rdata
│ ├── statins_base.Rdata
│ └── vaccine_jags.RData
├── jags
│ ├── smoking-jags.Rmd
│ └── smoking_model_RE.txt
└── rmarkdown
│ └── report
│ ├── biblio.bib
│ ├── report.Rmd
│ ├── section_CEAC.Rmd
│ ├── section_CEAF.Rmd
│ ├── section_CEEF.Rmd
│ ├── section_EIB.Rmd
│ ├── section_EVPI.Rmd
│ ├── section_InfoRank.Rmd
│ └── section_ceplane.Rmd
├── man-roxygen
├── args-comparison.R
├── args-graph.R
├── args-he.R
└── args-pos.R
├── man
├── BCEA-deprecated.Rd
├── BCEA-package.Rd
├── CEriskav_assign.Rd
├── CEriskav_plot_graph.Rd
├── GrassmannOptim.Rd
├── Smoking.Rd
├── Vaccine.Rd
├── add_contour_quadrants.Rd
├── add_contours.Rd
├── bcea.Rd
├── best_interv_given_k.Rd
├── ce_table.Rd
├── ceac.plot.Rd
├── ceac_matplot.Rd
├── ceac_plot_graph.Rd
├── ceaf.plot.Rd
├── ceef.plot.Rd
├── ceef.summary.Rd
├── ceef_plot_graph.Rd
├── ceplane.plot.Rd
├── ceplane_geom_params.Rd
├── ceplane_ggplot_params.Rd
├── ceplane_plot_graph.Rd
├── comp_names_from_.Rd
├── compute_CEAC.Rd
├── compute_EIB.Rd
├── compute_EVI.Rd
├── compute_IB.Rd
├── compute_ICER.Rd
├── compute_U.Rd
├── compute_Ubar.Rd
├── compute_Ustar.Rd
├── compute_ceaf.Rd
├── compute_eib_cri.Rd
├── compute_kstar.Rd
├── compute_ol.Rd
├── compute_p_best_interv.Rd
├── compute_vi.Rd
├── contour.Rd
├── contour2.Rd
├── contour_ggplot_params.Rd
├── contour_graph.Rd
├── convert_pts_to_mm.Rd
├── createInputs.Rd
├── diag.evppi.Rd
├── eib.plot.Rd
├── eib_params_base.Rd
├── eib_params_cri.Rd
├── eib_plot_graph.Rd
├── evi.plot.Rd
├── evi.plot.mixedAn.Rd
├── evi_plot_graph.Rd
├── evppi.Rd
├── evppi_plot_graph.Rd
├── evppi_qq_plot.Rd
├── evppi_residual_plot.Rd
├── figures
│ └── logo.png
├── geom_cri.Rd
├── geom_quad_txt.Rd
├── get_fitted_.Rd
├── ib.plot.Rd
├── ib_plot_graph.Rd
├── info.rank.Rd
├── info_rank_graph.Rd
├── inforank_params.Rd
├── is.bcea.Rd
├── is.rel.Rd
├── kstar_vlines.Rd
├── line_labels.Rd
├── loo_rank.Rd
├── make.report.Rd
├── make_legend_plotly.Rd
├── mce.plot.Rd
├── mixedAn-set.Rd
├── multi.ce.Rd
├── multiplot.Rd
├── new_bcea.Rd
├── num_lines.Rd
├── openPDF.Rd
├── plot.CEriskav.Rd
├── plot.bcea.Rd
├── plot.evppi.Rd
├── plot_eib_cri.Rd
├── prep_ceplane_params.Rd
├── prep_contour_params.Rd
├── prep_eib_params.Rd
├── prep_frontier_data.Rd
├── print.bcea.Rd
├── quadrant_params.Rd
├── quiet.Rd
├── select_plot_type.Rd
├── setComparisons.Rd
├── setComparisons_assign.Rd
├── setKmax_assign.Rd
├── setReferenceGroup_assign.Rd
├── sim_table.Rd
├── statins_HC.Rd
├── statins_base.Rd
├── struct.psa.Rd
├── summary.bcea.Rd
├── summary.mixedAn.Rd
├── summary.pairwise.Rd
├── tabulate_means.Rd
├── theme_bcea.Rd
├── validate_bcea.Rd
└── validate_eib_params.Rd
├── pkgdown
├── assets
│ └── bcea_cheatsheet.pdf
├── extra.css
└── favicon
│ ├── apple-touch-icon-120x120.png
│ ├── apple-touch-icon-60x60.png
│ ├── apple-touch-icon-76x76.png
│ ├── apple-touch-icon.png
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ └── favicon.ico
├── revdep
├── README.md
├── cran.md
├── failures.md
└── problems.md
├── tests
├── figs
│ ├── ceac-plot
│ │ └── ceac-plot-ggplot.svg
│ └── deps.txt
├── testthat.R
└── testthat
│ ├── ce_mock.stan
│ ├── ce_mock.txt
│ ├── ce_smoking.RData
│ ├── ce_vaccine.RData
│ ├── create_ce_mock.R
│ ├── df_ce.RData
│ ├── test-CEriskav.R
│ ├── test-bcea.R
│ ├── test-bcea_setters.R
│ ├── test-ceac_plot_ggplot.R
│ ├── test-compute_U.R
│ ├── test-compute_kstar.R
│ ├── test-compute_ol.R
│ ├── test-compute_vi.R
│ ├── test-createInputs.R
│ ├── test-eib.plot.R
│ ├── test-eib_plot_ggplot.R
│ ├── test-evppi.R
│ ├── test-summary.R
│ └── testdata
│ ├── EVPPI_GAM_default.RData
│ ├── EVPPI_gam.RData
│ ├── EVPPI_gam_3_residuals.RData
│ ├── EVPPI_gam_residuals.RData
│ ├── EVPPI_gp.RData
│ ├── EVPPI_gp_3_residuals.RData
│ ├── EVPPI_gp_residuals.RData
│ ├── EVPPI_idx.RData
│ ├── EVPPI_inla_3_residuals.RData
│ ├── EVPPI_inla_default.RData
│ ├── EVPPI_inla_residuals.RData
│ ├── EVPPI_psa.RData
│ ├── EVPPI_sad_default.RData
│ ├── EVPPI_sad_residuals.RData
│ ├── EVPPI_smoke.RData
│ ├── EVPPI_so_default.RData
│ ├── bugsfit.RData
│ ├── ce.RData
│ ├── jagsfit.RData
│ └── stanfit.RData
└── vignettes
├── .gitignore
├── CEriskav.Rmd
├── Set_bcea_parameters.Rmd
├── Set_bcea_parameters.md
├── bcea.Rmd
├── ceac.Rmd
├── ceef.Rmd
├── ceplane.Rmd
├── contour.Rmd
├── eib.Rmd
└── paired_vs_multiple_comps.Rmd
/.Rbuildignore:
--------------------------------------------------------------------------------
1 | ^renv$
2 | ^renv\.lock$
3 | ^.*\.Rproj$
4 | ^\.Rproj\.user$
5 | ^\.travis\.yml$
6 | ^appveyor\.yml$
7 | ^LICENSE\.md$
8 | ^_pkgdown\.yml$
9 | ^docs$
10 | ^pkgdown$
11 | ^\.httr-oauth$
12 | ^CONDUCT\.md$
13 | ^man-roxygen$
14 | ^.git
15 | ^.gitignore
16 | ^cran-comments\.md$
17 | ^README_dev\.md$
18 | ^\.github$
19 | ^inst/extdata/vaccine_jags\.RData$
20 | ^inst/extdata/statins_base\.RData$
21 | ^inst/extdata/statins_HC\.RData$
22 | ^inst/extdata/smoking_output\.RData$
23 | ^paper\.bib$
24 | ^paper\.md$
25 | ^CONTRIBUTING\.md$
26 | ^revdep$
27 | ^CRAN-SUBMISSION$
28 | ^CITATION\.cff$
29 | ^CITATION.cff
30 |
--------------------------------------------------------------------------------
/.github/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Please briefly describe your problem and what output you expect. If you have a general question, please don't use this form. Instead, ask on or .
2 |
3 | Please include a minimal reproducible example (AKA a reprex). If you've never heard of a [reprex](https://reprex.tidyverse.org/) before, start by reading .
4 |
5 | ---
6 |
7 | Brief description of the problem
8 |
9 | ```r
10 | # insert reprex here
11 | ```
12 |
--------------------------------------------------------------------------------
/.github/workflows/pkgdown.yaml:
--------------------------------------------------------------------------------
1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3 | on:
4 | push:
5 | branches: [main, master, dev]
6 | pull_request:
7 | branches: [main, master, dev]
8 | release:
9 | types: [published]
10 | workflow_dispatch:
11 |
12 | name: pkgdown
13 |
14 | jobs:
15 | pkgdown:
16 | runs-on: ubuntu-latest
17 | # Only restrict concurrency for non-PR jobs
18 | concurrency:
19 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
20 | env:
21 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
22 | steps:
23 | - uses: actions/checkout@v2
24 |
25 | - uses: r-lib/actions/setup-pandoc@v2
26 |
27 | - uses: r-lib/actions/setup-r@v2
28 | with:
29 | use-public-rspm: true
30 |
31 | - uses: r-lib/actions/setup-r-dependencies@v2
32 | with:
33 | extra-packages: any::pkgdown, local::.
34 | needs: website
35 |
36 | - name: Build site
37 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
38 | shell: Rscript {0}
39 |
40 | - name: Deploy to GitHub pages 🚀
41 | if: github.event_name != 'pull_request'
42 | uses: JamesIves/github-pages-deploy-action@4.1.4
43 | with:
44 | clean: false
45 | branch: gh-pages
46 | folder: docs
47 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .Rproj.user
2 | .Rhistory
3 | .RData
4 | .Ruserdata
5 | *.html
6 | *.xml
7 | *.js
8 | *.Rproj
9 | BCEA.Rcheck/
10 | inst/doc
11 | renv/
12 | revdep/
13 | BCEA_book.pdf - Shortcut
14 | docs/*/
15 | docs/
16 | docs/**
17 |
--------------------------------------------------------------------------------
/.httr-oauth:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/.httr-oauth
--------------------------------------------------------------------------------
/BCEA.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 |
3 | RestoreWorkspace: Default
4 | SaveWorkspace: Default
5 | AlwaysSaveHistory: Default
6 |
7 | EnableCodeIndexing: Yes
8 | UseSpacesForTab: Yes
9 | NumSpacesForTab: 2
10 | Encoding: UTF-8
11 |
12 | RnwWeave: knitr
13 | LaTeX: pdfLaTeX
14 |
15 | BuildType: Package
16 | PackageUseDevtools: Yes
17 | PackageInstallArgs: --no-multiarch --with-keep.source
18 | PackageRoxygenize: rd,collate,namespace
19 |
--------------------------------------------------------------------------------
/CITATION.cff:
--------------------------------------------------------------------------------
1 | cff-version: 1.2.0
2 | message: "If you use this software, please cite it as below."
3 | authors:
4 | - family-names: "Baio"
5 | given-names: "Gianluca"
6 | orcid: "https://orcid.org/0000-0003-4314-2570"
7 | - family-names: "Berardi"
8 | given-names: "Andrea"
9 | orcid: https://orcid.org/0000-0002-2906-496X
10 | - family-names: "Heath"
11 | given-names: "Anna"
12 | orcid: https://orcid.org/0000-0002-7263-4251
13 | - family-names: "Green"
14 | given-names: "Nathan"
15 | orcid: https://orcid.org/0000-0003-2745-1736
16 | title: "BCEA: Bayesian Cost-Effectiveness Analysis"
17 | version: 2.4.6
18 | doi: 10.1007/978-3-319-55718-2
19 | date-released: 2023-11-20
20 | url: "https://gianluca.statistica.it/software/bcea/"
21 |
--------------------------------------------------------------------------------
/CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Code of Conduct
2 |
3 | As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4 |
5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6 |
7 | Examples of unacceptable behaviour by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8 |
9 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10 |
11 | Instances of abusive, harassing, or otherwise unacceptable behaviour may be reported by opening an issue or contacting one or more of the project maintainers.
12 |
13 | This Code of Conduct is adapted from the Contributor Covenant (https://contributor-covenant.org), version 1.0.0, available at https://contributor-covenant.org/version/1/0/0/
--------------------------------------------------------------------------------
/CRAN-SUBMISSION:
--------------------------------------------------------------------------------
1 | Version: 2.4.6
2 | Date: 2023-06-05 12:52:55 UTC
3 | SHA: 770d3d2d910eca75ebaaccf4c290c20e4668a95a
4 |
--------------------------------------------------------------------------------
/DESCRIPTION:
--------------------------------------------------------------------------------
1 | Package: BCEA
2 | Type: Package
3 | Title: Bayesian Cost Effectiveness Analysis
4 | Version: 2.4.7
5 | Authors@R: c(
6 | person("Gianluca", "Baio",
7 | email = "g.baio@ucl.ac.uk",
8 | role = c("aut", "cre", "cph"),
9 | comment = c(ORCID = "0000-0003-4314-2570")),
10 | person("Andrea", "Berardi",
11 | email = "a.berardi@ucl.ac.uk",
12 | role = c("aut"),
13 | comment = c(ORCID = "0000-0002-2906-496X")),
14 | person("Anna", "Heath",
15 | email = "anna.heath@sickkids.ca",
16 | role = c("aut"),
17 | comment = c(ORCID = "0000-0002-7263-4251")),
18 | person("Nathan", "Green",
19 | email = "n.green@ucl.ac.uk",
20 | role = c("aut"),
21 | comment = c(ORCID = "0000-0003-2745-1736")))
22 | Imports:
23 | cli (>= 3.3.0),
24 | dplyr,
25 | ggplot2 (>= 3.5.0),
26 | graphics,
27 | gridExtra,
28 | MASS,
29 | Matrix,
30 | MCMCvis,
31 | purrr,
32 | Rdpack,
33 | reshape2,
34 | rlang,
35 | rstan,
36 | scales
37 | Depends:
38 | R (>= 3.5.0)
39 | Suggests:
40 | coda,
41 | grid,
42 | knitr,
43 | markdown,
44 | mgcv,
45 | plotly,
46 | plotrix,
47 | RColorBrewer,
48 | rjags,
49 | rmarkdown,
50 | splancs,
51 | testthat (>= 2.1.0),
52 | vdiffr,
53 | voi (>= 1.0.1),
54 | withr
55 | RdMacros: Rdpack
56 | VignetteBuilder: knitr
57 | Description: Produces an economic evaluation of a sample of suitable variables of
58 | cost and effectiveness / utility for two or more interventions,
59 | e.g. from a Bayesian model in the form of MCMC simulations.
60 | This package computes the most cost-effective alternative and
61 | produces graphical summaries and probabilistic sensitivity analysis,
62 | see Baio et al (2017) .
63 | License: GPL-3
64 | URL: https://gianluca.statistica.it/software/bcea/,
65 | https://gianluca.statistica.it/,
66 | https://github.com/giabaio/BCEA/,
67 | https://n8thangreen.github.io/BCEA/
68 | NeedsCompilation: no
69 | RoxygenNote: 7.3.2
70 | Encoding: UTF-8
71 | BugReports: https://github.com/n8thangreen/BCEA/issues/
72 | LazyData: false
73 | Roxygen: list(markdown = TRUE)
74 |
--------------------------------------------------------------------------------
/R/BCEA-deprecated.R:
--------------------------------------------------------------------------------
1 | ## BCEA-deprecated.R
2 | #' @title Deprecated functions in package \pkg{BCEA}.
3 | #' @description The functions listed below are deprecated and will be defunct in
4 | #' the near future. When possible, alternative functions with similar
5 | #' functionality are also mentioned. Help pages for deprecated functions are
6 | #' available at `help("-deprecated")`.
7 | #' @name BCEA-deprecated
8 | #' @keywords internal
9 | NULL
10 |
--------------------------------------------------------------------------------
/R/BCEA-package.R:
--------------------------------------------------------------------------------
1 | #------------------------------------------------------------------------------#
2 | #
3 | # ___ ___ ___
4 | # _____ / /\ / /\ / /\
5 | # / /::\ / /:/ / /:/_ / /::\
6 | # / /:/\:\ / /:/ / /:/ /\ / /:/\:\
7 | # / /:/~/::\ / /:/ ___ / /:/ /:/_ / /:/~/::\
8 | # /__/:/ /:/\:| /__/:/ / /\ /__/:/ /:/ /\ /__/:/ /:/\:\
9 | # \ \:\/:/~/:/ \ \:\ / /:/ \ \:\/:/ /:/ \ \:\/:/__\/
10 | # \ \::/ /:/ \ \:\ /:/ \ \::/ /:/ \ \::/
11 | # \ \:\/:/ \ \:\/:/ \ \:\/:/ \ \:\
12 | # \ \::/ \ \::/ \ \::/ \ \:\
13 | # \__\/ \__\/ \__\/ \__\/
14 | #
15 | #
16 | #------------------------------------------------------------------------------#
17 |
18 | #' @keywords internal
19 | "_PACKAGE"
20 |
21 | ## usethis namespace: start
22 | ## usethis namespace: end
23 | NULL
24 |
--------------------------------------------------------------------------------
/R/CEriskav.default.R:
--------------------------------------------------------------------------------
1 |
2 | #' @rdname CEriskav_assign
3 | #'
4 | #' @description Default vector of risk aversion parameters:
5 | #' 1e-11, 2.5e-6, 5e-6
6 | #'
7 | #' @export
8 | #'
9 | 'CEriskav<-.bcea' <- function(he,
10 | value) {
11 |
12 | value[value == 0] <- 1e-10
13 |
14 | ### COMPARISON IS USED TO SELECT THE COMPARISON FOR WHICH THE ANALYSIS IS CARRIED OUT
15 | # Reference: Baio G, Dawid AP (2011).
16 |
17 | if (is.null(value)) {
18 | value <- c(1e-11, 2.5e-6, 5e-6)
19 | }
20 |
21 | # expected utilities & EVPI for risk aversion cases
22 | K <- length(he$k)
23 | R <- length(value)
24 | Ur <- array(NA, c(dim(he$U), R))
25 | Urstar <- array(NA, c(dim(he$Ustar), R))
26 | comparator_idx <- c(he$comp, he$ref)
27 |
28 | for (i in seq_len(K)) {
29 | for (l in seq_len(R)) {
30 | for (j in comparator_idx) {
31 | Ur[, i, j, l] <- (1/value[l])*(1 - exp(-value[l]*he$U[, i, j]))
32 | }
33 | Urstar[, i, l] <- apply(Ur[, i, , l], 1, max, na.rm = TRUE)
34 | }
35 | }
36 |
37 | IBr <- array(NA, c(he$n_sim, K, he$n_comparisons, R))
38 |
39 | for (i in seq_len(he$n_comparisons)) {
40 | IBr[,, i,] <- Ur[, , he$ref, , drop = FALSE] - Ur[, , he$comp[i], , drop = FALSE]
41 | }
42 |
43 | eibr <- apply(IBr, c(2,3,4), mean)
44 |
45 | vir <- array(NA, c(he$n_sim, K, R))
46 |
47 | for (i in seq_len(K)) {
48 | for (l in seq_len(R)) {
49 | vir[, i, l] <- Urstar[, i, l] - max(apply(Ur[, i, , l], 2, mean, na.rm = TRUE), na.rm = TRUE)
50 | }
51 | }
52 |
53 | evir <- apply(vir, c(2, 3), mean)
54 |
55 | structure(
56 | modifyList(
57 | he,
58 | list(Ur = Ur,
59 | Urstar = Urstar,
60 | IBr = IBr,
61 | eibr = eibr,
62 | vir = vir,
63 | evir = evir,
64 | R = R,
65 | r = value)),
66 | class = c("CEriskav", class(he)))
67 | }
68 |
69 |
70 | #' @rdname CEriskav_assign
71 | #'
72 | #' @export
73 | #'
74 | 'CEriskav<-.default' <- function(he, value) {
75 | stop("No available method.", call. = FALSE)
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/R/add_ceplane_xxx.R:
--------------------------------------------------------------------------------
1 |
2 | #' @importFrom graphics axis
3 | #'
4 | add_ceplane_setup <- function(plot_params) {
5 |
6 | do.call("plot",
7 | plot_params$setup,
8 | quote = TRUE)
9 | axis(1)
10 | axis(2)
11 | }
12 |
13 | #' @importFrom graphics polygon
14 | #'
15 | add_ceplane_polygon <- function(plot_params) {
16 |
17 | do.call("polygon",
18 | plot_params$polygon,
19 | quote = TRUE)
20 | box()
21 | }
22 |
23 | #' @importFrom graphics matplot
24 | #'
25 | add_ceplane_points <- function(he,
26 | plot_params) {
27 | do.call("matplot",
28 | c(list(x = he$delta_e,
29 | y = he$delta_c,
30 | add = TRUE),
31 | plot_params$points),
32 | quote = TRUE)
33 | }
34 |
35 | #' @importFrom graphics text points
36 | #'
37 | add_ceplane_icer <- function(he,
38 | plot_params) {
39 |
40 | do.call("text",
41 | plot_params$icer_text,
42 | quote = TRUE)
43 |
44 | do.call("points",
45 | c(list(
46 | x = colMeans(he$delta_e),
47 | y = colMeans(he$delta_c)),
48 | plot_params$icer_points),
49 | quote = TRUE)
50 | }
51 |
52 | #' @importFrom graphics text
53 | #'
54 | add_ceplane_k_txt <- function(plot_params) {
55 |
56 | k_equals_txt <-
57 | paste0("k == ",
58 | format(
59 | plot_params$wtp,
60 | digits = 3,
61 | nsmall = 2,
62 | scientific = FALSE))
63 |
64 | do.call(text,
65 | c(list(labels =
66 | parse(text = k_equals_txt)),
67 | plot_params$k_txt))
68 | }
69 |
70 | #' @importFrom graphics legend
71 | #'
72 | add_ceplane_legend <- function(legend_params) {
73 |
74 | do.call(legend, legend_params)
75 | }
76 |
77 | #' @importFrom graphics abline
78 | #'
79 | add_axes <- function() {
80 |
81 | abline(h = 0, v = 0, col = "dark grey")
82 | }
83 |
--------------------------------------------------------------------------------
/R/add_contour_quadrants.R:
--------------------------------------------------------------------------------
1 |
2 | #' Add Contour Quadrants
3 | #'
4 | #' @template args-he
5 | #' @param params List
6 | #'
7 | #' @return Plot side effect
8 | #' @keywords internal aplot
9 | #'
10 | add_contour_quadrants <- function(he, params) {
11 |
12 | if (length(he$comp) > 1) return()
13 |
14 | pm <- params$quadrants
15 |
16 | text(x = pm$offset * pm$M.e,
17 | y = pm$offset * pm$M.c,
18 | adj = pm$adj[[1]],
19 | parse(text = pm$t1),
20 | cex = pm$cex)
21 |
22 | text(pm$offset * pm$m.e,
23 | pm$offset * pm$M.c,
24 | adj = pm$adj[[2]],
25 | parse(text = pm$t2),
26 | cex = pm$cex)
27 |
28 | text(pm$offset * pm$m.e,
29 | pm$offset * pm$m.c,
30 | adj = pm$adj[[3]],
31 | parse(text = pm$t3),
32 | cex = pm$cex)
33 |
34 | text(pm$offset * pm$M.e,
35 | pm$offset * pm$m.c,
36 | adj = pm$adj[[4]],
37 | parse(text = pm$t4),
38 | cex = pm$cex)
39 | }
40 |
41 |
42 | #' Geom Quadrant Text
43 | #'
44 | #' @template args-he
45 | #' @param graph_params Plot parameters; list
46 | #' @keywords internal aplot
47 | #'
48 | geom_quad_txt <- function(he, graph_params) {
49 |
50 | if (length(he$comp) > 1) return(NULL)
51 |
52 | geom_text(data = graph_params$quad_txt,
53 | aes(x = .data$x,
54 | y = .data$y,
55 | hjust = .data$hjust,
56 | label = .data$label),
57 | parse = TRUE,
58 | size = rel(3.5),
59 | inherit.aes = FALSE)
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/R/add_contours.R:
--------------------------------------------------------------------------------
1 |
2 | #' Add Contours to Base R Plot
3 | #'
4 | #' @template args-he
5 | #' @param params List
6 | #' @keywords internal aplot
7 | #' @return plot side effect
8 | #'
9 | add_contours <- function(he, params) {
10 |
11 | scale <- params$scale
12 | levels <- params$levels
13 | nlevels <- params$nlevels
14 | pts_col <- params$points$col
15 |
16 | for (i in seq_along(he$delta_e)) {
17 |
18 | density <- MASS::kde2d(as.matrix(he$delta_e[, i]),
19 | as.matrix(he$delta_c[, i]),
20 | n = 300,
21 | h = c(sd(as.matrix(he$delta_e[, i]))/scale,
22 | sd(as.matrix(he$delta_c[, i]))/scale))
23 |
24 | if (!any(is.na(density$z))) {
25 | if (is.null(nlevels)) {
26 | # normalise the density and use levels in the contour
27 | density$z <-
28 | (density$z - min(density$z)) / (max(density$z) - min(density$z))
29 |
30 | graphics::contour(
31 | density$x,
32 | density$y,
33 | density$z,
34 | add = TRUE,
35 | levels = levels,
36 | col = pts_col[i],
37 | lwd = params$contour$size,
38 | drawlabels = TRUE)
39 | }
40 | if (!is.null(nlevels)) {
41 | graphics::contour(
42 | density$x,
43 | density$y,
44 | density$z,
45 | add = TRUE,
46 | col = pts_col[i],
47 | lwd = params$contour$size,
48 | nlevels = nlevels,
49 | drawlabels = FALSE)
50 | }
51 | }
52 | }
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/R/base_methods.R:
--------------------------------------------------------------------------------
1 |
2 | #' Check bcea Class
3 | #' @template args-he
4 | #' @export
5 | #'
6 | #' @return
7 | #' `is.bcea` returns TRUE or FALSE depending on whether its argument
8 | #' is a bcea class object.
9 | #'
10 | is.bcea <- function(he) inherits(he, "bcea")
11 |
12 |
13 | #' bcea Print Method
14 | #'
15 | #' @param x A `bcea` object containing the results of the Bayesian
16 | #' modelling and the economic evaluation.
17 | #' @param digits Minimal number of significant digits, see [print.default()].
18 | #' @param give.attr Logical; if TRUE (default), show attributes as sub structures.
19 | #' @param no.list Logical; if TRUE, no ‘list of ...’ nor the class are printed.
20 | #' @param ... Potential further arguments.
21 | #' @keywords print
22 | #' @export
23 | #' @importFrom utils str
24 | #'
25 | #' @examples
26 | #' data("Vaccine")
27 | #' he <- BCEA::bcea(eff, cost)
28 | #'
29 | print.bcea <- function(x,
30 | digits = getOption("digits"),
31 | give.attr = FALSE,
32 | no.list = TRUE,
33 | ...){
34 | out <-
35 | str(x,
36 | give.attr = give.attr,
37 | digits.d = digits,
38 | no.list = no.list,
39 | ...)
40 | invisible(out)
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/R/bcea_plot.R:
--------------------------------------------------------------------------------
1 | #' ##TODO:
2 | #'
3 | #' # replace top-level functions with sub-classes:
4 | #'
5 | #' ceac.plot <- function(he, graph = "base") {
6 | #' he <- structure(he, class = list("ceac", class(he)))
7 | #' bcea_plot(he, graph)
8 | #' }
9 | #'
10 | #' ceplane.plot <- function(he, graph = "base") {
11 | #' he <- structure(he, class = list("ceplane", class(he)))
12 | #' bcea_plot(he, graph)
13 | #' }
14 | #'
15 | #' # then don't have to repeat this structure every time:
16 | #'
17 | #' bcea_plot <- function(he, graph, ...) {
18 | #' params <- make_plot_params(he)
19 | #' data <- make_plot_data(he)
20 | #'
21 | #' if (is_baseplot(graph))
22 | #' plot_base(he, data, params)
23 | #' if (is_ggplot(graph))
24 | #' plot_ggplot(he, data, params)
25 | #' }
26 | #'
27 | #' #'
28 | #' make_plot_params <- function(he, ...) {
29 | #' UseMethod('make_plot_params', he)
30 | #' }
31 | #'
32 | #' make_plot_params.ceac <- function(he) {
33 | #'
34 | #' }
35 | #'
36 | #' make_plot_data.ceac <- function(he) {
37 | #'
38 | #' }
39 | #'
40 | #' #'
41 | #' plot_base <- function(he, ...) {
42 | #' UseMethod('plot_base', he)
43 | #' }
44 | #'
45 | #' plot_base.ceac <- function(he) {
46 | #'
47 | #' }
48 | #'
49 | #' plot_base.ceplane <- function(he) {
50 | #'
51 | #' }
52 | #'
53 | #' #'
54 | #' plot_ggplot <- function(he, ...) {
55 | #' UseMethod('plot_base', he)
56 | #' }
57 | #'
58 | #' plot_ggplot.ceac <- function(he) {
59 | #'
60 | #' }
61 | #'
62 | #' plot_ggplot.ceplane <- function(he) {
63 | #'
64 | #' }
65 | #'
66 | #'
67 | #' #'
68 | #' make_plot_data <- function(he, ...) {
69 | #' UseMethod('make_plot_data', he)
70 | #' }
71 | #'
72 | #'
73 | #'
74 |
--------------------------------------------------------------------------------
/R/bcea_setters.R:
--------------------------------------------------------------------------------
1 |
2 | #' @name setReferenceGroup_assign
3 | #' @title Set Reference Group
4 | #'
5 | #' @description Alternative way to define (e,c) reference group.
6 | #'
7 | #' @template args-he
8 | #' @param value Reference group number
9 | #'
10 | #' @return bcea-type object
11 | #' @export
12 | #'
13 | 'setReferenceGroup<-' <- function(he, value) {
14 | UseMethod('setReferenceGroup<-', he)
15 | }
16 |
17 | #' @rdname setReferenceGroup_assign
18 | #' @export
19 | #'
20 | 'setReferenceGroup<-.bcea' <- function(he, value) {
21 |
22 | bcea(eff = he$e,
23 | cost = he$c,
24 | ref = value,
25 | interventions = he$interventions,
26 | Kmax = he$Kmax,
27 | plot = FALSE)
28 | }
29 |
30 | #' @rdname setReferenceGroup_assign
31 | #' @export
32 | #'
33 | 'setReferenceGroup<-.default' <- function(he, value) {
34 | stop("No method available.")
35 | }
36 |
37 | # -------------------------------------------------------------------------
38 |
39 | #' @name setKmax_assign
40 | #' @title Set Maximum Willingness to Pay
41 | #'
42 | #' @description Alternative way to define `K` statistic.
43 | #'
44 | #' @template args-he
45 | #' @param value Maximum willingness to pay
46 | #'
47 | #' @return bcea-type object
48 | #' @export
49 | #'
50 | 'setKmax<-' <- function(he, value) {
51 | UseMethod('setKmax<-', he)
52 | }
53 |
54 | #' @rdname setKmax_assign
55 | #' @export
56 | #'
57 | 'setKmax<-.bcea' <- function(he, value) {
58 |
59 | bcea(eff = he$e,
60 | cost = he$c,
61 | ref = he$ref,
62 | interventions = he$interventions,
63 | Kmax = value,
64 | plot = FALSE)
65 | }
66 |
67 | #' @rdname setKmax_assign
68 | #' @export
69 | #'
70 | 'setKmax<-.default' <- function(he, value) {
71 | stop("No method available.")
72 | }
73 |
--------------------------------------------------------------------------------
/R/best_interv_given_k.R:
--------------------------------------------------------------------------------
1 |
2 | #' Optimal intervention
3 | #'
4 | #' Select the best option for each value of willingness to pay.
5 | #'
6 | #' @param eib Expected incremental benefit
7 | #' @param ref Reference group number
8 | #' @param comp Comparison group number(s)
9 | #'
10 | #' @return Group index
11 | #' @export
12 | #'
13 | best_interv_given_k <- function(eib,
14 | ref,
15 | comp) {
16 |
17 | if (length(comp) == 1) {
18 |
19 | best <- rep(ref, NROW(eib))
20 | best[eib < 0] <- comp ##TODO: why isnt it eib > 0?
21 |
22 | } else {
23 |
24 | ##TODO: what cases would this be NULL?
25 | if (is.null(dim(eib))) {
26 |
27 | min_eib <- min(eib)
28 | which_eib <- which.min(eib)
29 |
30 | } else {
31 |
32 | min_eib <- apply(eib, 1, min)
33 | which_eib <- apply(eib, 1, which.min)
34 | }
35 |
36 | best <- ifelse(min_eib > 0,
37 | yes = ref,
38 | no = comp[which_eib])
39 | }
40 |
41 | best
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/R/ce_table.R:
--------------------------------------------------------------------------------
1 |
2 | #' Cost-effectiveness summary statistics table
3 | #'
4 | #' As is commonly shown in a journal paper.
5 | #' @template args-he
6 | #' @param wtp Willingness to pay
7 | #' @param ... Additional parameters
8 | #' @keywords internal
9 | #' @examples
10 | #' data(Vaccine)
11 | #'
12 | #' # Runs the health economic evaluation using BCEA
13 | #' m <- bcea(
14 | #' e=eff,
15 | #' c=cost, # defines the variables of
16 | #' # effectiveness and cost
17 | #' ref=2, # selects the 2nd row of (e, c)
18 | #' # as containing the reference intervention
19 | #' interventions=treats, # defines the labels to be associated
20 | #' # with each intervention
21 | #' Kmax=50000, # maximum value possible for the willingness
22 | #' # to pay threshold; implies that k is chosen
23 | #' # in a grid from the interval (0, Kmax)
24 | #' )
25 | #' ce_table(m)
26 | #' @export
27 | #'
28 | ce_table <- function(he,
29 | wtp = 25000,
30 | ...) {
31 |
32 | data.frame(
33 | cost = colMeans(he$c)[c(he$ref, he$comp)],
34 | eff = colMeans(he$e)[c(he$ref, he$comp)],
35 | delta.c = c(NA, colMeans(he$delta_c)),
36 | delta.e = c(NA, colMeans(he$delta_e)),
37 | ICER = c(NA, he$ICER),
38 | INB = c(NA, he$eib[he$k == wtp, ]))
39 | }
40 |
41 |
42 | #' Calculate Dataset For ICERs From bcea Object
43 | #'
44 | #' @template args-he
45 | #' @param comp_label Optional vector of strings with comparison labels
46 | #' @param ... Additional arguments
47 | #'
48 | #' @return A data.frame object including mean outcomes, comparison identifier,
49 | #' comparison label and associated ICER
50 | #'
51 | #' @export
52 | #' @examples
53 | #' data("Smoking")
54 | #' he <- BCEA::bcea(eff, cost)
55 | #' tabulate_means(he)
56 | #'
57 | tabulate_means <- function(he,
58 | comp_label = NULL,
59 | ...) {
60 |
61 | comp_label <- comp_label %||% seq_len(he$n_comparisons)
62 |
63 | data.frame(
64 | lambda.e = vapply(1:he$n_comparisons,
65 | function(x) mean(as.matrix(he$delta_e)[, x]),
66 | FUN.VALUE = NA_real_),
67 | lambda.c = vapply(1:he$n_comparisons,
68 | function(x) mean(as.matrix(he$delta_c)[, x]),
69 | FUN.VALUE = NA_real_),
70 | comparison = as.factor(1:he$n_comparisons),
71 | label = comp_label,
72 | ICER = he$ICER)
73 | }
74 |
--------------------------------------------------------------------------------
/R/ceac_boot.R:
--------------------------------------------------------------------------------
1 | #'
2 | #' #' IB Bootstrapping
3 | #' #'
4 | #' #' @template args-he
5 | #' #' @param k Willingness to pay
6 | #' #' @param R Number of samples
7 | #' #'
8 | #' ib_boot <- function (he, k, R) {
9 | #'
10 | #' k_idx <- which(he$k == k)
11 | #' ci <- vector(mode = "numeric", length = R)
12 | #'
13 | #' for (i in seq_len(R)) {
14 | #'
15 | #' idx <- sample(1:he$n_sim, replace = TRUE)
16 | #' s <- he$ib[k_idx, , ][idx] > 0
17 | #' ci[i] <- sum(s)/he$n_sim
18 | #' }
19 | #' ci
20 | #' }
21 | #'
22 | #'
23 | #' #' CEAC Bootstrapping
24 | #' #'
25 | #' #' @template args-he
26 | #' #' @param R Number of samples
27 | #' #'
28 | #' #' @importFrom stats quantile
29 | #' #'
30 | #' #' @examples
31 | #' #' res <- ceac_boot(he, R)
32 | #' #'
33 | #' #' plot(res[, 1] , type = "l")
34 | #' #' lines(res[, 2] , type = "l")
35 | #' #'
36 | #' ceac_boot <- function(he, R) {
37 | #'
38 | #' ci <- matrix(, nrow = length(he$k), ncol = 2)
39 | #'
40 | #' for (i in seq_along(he$k)) {
41 | #'
42 | #' ib <- ib_boot(he, k = he$k[i], R)
43 | #'
44 | #' ci[i, ] <- quantile(ib, probs = c(0.025, 0.975))
45 | #' }
46 | #' ci
47 | #' }
48 | #'
49 | #'
50 |
--------------------------------------------------------------------------------
/R/ceplane_base_params.R:
--------------------------------------------------------------------------------
1 |
2 | #' @keywords dplot
3 | #'
4 | ceplane_base_params <- function(he,
5 | wtp,
6 | graph_params) {
7 |
8 | c(list(
9 | setup = setup_params(graph_params),
10 | points = points_params(graph_params),
11 | polygon = polygon_params(graph_params),
12 | k_txt = k_text(graph_params, wtp),
13 | wtp = wtp,
14 | ref_first = graph_params$ref_first),
15 | icer_params(graph_params, he))
16 | }
17 |
18 |
19 | #' @keywords dplot
20 | #'
21 | contour_base_params <- function(he,
22 | graph_params) {
23 |
24 | c(list(
25 | setup = setup_params(graph_params),
26 | points = points_params(graph_params),
27 | quadrants = quadrant_params(he, graph_params),
28 | scale = graph_params$scale,
29 | levels = graph_params$levels,
30 | contour = graph_params$contour,
31 | nlevels = graph_params$nlevels,
32 | ref_first = graph_params$ref_first),
33 | icer_params(graph_params, he))
34 | }
35 |
--------------------------------------------------------------------------------
/R/ceplane_geom_params.R:
--------------------------------------------------------------------------------
1 |
2 | #' Extract Separate Parameter Sets
3 | #'
4 | #' @param ... Additional arguments
5 | #'
6 | #' @importFrom utils modifyList
7 | #' @keywords internal
8 | #'
9 | ceplane_geom_params <- function(...) {
10 |
11 | extra_params <- list(...)
12 |
13 | icer_params <-
14 | extra_params[
15 | names(extra_params) %in% c("ICER_size", "ICER_colors")]
16 | names(icer_params) <- gsub("ICER_", "", names(icer_params))
17 |
18 | point_params <-
19 | extra_params[
20 | names(extra_params) %in% c("point_size", "point_colors")]
21 | names(point_params) <- gsub("point_", "", names(point_params))
22 |
23 | polygon_params <-
24 | extra_params[
25 | names(extra_params) %in% c("area_include", "area_color")]
26 | names(polygon_params) <- gsub("area_", "", names(polygon_params))
27 |
28 | label.pos <-
29 | extra_params[
30 | names(extra_params) %in% "label.pos"]
31 |
32 | modifyList(
33 | list(
34 | area_include = TRUE,
35 | label.pos = label.pos),
36 | list(
37 | icer = icer_params,
38 | point = point_params,
39 | area = polygon_params))
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/R/ceplane_legend_manual.R:
--------------------------------------------------------------------------------
1 |
2 | #
3 | ceplane_legend_manual <- function(he, plot_params) {
4 | isfirst <- plot_params$ref_first
5 |
6 | list(
7 | scale_color_manual(
8 | labels =
9 | line_labels.default(he, ref_first = isfirst),
10 | values = plot_params$point$color),
11 | scale_shape_manual(
12 | labels =
13 | line_labels.default(he, ref_first = isfirst),
14 | values = plot_params$point$shape))
15 | }
16 |
--------------------------------------------------------------------------------
/R/compute_eib_cri.R:
--------------------------------------------------------------------------------
1 |
2 | #' Calculate Credible Intervals
3 | #'
4 | #' For expected incremental benefit plot.
5 | #'
6 | #' @template args-he
7 | #' @param alpha_cri Significance level, 0 - 1
8 | #' @param cri.quantile Credible interval quantile?; logical
9 | #'
10 | #' @return cri
11 | #'
12 | #' @importFrom stats qnorm sd quantile
13 | #'
14 | compute_eib_cri <- function(he,
15 | alpha_cri = 0.05,
16 | cri.quantile = TRUE) {
17 |
18 | if (he$n_comparisons > 1) {
19 | margin <- c(1, 3)
20 | } else {
21 | margin <- 1
22 | }
23 |
24 | ##TODO; do low and high together so only one call to matlines()
25 | compute_cri <- function(x, low = TRUE) {
26 | tau <- ifelse(low, alpha_cri/2, 1 - alpha_cri/2)
27 |
28 | if (cri.quantile) {
29 | return(quantile(x, tau))
30 | } else {
31 | return(mean(x) - qnorm(tau) * sd(x))
32 | }
33 | }
34 |
35 | cri <- data.frame(
36 | low =
37 | c(apply(he$ib, margin, FUN = compute_cri, low = TRUE)),
38 | upp =
39 | c(apply(he$ib, margin, FUN = compute_cri, low = FALSE)),
40 | comp =
41 | as.factor(
42 | rep(1:he$n_comparisons, each = length(he$k))),
43 | k = he$k)
44 |
45 | return(cri)
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/R/contour_ggplot_params.R:
--------------------------------------------------------------------------------
1 |
2 | #' Contour ggplot Parameters
3 | #'
4 | #' @template args-he
5 | #' @param graph_params Other graphical parameters
6 | #' @param ... Additional arguments
7 | #'
8 | #' @import ggplot2
9 | #' @keywords internal
10 | #'
11 | contour_ggplot_params <- function(he,
12 | graph_params,
13 | ...) {
14 |
15 | ext_params <- ceplane_geom_params(...)
16 |
17 | graph_params$legend <-
18 | make_legend_ggplot(he, graph_params$pos_legend)
19 |
20 | if (!is.null(graph_params$nlevels)) {
21 | nlevels <- round(graph_params$nlevels)
22 | if (graph_params$nlevels < 0)
23 | nlevels <- 10
24 | if (graph_params$nlevels == 0)
25 | nlevels <- 1
26 | }
27 |
28 | default_params <-
29 | list(
30 | quadrant = quadrant_params(he, graph_params),
31 | size = rel(3.5),
32 | contour = list(
33 | aes_string(colour = "comparison"),
34 | contour_var = "ndensity",
35 | adjust = 2,
36 | size = 1,
37 | bins = 5),
38 | icer = list(
39 | data = data.frame(x = colMeans(he$delta_e),
40 | y = colMeans(he$delta_c)),
41 | mapping = aes(x = .data$x, y = .data$y),
42 | color = "red",
43 | size = convert_pts_to_mm(0.8),
44 | inherit.aes = FALSE),
45 | point = list(
46 | shape = rep(19, he$n_comparisons),
47 | size = 4),
48 | line = list(
49 | color = "black"))
50 |
51 | params <-
52 | modifyList(default_params,
53 | graph_params) %>%
54 | modifyList(ext_params)
55 |
56 | params$quad_txt <-
57 | data.frame(
58 | x = c(params$xlim[2], params$xlim[1], params$xlim[1], params$xlim[2]),
59 | y = c(params$ylim[2], params$ylim[2], params$ylim[1], params$ylim[1]),
60 | label = c(params$quadrant$t1, params$quadrant$t2,
61 | params$quadrant$t3, params$quadrant$t4),
62 | hjust = c(1, 0, 0, 1))
63 |
64 | params
65 | }
66 |
67 |
--------------------------------------------------------------------------------
/R/convert_pts_to_mm.R:
--------------------------------------------------------------------------------
1 |
2 | #' Use from Base R to ggplot
3 | #'
4 | #' @param x points
5 | #' @keywords internal
6 | #'
7 | convert_pts_to_mm <- function(x)
8 | x*72.27/25.4
9 |
10 |
--------------------------------------------------------------------------------
/R/eib_legend_base.R:
--------------------------------------------------------------------------------
1 |
2 | #'
3 | eib_legend_base <- function(he, graph_params) {
4 |
5 | list(x = where_legend(he, graph_params$pos),
6 | legend = paste0(he$interventions[he$ref], " vs ",
7 | he$interventions[he$comp]),
8 | cex = 0.7,
9 | bty = "n",
10 | lwd = graph_params$line$lwd,
11 | col = graph_params$line$color,
12 | lty = graph_params$line$type)
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/R/eib_params_base.R:
--------------------------------------------------------------------------------
1 |
2 | #' EIB parameters specific to base R plot
3 | #'
4 | #' @template args-he
5 | #' @param graph_params Type of plot device
6 | #' @param cri_params Credible interval parameters
7 | #' @return list
8 | #' @keywords internal
9 | #'
10 | eib_params_base <- function(he,
11 | graph_params,
12 | cri_params) {
13 |
14 | ylim <-
15 | if (!cri_params$plot.cri) {
16 | range(c(he$eib))
17 | } else {
18 | range(c(he$eib),
19 | cri_params$data$low,
20 | cri_params$data$upp)
21 | }
22 |
23 | list(
24 | xlab = graph_params$xlab,
25 | ylab = graph_params$ylab,
26 | main = graph_params$main,
27 | col = graph_params$line$color,
28 | lwd = graph_params$line$lwd,
29 | lty = graph_params$line$type,
30 | type = "l",
31 | xlim = range(he$k),
32 | ylim = ylim)
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/R/eib_params_cri.R:
--------------------------------------------------------------------------------
1 |
2 | #' EIB Parameters CrI
3 | #' @keywords internal aplot
4 | #'
5 | eib_params_cri <- function(he, graph_params) {
6 | list(plot.cri = graph_params$plot.cri,
7 | data =
8 | compute_eib_cri(he,
9 | graph_params$alpha_cri,
10 | graph_params$cri.quantile),
11 | col = graph_params$line$cri_col,
12 | lty = graph_params$line$cri_lty)
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/R/eib_params_ggplot.R:
--------------------------------------------------------------------------------
1 |
2 | #
3 | eib_params_ggplot <- function(he,
4 | graph_params,
5 | cri_params,
6 | ...) {
7 |
8 | graph_params <- helper_ggplot_params(he, graph_params)
9 |
10 | ##TODO: remove duplication with base
11 | ylim <-
12 | if (!cri_params$plot.cri) {
13 | range(c(he$eib))
14 | } else {
15 | range(c(he$eib),
16 | cri_params$data)
17 | }
18 |
19 | default_params <-
20 | list(
21 | size = rel(3.5),
22 | text = list(
23 | size =
24 | if (is.rel(graph_params$text$size)) {
25 | 11 * unclass(graph_params$text$size) # theme_get()$text$size
26 | } else {
27 | graph_params$text$size
28 | }
29 | ),
30 | kstar = list(
31 | geom = "text",
32 | label = paste0("k* = ", format(he$kstar, digits = 6)),
33 | x = he$kstar,
34 | y = min(ylim),
35 | hjust = ifelse((max(he$k) - he$kstar)/max(he$k) > 1/6,
36 | yes = -0.1,
37 | no = 1.1),
38 | vjust = 1),
39 | cri = list(
40 | lwd = ifelse(!graph_params$plot.cri, 0.5, 0.75),
41 | show.legend = FALSE),
42 | currency = "")
43 |
44 | modifyList(default_params,
45 | graph_params)
46 | }
47 |
--------------------------------------------------------------------------------
/R/evppi_plot_base.R:
--------------------------------------------------------------------------------
1 |
2 | #' @title Plot Expected Value of Partial Information With Respect to a
3 | #' Set of Parameters
4 | #'
5 | #' @description Base R and \pkg{ggplot2} versions.
6 | #'
7 | #' @name evppi_plot_graph
8 | #'
9 | NULL
10 |
11 |
12 | #' @rdname evppi_plot_graph
13 | #'
14 | #' @param evppi_obj Object of class `evppi`
15 | #' @param pos_legend Position of legend
16 | #' @param col Colour
17 | #' @param annot Annotate EVPPI curve with parameter names
18 | #'
19 | evppi_plot_base <- function(evppi_obj,
20 | pos_legend,
21 | col = NULL,
22 | annot = FALSE) {
23 | legend_params <-
24 | evppi_legend_base(evppi_obj, pos_legend, col)
25 |
26 | plot(evppi_obj$k,
27 | evppi_obj$evi,
28 | type = "l",
29 | col = legend_params$col[1],
30 | lty = legend_params$lty[1],
31 | xlab = "Willingness to pay",
32 | ylab = "",
33 | main = "Expected Value of Perfect Partial Information",
34 | lwd = 2,
35 | ylim = range(range(evppi_obj$evi),
36 | range(evppi_obj$evppi)))
37 |
38 | if (!is.list(evppi_obj$evppi))
39 | evppi_obj$evppi <- list(evppi_obj$evppi)
40 |
41 | evppi_dat <- do.call(cbind, evppi_obj$evppi)
42 | txt_coord_y <- evppi_dat[length(evppi_obj$k), ]
43 |
44 | matplot(evppi_obj$k,
45 | evppi_dat,
46 | type = "l",
47 | col = legend_params$col[-1],
48 | lty = legend_params$lty[-1],
49 | add = TRUE)
50 |
51 | if (annot) {
52 | text(x = par("usr")[2],
53 | y = txt_coord_y,
54 | labels = paste0("(", evppi_obj$index, ")", collapse = " "),
55 | cex = 0.7,
56 | pos = 2)
57 | }
58 |
59 | do.call(legend, legend_params)
60 |
61 | return(invisible(NULL))
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/R/evppi_plot_ggplot.R:
--------------------------------------------------------------------------------
1 |
2 | #' @rdname evppi_plot_graph
3 | #'
4 | #' @param evppi_obj Object of class evppi
5 | #' @param pos_legend Position of legend
6 | #' @param col Colour
7 | #' @param ... Additional arguments
8 | #'
9 | #' @importFrom purrr pluck keep
10 | #' @import dplyr ggplot2
11 | #'
12 | evppi_plot_ggplot <- function(evppi_obj,
13 | pos_legend = c(0, 0.8),
14 | col = c(1,1),
15 | ...) {
16 |
17 | extra_args <- list(...)
18 |
19 | plot_dat <-
20 | evppi_obj[c("evi", "evppi", "k")] %>%
21 | bind_rows() %>%
22 | ##TODO: for >1 evppi
23 | melt(id.vars = "k") %>%
24 | mutate(variable = as.character(.data$variable),
25 | variable = ifelse(.data$variable == "evppi",
26 | paste("EVPPI for",
27 | evppi_obj$parameters),
28 | "EVPI"))
29 |
30 | theme_add <- Filter(f = \(val) ggplot2::is.theme(val), x = extra_args)
31 |
32 | size <- purrr::pluck(extra_args, "size", .default = c(1, 0.5))
33 |
34 | legend_params <- make_legend_ggplot(evppi_obj, pos_legend)
35 |
36 | ggplot(plot_dat,
37 | aes(x = .data$k, y = .data$value,
38 | group = .data$variable, size = .data$variable, colour = .data$variable)) +
39 | geom_line() +
40 | theme_default() +
41 | theme_add +
42 | scale_color_manual(values = col) +
43 | scale_size_manual(values = size) +
44 | do.call(theme, legend_params) +
45 | ggtitle("Expected Value of Perfect Partial Information") +
46 | xlab("Willingness to pay") +
47 | ylab("")
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/R/evppi_plot_helpers.R:
--------------------------------------------------------------------------------
1 |
2 | #' @importFrom grDevices colors
3 | #'
4 | evppi_legend_cols <- function(evppi_obj, col = NULL) {
5 |
6 | n_cols <- length(evppi_obj$parameters) + 1
7 |
8 | if (is.null(col)) {
9 | cols <- colors()
10 | gr <- floor(seq(from = 261, to = 336, length.out = n_cols))
11 | return(cols[gr])
12 |
13 | } else {
14 | if (length(col) != n_cols) {
15 | message(
16 | "The vector 'col' must have the number of elements for an EVPI
17 | colour and each of the EVPPI parameters. Forced to black\n")
18 | return(rep("black", length(evppi_obj$parameters) + 1))
19 | }
20 | }
21 |
22 | col
23 | }
24 |
25 |
26 | #'
27 | evppi_legend_text <- function(evppi_obj) {
28 |
29 | cmd <-
30 | if (nchar(evppi_obj$parameters[1]) <= 25) {
31 | paste0("EVPPI for ", evppi_obj$parameters)
32 | } else "EVPPI for the selected\nsubset of parameters"
33 |
34 | if (length(evppi_obj$index) > 1 &&
35 | (("Strong & Oakley (univariate)" %in% evppi_obj$method) ||
36 | ("Sadatsafavi et al" %in% evppi_obj$method))) {
37 |
38 | # label lines
39 | for (i in seq_along(evppi_obj$index)) {
40 |
41 | ##TODO:
42 | # text(x = par("usr")[2],
43 | # y = evppi_obj$evppi[[i]][length(evppi_obj$k)],
44 | # labels = paste0("(", i, ")"), cex = 0.7, pos = 2)
45 | }
46 |
47 | cmd <-
48 | paste0("(",
49 | paste(seq_len(evppi_obj$index)),
50 | ") EVPPI for ",
51 | evppi_obj$parameters)
52 | }
53 |
54 | c("EVPI", cmd)
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/R/filter_by.R:
--------------------------------------------------------------------------------
1 |
2 | # helper functions so don't have to remember
3 | # which dimension for which statistic
4 |
5 | Ustar_filter_by <- function(he, wtp) {
6 | he$Ustar[, he$k == wtp]
7 | }
8 |
9 | U_filter_by <- function(he, wtp) {
10 | he$U[, he$k == wtp, ]
11 | }
12 |
13 | ib_filter_by <- function(he, wtp) {
14 | he$ib[he$k == wtp, , ]
15 | }
16 |
17 | ol_filter_by <- function(he, wtp) {
18 | he$ol[, he$k == wtp]
19 | }
20 |
21 | vi_filter_by <- function(he, wtp) {
22 | he$vi[, he$k == wtp]
23 | }
24 |
--------------------------------------------------------------------------------
/R/geom_cri.R:
--------------------------------------------------------------------------------
1 |
2 | #' Credible interval ggplot geom
3 | #'
4 | #' @param plot.cri Should we plot CrI? Logical
5 | #' @param params Plot parameters including data
6 | #' @keywords internal aplot
7 | #'
8 | geom_cri <- function(plot.cri = TRUE,
9 | params = NA) {
10 | if (plot.cri) {
11 | list(geom_line(data = params$data,
12 | aes(y = .data$low,
13 | group = .data$comp),
14 | linetype = 2),
15 | geom_line(data = params$data,
16 | aes(y = .data$upp,
17 | group = .data$comp),
18 | linetype = 2))
19 | } else list(NULL)
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/R/helper_base_params.R:
--------------------------------------------------------------------------------
1 |
2 | #' @importFrom grDevices colors
3 | #' @keywords dplot
4 | #'
5 | helper_base_params <- function(he,
6 | graph_params) {
7 |
8 | n_lines <- num_lines(he)
9 |
10 | if (n_lines == 1) {
11 | default_params <-
12 | list(list(lwd = 1,
13 | line = list(type = 1)))
14 |
15 | graph_params <- modifyList(default_params, graph_params)
16 | }
17 |
18 | if (n_lines > 1) {
19 | default_params <-
20 | list(list(lwd = ifelse(n_lines <= 6, 1, 1.5),
21 | line =
22 | list(type = rep_len(1:6, n_lines),
23 | color = colors()[floor(seq(262, 340,
24 | length.out = n_lines))])
25 | ))
26 |
27 | graph_params <- modifyList(default_params, graph_params)
28 |
29 | types <- graph_params$line$type
30 | cols <- graph_params$line$color
31 |
32 | is_enough_types <- length(types) >= n_lines || length(types) == 1
33 | is_enough_colours <- length(cols) >= n_lines || length(cols) == 1
34 |
35 | if (!is_enough_types) {
36 | graph_params$line$type <- rep_len(types, n_lines)
37 | message("Wrong number of line types provided. Falling back to default\n")}
38 |
39 | if (!is_enough_colours) {
40 | graph_params$line$color <- rep_len(cols, n_lines)
41 | message("Wrong number of colours provided. Falling back to default\n")}
42 | }
43 |
44 | list(type = "l",
45 | main = graph_params$annot$title,
46 | xlab = graph_params$annot$x,
47 | ylab = graph_params$annot$y,
48 | ylim = c(0, 1),
49 | lty = graph_params$line$type,
50 | col = graph_params$line$color,
51 | lwd = graph_params$lwd,
52 | pch = NULL)
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/R/helper_ggplot_params.R:
--------------------------------------------------------------------------------
1 |
2 | #' @noRd
3 | #'
4 | #' @keywords dplot
5 | #'
6 | helper_ggplot_params <- function(he,
7 | graph_params) {
8 |
9 | n_lines <- num_lines(he)
10 |
11 | text_default <- list(
12 | size =
13 | if (is.rel(graph_params$text$size)) {
14 | 11 * unclass(graph_params$text$size) # theme_get()$text$size
15 | } else {
16 | graph_params$text$size
17 | })
18 |
19 | if (n_lines == 1) {
20 | default_params <-
21 | list(labels = NULL,
22 | line =
23 | list(type = 1,
24 | color = 1,
25 | size = 1),
26 | text = text_default)
27 |
28 | graph_params <-
29 | modifyList(default_params, graph_params)
30 | }
31 |
32 | if (n_lines > 1) {
33 | default_params <-
34 | list(labels = line_labels(he),
35 | line =
36 | list(type = rep_len(1:6, n_lines),
37 | color = 1,
38 | size = rep_len(1, n_lines)),
39 | text = text_default)
40 |
41 | graph_params <- modifyList(default_params, graph_params)
42 |
43 | types <- graph_params$line$type
44 | cols <- graph_params$line$color
45 | sizes <- graph_params$line$size
46 |
47 | is_enough_types <- length(types) >= n_lines
48 | is_enough_colours <- length(cols) >= n_lines
49 | is_enough_sizes <- length(sizes) == n_lines
50 |
51 | if (!is_enough_types) {
52 | graph_params$line$type <- rep_len(types, n_lines)}
53 | if (!is_enough_colours) {
54 | graph_params$line$color <- rep_len(cols, n_lines)}
55 | if (!is_enough_sizes) {
56 | graph_params$line$size <- rep_len(sizes, n_lines)}
57 | }
58 |
59 | graph_params
60 | }
61 |
--------------------------------------------------------------------------------
/R/kstar_vlines.R:
--------------------------------------------------------------------------------
1 |
2 | #' Prepare K-star vertical lines
3 | #'
4 | #' @template args-he
5 | #' @param plot_params Plots parameters
6 | #' @keywords internal
7 | #'
8 | kstar_vlines <- function(he, plot_params) {
9 |
10 | if (length(he$kstar) > 0) {
11 | abline(v = he$kstar,
12 | col = "dark grey",
13 | lty = "dotted")
14 |
15 | text(x = he$kstar,
16 | y = min(plot_params$ylim),
17 | paste("k* = ", he$kstar , sep = ""))
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/R/ldr.R:
--------------------------------------------------------------------------------
1 |
2 | # Package: ldr
3 | # Type: Package
4 | # Title: Methods for likelihood-based dimension reduction in regression
5 | # Version: 1.3.3
6 | # Date: 2014-06-06
7 | # Author: Kofi Placid Adragni, Andrew Raim
8 | # Maintainer: Kofi Placid Adragni
9 | # Description: Functions, methods, and data sets for fitting likelihood-based dimension reduction in regression,
10 | # using principal fitted components (pfc), likelihood acquired directions (lad), covariance reducing models (core).
11 | # URL: https://www.jstatsoft.org/v61/i03/
12 | # License: GPL (>= 2)
13 | # Packaged: 2021-10-08 16:32:42 UTC; Nathan
14 | # Repository: https://github.com/cran/ldr
15 | # Date/Publication: 2014-10-29 16:36:14
16 | #
17 | # Likelihood-based Dimension Reduction
18 | #
19 | # Main function of the package. It creates objects of one of classes core, lad,
20 | # or pfc to estimate a sufficient dimension reduction subspace using covariance reducing models (CORE),
21 | # likelihood acquired directions (LAD), or principal fitted components (PFC).
22 | #
23 | ldr <-
24 | function(X, y=NULL, fy=NULL, Sigmas=NULL, ns=NULL, numdir=NULL, nslices=NULL,
25 | model=c("core", "lad", "pfc"), numdir.test=FALSE, ...)
26 | {
27 | if (model=="pfc")
28 | {
29 | if (is.null(fy)){stop("fy is not provided"); return()}
30 |
31 | return(invisible(pfc(X=X, y=y, fy=fy, numdir=numdir, numdir.test=numdir.test, ...)))
32 | }
33 |
34 | if (model=="lad")
35 | {
36 | if (is.null(y)){stop("The response is needed"); return()}
37 |
38 | return(invisible(lad(X=X, y=y, numdir=numdir, nslices=nslices, numdir.test=numdir.test,...)))
39 | }
40 |
41 | if (model=="core")
42 | {
43 | if (!is.null(Sigmas) && !is.null(ns))
44 | return(invisible(core(Sigmas=Sigmas, ns=ns, numdir=numdir, numdir.test=numdir.test,...)))
45 |
46 | return(invisible(core(X=X, y=y, numdir=numdir, numdir.test=numdir.test,...)))
47 | }
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/R/line_labels.R:
--------------------------------------------------------------------------------
1 |
2 | #' Create Labels for Plot
3 | #'
4 | #' @template args-he
5 | #' @param ... Additional arguments
6 | #' @export
7 | #' @keywords internal
8 | #'
9 | line_labels <- function(he, ...) UseMethod("line_labels", he)
10 |
11 |
12 | #' Swapped labels so that reference is second
13 | #' @rdname line_labels
14 | #' @export
15 | #'
16 | line_labels.default <- function(he, ref_first = TRUE, ...) {
17 |
18 | if (he$n_comparisons == 1) return("")
19 |
20 | if (ref_first) {
21 | paste(he$interventions[he$ref], "vs",
22 | he$interventions[he$comp])
23 | } else {
24 | paste(he$interventions[he$comp], "vs",
25 | he$interventions[he$ref])
26 | }
27 | }
28 |
29 | #' @rdname line_labels
30 | #' @export
31 | #'
32 | line_labels.pairwise <- function(he, ...) {
33 | he$interventions[c(he$comp, he$ref)]
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/R/list_methods.R:
--------------------------------------------------------------------------------
1 |
2 | #' @importFrom utils methods
3 | #'
4 | list_plot_methods <- function() {
5 |
6 | m <- methods(class = "bcea")
7 | m[grep(pattern = "plot", m)]
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/R/make_legend_ggplot.R:
--------------------------------------------------------------------------------
1 |
2 | #' @noRd
3 | #' @title make_legend_ggplot
4 | #'
5 | #' @description c(0, 0) corresponds to the “bottom left”
6 | #' c(1, 1) corresponds to the “top right”
7 | #' inside the plotting area
8 | #'
9 | #' @param dat data
10 | #' @param pos_legend Legend position
11 | #'
12 | #' @keywords internal
13 | #'
14 | make_legend_ggplot <- function(dat, pos_legend) {
15 |
16 | legend_just <- NULL # sets the corner that the legend_pos position refers to
17 | legend_dir <- NULL
18 |
19 | n_lines <- num_lines(dat)
20 |
21 | if (n_lines == 1) {
22 |
23 | legend_pos <- "none"
24 |
25 | } else if (any(is.na(pos_legend))) {
26 |
27 | legend_pos <- "none"
28 |
29 | } else if (is.logical(pos_legend)) {
30 |
31 | if (isTRUE(pos_legend)) {
32 | legend_pos <- "bottom"
33 | } else {
34 | legend_pos <- c(1, 0)
35 | legend_just <- legend_pos
36 | }
37 | } else if (is.character(pos_legend)) {
38 |
39 | pos_choices <- c("left", "right", "bottom", "top")
40 | dir_choices <- c("horizontal", "vertical")
41 |
42 | legend_pos <- pos_choices[sapply(pos_choices, function(t) grepl(t, pos_legend))]
43 | legend_dir <- dir_choices[sapply(dir_choices, function(t) grepl(t, pos_legend))]
44 |
45 | if (length(legend_dir) == 0) {
46 | legend_dir <- NULL # default
47 | }
48 |
49 | legend_just <- "center"
50 | } else if (is.numeric(pos_legend) &&
51 | length(pos_legend) == 2) {
52 |
53 | legend_pos <- pos_legend
54 | legend_just <- pos_legend
55 | } else {
56 | # default
57 | legend_pos <- c(1, 0)
58 | legend_just <- legend_pos
59 | }
60 |
61 | list(legend.direction = legend_dir,
62 | legend.justification = legend_just,
63 | legend.position = legend_pos)
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/R/make_legend_plotly.R:
--------------------------------------------------------------------------------
1 |
2 | #' Legend Positioning
3 | #'
4 | #' @param pos_legend Position of legend
5 | #' @return String
6 | #'
7 | #' @export
8 | #' @keywords internal
9 | #'
10 | make_legend_plotly <- function(pos_legend) {
11 |
12 | legend_params <- list(orientation = "v",
13 | xanchor = "center",
14 | x = 0.5,
15 | y = 0)
16 |
17 | if (is.character(pos_legend))
18 | legend_params <- switch(
19 | pos_legend,
20 | "left" = list(orientation = "v", x = 0, y = 0.5),
21 | "bottomleft" = list(orientation = "v", x = 0, y = 0),
22 | "topleft" = list(orientation = "v", x = 0, y = 1),
23 | "right" = list(orientation = "v", x = 0, y = 0.5),
24 | "bottomright" = list(orientation = "v", x = 1, y = 0),
25 | "topright" = list(orientation = "v", x = 1, y = 1),
26 | "bottom" = list(orientation = "v", xanchor = "center", x = 0.5, y = 0),
27 | "top" = list(orientation = "h", xanchor = "center", x = 0.5, y = 100))
28 |
29 | legend_params
30 | }
--------------------------------------------------------------------------------
/R/misc_helpers.R:
--------------------------------------------------------------------------------
1 |
2 | #
3 | `%||%` <- function(x, y) {
4 | if (is.null(x)) y else x
5 | }
6 |
7 | #' Reports whether x is a rel object
8 | #' Copied from ggplot2
9 | #'
10 | #' @param x An object to test
11 | #' @keywords internal
12 | is.rel <- function(x) inherits(x, "rel")
13 |
--------------------------------------------------------------------------------
/R/mixedAn.default.R:
--------------------------------------------------------------------------------
1 |
2 | #' @export
3 | #'
4 | 'mixedAn<-.bcea' <- function(he,
5 | value = NULL) {
6 |
7 | Ubar <- OL.star <- evi.star <- NULL
8 |
9 | value <- value %||% rep(1, he$n_comparators)/he$n_comparators
10 |
11 | Ubar <- compute_Ubar(he, value)
12 | OL.star <- he$Ustar - Ubar
13 | evi.star <- compute_EVI(OL.star)
14 |
15 | structure(
16 | modifyList(
17 | he,
18 | list(
19 | Ubar = Ubar,
20 | OL.star = OL.star,
21 | evi.star = evi.star,
22 | mkt.shares = value)),
23 | class = c("mixedAn", class(he)))
24 | }
25 |
26 |
27 | #' @export
28 | #'
29 | 'mixedAn<-.default' <- function(he,
30 | value) {
31 | stop("No method available", call. = FALSE)
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/R/multi.ce.R:
--------------------------------------------------------------------------------
1 |
2 | #' @name multi.ce
3 | #' @title Cost-effectiveness Analysis With Multiple Comparison
4 | #'
5 | #' @description Computes and plots the probability that each of the `n_int` interventions
6 | #' being analysed is the most cost-effective and the cost-effectiveness
7 | #' acceptability frontier.
8 | #'
9 | #' @template args-he
10 | #'
11 | #' @return Original `bcea` object (list) of class "pairwise" with additional:
12 | #' \item{p_best_interv}{A matrix including the probability that each
13 | #' intervention is the most cost-effective for all values of the willingness to
14 | #' pay parameter}
15 | #' \item{ceaf}{A vector containing the cost-effectiveness acceptability frontier}
16 | #'
17 | #' @author Gianluca Baio
18 | #' @seealso [bcea()],
19 | #' [ceaf.plot()]
20 | #' @keywords hplot dplot
21 | #'
22 | #' @examples
23 | #' # See Baio G., Dawid A.P. (2011) for a detailed description of the
24 | #' # Bayesian model and economic problem
25 | #'
26 | #' # Load the processed results of the MCMC simulation model
27 | #' data(Vaccine)
28 | #'
29 | #' # Runs the health economic evaluation using BCEA
30 | #'
31 | #' m <- bcea(e=eff, c=cost, # defines the variables of
32 | #' # effectiveness and cost
33 | #' ref=2, # selects the 2nd row of (e,c)
34 | #' # as containing the reference intervention
35 | #' interventions=treats, # defines the labels to be associated
36 | #' # with each intervention
37 | #' Kmax=50000, # maximum value possible for the willingness
38 | #' # to pay threshold; implies that k is chosen
39 | #' # in a grid from the interval (0,Kmax)
40 | #' plot=FALSE # inhibits graphical output
41 | #' )
42 | #'
43 | #' mce <- multi.ce(m) # uses the results of the economic analysis
44 | #'
45 | #' ceac.plot(mce)
46 | #' ceaf.plot(mce)
47 | #'
48 | #' @export
49 | #'
50 | multi.ce.bcea <- function(he) {
51 |
52 | p_best_interv <- compute_p_best_interv(he)
53 | ceaf <- compute_ceaf(p_best_interv)
54 |
55 | res <- c(he,
56 | list(p_best_interv = p_best_interv,
57 | ceaf = ceaf))
58 |
59 | structure(res, class = c("pairwise", class(he)))
60 | }
61 |
62 |
63 | #' @export
64 | #'
65 | multi.ce <- function(he) {
66 | UseMethod('multi.ce', he)
67 | }
68 |
69 |
70 |
--------------------------------------------------------------------------------
/R/multiplot.R:
--------------------------------------------------------------------------------
1 |
2 | #' Plot Multiple bcea Graphs
3 | #'
4 | #' Arrange plots in grid. Sourced from R graphics cookbook.
5 | #'
6 | #' @param plotlist List of ggplot objects
7 | #' @param cols Number of columns
8 | #' @param layout_config Matrix of plot configuration
9 | #' @return ggplot TableGrob object
10 | #'
11 | #' @importFrom gridExtra grid.arrange
12 | #' @keywords internal
13 | #'
14 | multiplot <- function(plotlist = NULL,
15 | cols = 1,
16 | layout_config = NULL) {
17 |
18 | n_plots <- length(plotlist)
19 |
20 | layout_config <-
21 | layout_config %||% matrix(seq(1, cols*ceiling(n_plots/cols)),
22 | ncol = cols,
23 | nrow = ceiling(n_plots/cols))
24 |
25 | grid_params <-
26 | c(plotlist, list(layout_matrix = layout_config))
27 |
28 | do.call("grid.arrange", grid_params)
29 | }
30 |
--------------------------------------------------------------------------------
/R/new_bcea.R:
--------------------------------------------------------------------------------
1 |
2 | #' Constructor for bcea
3 | #'
4 | #' @param df_ce Dataframe of all simulation eff and cost
5 | #' @param k Vector of willingness to pay values
6 | #'
7 | #' @import reshape2 dplyr
8 | #' @importFrom rlang int
9 | #'
10 | #' @return List object of class bcea.
11 | #' @seealso [bcea()]
12 | #'
13 | #' @export
14 | #'
15 | new_bcea <- function(df_ce, k) {
16 |
17 | # K <- length(k)
18 | ref <- unique(df_ce$ref)
19 | comp <- (1:max(df_ce$ints))[-ref]
20 | df_ce_comp <- df_ce %>% filter(.data$ints != ref)
21 |
22 | ICER <- compute_ICER(df_ce)
23 |
24 | ib <- compute_IB(df_ce, k)
25 |
26 | ceac <- compute_CEAC(ib)
27 |
28 | eib <- compute_EIB(ib)
29 |
30 | best <- best_interv_given_k(eib, ref, comp)
31 |
32 | kstar <- compute_kstar(k, best, ref)
33 |
34 | U <- compute_U(df_ce, k)
35 |
36 | Ustar <- compute_Ustar(U)
37 |
38 | vi <- compute_vi(Ustar, U)
39 |
40 | ol <- compute_ol(Ustar, U, best)
41 |
42 | evi <- compute_EVI(ol)
43 |
44 | interv_names <- levels(df_ce$interv_names)
45 |
46 | e_dat <-
47 | reshape2::dcast(sim ~ interv_names,
48 | value.var = "eff1",
49 | data = df_ce)[, -1]
50 |
51 | c_dat <-
52 | reshape2::dcast(sim ~ interv_names,
53 | value.var = "cost1",
54 | data = df_ce)[, -1]
55 |
56 |
57 | delta_e <-
58 | reshape2::dcast(sim ~ interv_names,
59 | value.var = "delta_e",
60 | data = df_ce_comp)[, -1, drop = FALSE]
61 |
62 | delta_c <-
63 | reshape2::dcast(sim ~ interv_names,
64 | value.var = "delta_c",
65 | data = df_ce_comp)[, -1, drop = FALSE]
66 |
67 | he <-
68 | list(n_sim = length(unique(df_ce$sim)),
69 | n_comparators = length(comp) + 1,
70 | n_comparisons = length(comp),
71 | delta_e = delta_e,
72 | delta_c = delta_c,
73 | ICER = ICER,
74 | Kmax = max(k),
75 | k = k,
76 | ceac = ceac,
77 | ib = ib,
78 | eib = eib,
79 | kstar = kstar,
80 | best = best,
81 | U = U,
82 | vi = vi,
83 | Ustar = Ustar,
84 | ol = ol,
85 | evi = evi,
86 | ref = ref,
87 | comp = comp,
88 | step = k[2] - k[1],
89 | interventions = interv_names,
90 | e = as.matrix(e_dat),
91 | c = as.matrix(c_dat))
92 |
93 | structure(he, class = c("bcea", class(he)))
94 | }
95 |
96 |
--------------------------------------------------------------------------------
/R/num_lines.R:
--------------------------------------------------------------------------------
1 | # Number of lines
2 | # which depends on the type of plot
3 |
4 |
5 | #' @title Get number of lines
6 | #' @name num_lines
7 | #' @param dat Data
8 | #' @keywords internal
9 | #'
10 | num_lines <- function(dat) {
11 | UseMethod('num_lines', dat)
12 | }
13 |
14 | #' @rdname num_lines
15 | #'
16 | num_lines.pairwise <- function(dat) {
17 | dat$n_comparators
18 | }
19 |
20 | #' @rdname num_lines
21 | #'
22 | num_lines.bcea <- function(dat) {
23 | dat$n_comparisons
24 | }
25 |
26 | #' @rdname num_lines
27 | #'
28 | num_lines.evppi <- function(dat) {
29 | 2
30 | }
31 |
32 | #' @rdname num_lines
33 | #'
34 | num_lines.default <- function(dat) {
35 | dat$n_comparisons
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/R/orthonorm.R:
--------------------------------------------------------------------------------
1 |
2 | # Package: ldr
3 | # Type: Package
4 | # Title: Methods for likelihood-based dimension reduction in regression
5 | # Version: 1.3.3
6 | # Date: 2014-06-06
7 | # Author: Kofi Placid Adragni, Andrew Raim
8 | # Maintainer: Kofi Placid Adragni
9 | # Description: Functions, methods, and data sets for fitting likelihood-based dimension reduction in regression,
10 | # using principal fitted components (pfc), likelihood acquired directions (lad), covariance reducing models (core).
11 | # URL: https://www.jstatsoft.org/v61/i03/
12 | # License: GPL (>= 2)
13 | # Packaged: 2021-10-08 16:32:42 UTC; Nathan
14 | # Repository: https://github.com/cran/ldr
15 | # Date/Publication: 2014-10-29 16:36:14
16 | #' @importFrom cli cli_alert_warning
17 | #
18 | orthonorm <- function (u) {
19 | if (is.null(u))
20 | return(NULL)
21 |
22 | if (!(is.matrix(u)))
23 | u <- as.matrix(u)
24 | dd <- dim(u)
25 | n <- dd[1]
26 | p <- dd[2]
27 | if (prod(abs(La.svd(u)$d) > 1e-08) == 0)
28 | stop("collinears vectors in orthonorm")
29 | if (n < p) {
30 | cli::cli_alert_warning(
31 | "There are too many vectors to orthonormalize in orthonorm.")
32 | u <- as.matrix(u[, 1:p])
33 | n <- p
34 | }
35 | v <- u
36 | if (p > 1) {
37 | for (i in 2:p) {
38 | coef.proj <- c(crossprod(u[, i], v[, 1:(i - 1)]))/diag(crossprod(v[,
39 | 1:(i - 1)]))
40 | v[, i] <- u[, i] - matrix(v[, 1:(i - 1)], nrow = n) %*%
41 | matrix(coef.proj, nrow = i - 1)
42 | }
43 | }
44 | coef.proj <- 1/sqrt(diag(crossprod(v)))
45 | return(t(t(v) * coef.proj))
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/R/plot.mixedAn.R:
--------------------------------------------------------------------------------
1 |
2 | #' @rdname BCEA-deprecated
3 | #' @section `plot.mixedAn`:
4 | #' For `plot.mixedAn`, use [evi.plot()].
5 | #'
6 | #' Summary plot of the health economic analysis when the mixed analysis is
7 | #' considered
8 | #'
9 | #' Compares the optimal scenario to the mixed case in terms of the EVPI.
10 | #'
11 | #' @param x An object of class `mixedAn`, given as output of the call to
12 | #' the function [mixedAn()].
13 | #' @param y.limits Range of the y-axis for the graph. The default value is
14 | #' `NULL`, in which case the maximum range between the optimal and the
15 | #' mixed analysis scenarios is considered.
16 | #' @param pos Parameter to set the position of the legend. Can be given in form
17 | #' of a string `(bottom|top)(right|left)` for base graphics and
18 | #' `bottom|top|left|right` for ggplot2. It can be a two-elements vector,
19 | #' which specifies the relative position on the x and y axis respectively, or
20 | #' alternatively it can be in form of a logical variable, with `FALSE`
21 | #' indicating to use the default position and `TRUE` to place it on the
22 | #' bottom of the plot. Default value is `c(0,1)`, that is in the topleft
23 | #' corner inside the plot area.
24 | #' @param graph A string used to select the graphical engine to use for
25 | #' plotting. Should (partial-)match the two options `"base"` or
26 | #' `"ggplot2"`. Default value is `"base"`.
27 | #' @param ... Arguments to be passed to methods, such as graphical parameters
28 | #' (see [par()]).
29 | #' @return \item{evi}{ A ggplot object containing the plot. Returned only if
30 | #' `graph="ggplot2"`. } The function produces a graph showing the
31 | #' difference between the ''optimal'' version of the EVPI (when only the most
32 | #' cost-effective intervention is included in the market) and the mixed
33 | #' strategy one (when more than one intervention is considered in the market).
34 | #' @author Gianluca Baio, Andrea Berardi
35 | #' @usage plot.mixedAn(x, y.limits=NULL, pos=c(0,1), graph=c("base","ggplot2"),...)
36 | #'
37 | #' @export
38 | #'
39 | plot.mixedAn <- function(x, y.limits = NULL, pos = c(0,1),
40 | graph = c("base","ggplot2"), ...) {
41 | .Deprecated(new = "evi.plot")
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/R/plot_eib_cri.R:
--------------------------------------------------------------------------------
1 |
2 | #' Plot Credible Intervals
3 | #'
4 | #' Bayesian posterior credible intervals against willingness to pay.
5 | #' @template args-he
6 | #' @param params Graph parameters
7 | #' @importFrom graphics matlines
8 | #' @keywords internal
9 | #'
10 | plot_eib_cri <- function(he, params) {
11 |
12 | if (!params$plot.cri) return()
13 |
14 | ##TODO: move y rearranging to compute_eib_cri()
15 | ##TODO: single do.call() on combined y matrix
16 | do.call(matlines,
17 | list(x = he$k,
18 | y = matrix(params$data$low,
19 | ncol = he$n_comparisons),
20 | col = params$col,
21 | lty = params$lty))
22 |
23 | do.call(matlines,
24 | list(x = he$k,
25 | y = matrix(params$data$upp,
26 | ncol = he$n_comparisons),
27 | col = params$col,
28 | lty = params$lty))
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/R/prep_ceplane_params.R:
--------------------------------------------------------------------------------
1 |
2 | #' Prepare CE-plane Parameters
3 | #'
4 | #' In ggplot format, combine user-supplied
5 | #' parameters with defaults.
6 | #'
7 | #' @template args-he
8 | #' @param wtp_params Willingness-to-pay parameters. This can be a single value or a list.
9 | #' @param ... Additional arguments
10 | #' @importFrom grDevices grey.colors
11 | #'
12 | #' @return List pf graph parameters
13 | #' @export
14 | #' @keywords internal
15 | #'
16 | prep_ceplane_params <- function(he, wtp_params, ...) {
17 |
18 | graph_params <- list(...)
19 |
20 | # back compatibility
21 | if (!is.list(wtp_params)) {
22 | wtp_params <- list(value = wtp_params)
23 | }
24 |
25 | intervs_in_title <-
26 | paste("\n",
27 | he$interventions[he$ref],
28 | "vs",
29 | paste0(he$interventions[he$comp],
30 | collapse = ", "))
31 |
32 | plot_title <-
33 | paste0(
34 | "Cost-Effectiveness Plane",
35 | ifelse(he$n_comparisons == 1, #he$change_comp,
36 | yes = intervs_in_title,
37 | no = ""))
38 |
39 | axes_lim <- xy_params(he, wtp_params$value, graph_params)
40 |
41 | default_params <-
42 | list(xlab = "Incremental effectiveness",
43 | ylab = "Incremental cost",
44 | title = plot_title,
45 | xlim = axes_lim$xlim,
46 | ylim = axes_lim$ylim,
47 | label.pos = TRUE,
48 | point = list(
49 | color = grey.colors(n = he$n_comparisons,
50 | end = 0.7,
51 | alpha = 1),
52 | size = 0.35,
53 | shape = rep(20, he$n_comparisons)),
54 | wtp = list(
55 | value = 25000),
56 | area_include = TRUE,
57 | ICER_size = 2,
58 | text = list(
59 | size = 11),
60 | area = list(
61 | # line_color = "black",
62 | col = "grey95"),
63 | ref_first = TRUE)
64 |
65 | out <-
66 | modifyList(default_params, graph_params) |>
67 | modifyList(list(wtp = wtp_params))
68 |
69 | out$wtp$label <- paste0(" k = ", format(out$wtp$value, digits = 6), "\n")
70 |
71 | # move out of wtp list so can pass straight to geom
72 | out$wtp_value <- out$wtp$value
73 | out$wtp$value <- NULL
74 |
75 | out
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/R/prep_contour_params.R:
--------------------------------------------------------------------------------
1 |
2 | #' Prepare contour plot parameters
3 | #' Additional to ceplane parameters
4 | #' @template args-he
5 | #' @param ... Additional parameters
6 | #' @return A list of parameters
7 | #' @keywords internal
8 | #'
9 | prep_contour_params <- function(he, ...) {
10 |
11 | contour_params <- list(...)
12 | ceplane_params <- prep_ceplane_params(he, wtp_params = 1e7, ...)
13 |
14 | default_params <-
15 | modifyList(ceplane_params,
16 | list(scale = 0.5,
17 | nlevels = NULL,
18 | levels = c(0.25, 0.5, 0.75, 0.95)))
19 | modifyList(default_params, contour_params)
20 | }
21 |
--------------------------------------------------------------------------------
/R/prep_eib_params.R:
--------------------------------------------------------------------------------
1 |
2 | #' Prepare EIB plot parameters
3 | #'
4 | #' Parameters general to all plotting devices.
5 | #'
6 | #' @template args-he
7 | #' @param plot.cri Make title including credible interval? Logical
8 | #' @param ... Additional parameters
9 | #' @return List of graph parameters
10 | #' @keywords internal
11 | #'
12 | prep_eib_params <- function(he, plot.cri, ...) {
13 |
14 | graph_params <- list(...)
15 |
16 | default_params <-
17 | list(
18 | xlab = "Willingness to pay",
19 | ylab = "EIB",
20 | alpha_cri = 0.05,
21 | cri.quantile = TRUE,
22 | area = list(include = FALSE,
23 | color = "grey"),
24 | labels = line_labels(he),
25 | text = list(
26 | size = 11),
27 | line = list(
28 | type = rep_len(1:6, he$n_comparisons),
29 | lwd = ifelse(he$n_comparisons > 6, 1.5, 1),
30 | color = 1, #1:he$n_comparisons,
31 | cri_col = "grey50",
32 | cri_lty = 2),
33 | plot.cri = ifelse((is.null(plot.cri) && he$n_comparisons == 1) ||
34 | (!is.null(plot.cri) && plot.cri),
35 | TRUE, FALSE))
36 |
37 | graph_params <- modifyList(default_params, graph_params)
38 |
39 | graph_params$main <-
40 | paste0(
41 | "Expected Incremental Benefit",
42 | ifelse(
43 | default_params$plot.cri,
44 | paste0("\nand ", format((1 - graph_params$alpha_cri)*100, digits = 4),
45 | "% credible intervals"),
46 | ""))
47 |
48 | graph_params <- validate_eib_params(graph_params)
49 |
50 | graph_params
51 | }
52 |
53 |
54 | #' Validate EIB parameters
55 | #'
56 | #' @param params Graph parameters
57 | #' @seealso [prep_eib_params()]
58 | #' @return List of graph parameters
59 | #' @importFrom cli cli_alert_warning
60 | #' @keywords internal
61 | #'
62 | validate_eib_params <- function(params) {
63 |
64 | if (params$alpha_cri < 0 || params$alpha_cri > 1) {
65 | cli::cli_alert_warning(
66 | "Argument {.var alpha} must be between 0 and 1. Reset to default value 0.95.")
67 | params$alpha_cri <- 0.05
68 | }
69 |
70 | if (params$alpha_cri > 0.8 && params$cri.quantile) {
71 | cli::cli_alert_warning(
72 | "It is recommended adopting the normal approximation of the credible interval for high values of {.var alpha}.
73 | Please set the argument {.code cri.quantile = FALSE} to use the normal approximation.")
74 | }
75 |
76 | params
77 | }
78 |
79 |
--------------------------------------------------------------------------------
/R/prepare_ceac_params.R:
--------------------------------------------------------------------------------
1 |
2 | #' @keywords dplot
3 | #'
4 | prepare_ceac_params <- function(he, ...) {
5 |
6 | extra_params <- list(...)
7 |
8 | # defaults
9 |
10 | plot_params <- list(area = list(include = FALSE,
11 | color = NULL),
12 | line = list(color = "black",
13 | size = 1,
14 | type = 1:num_lines(he)),
15 | text = list(size = 11),
16 | currency = "")
17 |
18 | annot_params <- list(title = "Cost Effectiveness Acceptability Curve",
19 | x = "Willingness to pay",
20 | y = "Probability of cost effectiveness")
21 |
22 | plot_extra_params <- extra_params[c("area", "line", "text", "currency")]
23 | annot_extra_params <- extra_params[c("title", "xlab", "ylab")]
24 |
25 | annot_params <- modifyList(annot_params, annot_extra_params)
26 | plot_params <- modifyList(plot_params, plot_extra_params)
27 |
28 | c(plot_params,
29 | list(annot = annot_params))
30 | }
31 |
--------------------------------------------------------------------------------
/R/prepare_ceac_params_multi.R:
--------------------------------------------------------------------------------
1 |
2 | ##TODO: I can't find where this is used?...
3 | #
4 | prepare_ceac_params_multi <- function(he,
5 | pos,
6 | ...) {
7 |
8 | alt.legend <- pos
9 | lty <- rep(1:6, ceiling(he$n_comparators/6))[1:he$n_comparators]
10 | label <- paste0(he$interventions)
11 |
12 | jus <- NULL
13 |
14 | if (alt.legend) {
15 | alt.legend <- "bottom"
16 | heplot <- heplot + theme(legend.direction = "vertical")
17 | } else {
18 | if (is.character(alt.legend)) {
19 | choices <- c("left", "right", "bottom", "top")
20 | alt.legend <- choices[pmatch(alt.legend, choices)]
21 | jus <- "center"
22 |
23 | if (is.na(alt.legend))
24 | alt.legend <- FALSE
25 | }
26 |
27 | if (length(alt.legend) > 1)
28 | jus <- alt.legend
29 |
30 | if (length(alt.legend) == 1 && !is.character(alt.legend)) {
31 | alt.legend <- c(1, 0.5)
32 | jus <- alt.legend
33 | }
34 | }
35 |
36 | list(jus = jus,
37 | alt.legend = alt.legend,
38 | label = label,
39 | lty = lty)
40 | }
--------------------------------------------------------------------------------
/R/quadrant_params.R:
--------------------------------------------------------------------------------
1 |
2 | #' Quadrant Parameters
3 | #' requires just a single comparison group
4 | #' @keywords internal aplot
5 | #'
6 | quadrant_params <- function(he, params) {
7 |
8 | p.ne <-
9 | sum(he$delta_e > 0 &
10 | he$delta_c > 0) / he$n_sim
11 | p.nw <-
12 | sum(he$delta_e <= 0 &
13 | he$delta_c > 0) / he$n_sim
14 | p.sw <-
15 | sum(he$delta_e <= 0 &
16 | he$delta_c <= 0) / he$n_sim
17 | p.se <-
18 | sum(he$delta_e > 0 &
19 | he$delta_c <= 0) / he$n_sim
20 |
21 | list(
22 | cex = 0.8,
23 | offset = 1.0,
24 | adj = list(c(1,1), c(0,1),c(0,0), c(1,0)),
25 | p.ne = p.ne,
26 | p.nw = p.nw,
27 | p.sw = p.sw,
28 | p.se = p.se,
29 | m.e = params$xlim[1],
30 | M.e = params$xlim[2],
31 | m.c = params$ylim[1],
32 | M.c = params$ylim[2],
33 | t1 = paste("Pr(Delta[e]>0, Delta[c]>0)==",
34 | format(p.ne, digits = 4, nsmall = 3),
35 | sep = ""),
36 | t2 = paste("Pr(Delta[e]<=0, Delta[c]>0)==",
37 | format(p.nw, digits = 4, nsmall = 3),
38 | sep = ""),
39 | t3 = paste("Pr(Delta[e]<=0, Delta[c]<=0)==",
40 | format(p.sw, digits = 4, nsmall = 3),
41 | sep = ""),
42 | t4 = paste("Pr(Delta[e]>0, Delta[c]<=0)==",
43 | format(p.se, digits = 4, nsmall = 3),
44 | sep = ""))
45 | }
46 |
--------------------------------------------------------------------------------
/R/select_plot_type.R:
--------------------------------------------------------------------------------
1 |
2 | #' Choose Graphical Engine
3 | #'
4 | #' From base R, ggplot2 or plotly.
5 | #'
6 | #' @param graph Type names; string
7 | #' @return Plot ID integer 1:base R; 2:ggplot2; 3:plotly
8 | #' @importFrom cli cli_alert_warning
9 | #' @keywords dplot internal
10 | #'
11 | select_plot_type <- function(graph) {
12 |
13 | if (missing(graph)) graph <- "base"
14 |
15 | graph_lup <- c(base = 1, ggplot2 = 2, plotly =3)
16 | graph_type <- graph_lup[graph]
17 |
18 | is_req_pkgs <- unname(sapply(c("ggplot2", "grid"),
19 | requireNamespace, quietly = TRUE))
20 |
21 | if (graph_type == 2 && !all(is_req_pkgs)) {
22 | cli::cli_alert_warning(
23 | "Packages {.pkg ggplot2} and {.pkg grid} not found;
24 | plot will be rendered using base graphics.")
25 | graph_type <- 1}
26 |
27 | if (graph_type == 3 && !requireNamespace("plotly", quietly = TRUE)) {
28 | cli::cli_alert_warning(
29 | "Package {.pkg plotly} not found;
30 | plot will be rendered using base graphics.")
31 | graph_type <- 1}
32 |
33 | graph_type
34 | }
35 |
36 |
37 | #'
38 | is_baseplot <- function(graph) {
39 |
40 | select_plot_type(graph) == 1
41 | }
42 |
43 | #'
44 | is_ggplot <- function(graph) {
45 |
46 | select_plot_type(graph) == 2
47 | }
48 |
49 | #'
50 | is_plotly <- function(graph) {
51 |
52 | select_plot_type(graph) == 3
53 | }
54 |
55 |
56 | ##TODO: this is from eib.plot()
57 | ## do we need to change anything?
58 | ##
59 | # # choose graphical engine
60 | # if (any(is.null(graph)) || any(is.na(graph))) graph <- "base"
61 | #
62 | # graph_choice <- pmatch(graph[1], c("base", "ggplot2", "plotly"), nomatch = 1)
63 | #
64 | # if (graph_choice == 2 &&
65 | # !requireNamespace("ggplot2", quietly = TRUE) &
66 | # requireNamespace("grid", quietly = TRUE)) {
67 | # warning("Package ggplot2 and grid not found;
68 | # eib.plot will be rendered using base graphics.")
69 | # graph_choice <- 1
70 | # }
71 | # if (graph_choice == 3 &&
72 | # !requireNamespace("plotly", quietly = TRUE)) {
73 | # warning("Package plotly not found;
74 | # eib.plot will be rendered using base graphics.")
75 | # graph_choice <- 1
76 | # }
77 |
78 |
--------------------------------------------------------------------------------
/R/setComparisons.R:
--------------------------------------------------------------------------------
1 |
2 | #' @name setComparisons
3 | #' @title Set Comparisons Group
4 | #'
5 | #' @description One of the alternative way to set (e,c) comparison group.
6 | #' Simply recompute all comparisons and drop unwanted.
7 | #'
8 | #' @template args-he
9 | #' @template args-comparison
10 | #' @seealso [setComparisons<-()]
11 | #' @export
12 | #'
13 | setComparisons <- function(he, comparison) {
14 |
15 | if (is.null(comparison)) return(he)
16 |
17 | if (he$ref %in% comparison)
18 | stop("Can't select Reference group. Change Reference first.",
19 | call. = FALSE)
20 |
21 | n_interv <- ncol(he$e)
22 | if (any(!comparison %in% 1:n_interv))
23 | stop("Comparison index not in available comparisons.",
24 | call. = FALSE)
25 |
26 | res <-
27 | bcea(eff = he$e,
28 | cost = he$c,
29 | ref = he$ref,
30 | interventions = he$interventions,
31 | Kmax = he$Kmax,
32 | k = he$k)
33 |
34 | name_comp <- he$interventions[comparison]
35 |
36 | res$comp <- comparison
37 | res$n_comparisons <- length(comparison)
38 | res$n_comparators <- length(comparison) + 1
39 |
40 | res$delta_e <- res$delta_e[, name_comp, drop = FALSE]
41 | res$delta_c <- res$delta_c[, name_comp, drop = FALSE]
42 |
43 | res$ICER <- res$ICER[name_comp]
44 | res$ib <- res$ib[, , name_comp, drop = FALSE]
45 | res$eib <- res$eib[, name_comp, drop = FALSE]
46 | res$ceac <- res$ceac[, name_comp, drop = FALSE]
47 |
48 | ##TODO: is there a way not to recompute the whole thing?
49 | res$best <- best_interv_given_k(res$eib, res$ref, res$comp)
50 | res$kstar <- compute_kstar(res$k, res$best, res$ref)
51 |
52 | ##TODO: currently compute _all_ interventions in compute_U()
53 | ## change to this?
54 | # res$U <- res$U[, , name_comp, drop = FALSE]
55 |
56 | return(res)
57 | }
58 |
59 |
60 | #' @name setComparisons_assign
61 | #' @title Set Comparison Group
62 | #'
63 | #' @description One of the alternative way to set (e,c) comparison group.
64 | #'
65 | #' @template args-he
66 | #' @param value Comparison
67 | #' @return bcea-type object
68 | #' @seealso [setComparisons()]
69 | #' @export
70 | #'
71 | 'setComparisons<-' <- function(he, value) {
72 | UseMethod('setComparisons<-', he)
73 | }
74 |
75 | #' @rdname setComparisons_assign
76 | #' @export
77 | #'
78 | 'setComparisons<-.bcea' <- function(he, value) {
79 |
80 | setComparisons(he, value)
81 | }
82 |
83 | #' @rdname setComparisons_assign
84 | #' @export
85 | #'
86 | 'setComparisons<-.default' <- function(he, value) {
87 | stop("No method available.")
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/R/themes_ggplot.R:
--------------------------------------------------------------------------------
1 | # themes for ggplot functions ---------------------------------------------
2 |
3 | #' bcea theme ggplot2
4 | #' @name theme_bcea
5 | #' @keywords internal aplot
6 | #'
7 | theme_default <- function() {
8 |
9 | theme_bw() %+replace%
10 | theme(legend.title = element_blank(),
11 | legend.background = element_blank(),
12 | text = element_text(size = 11),
13 | legend.key.size = grid::unit(0.66, "lines"),
14 | legend.spacing = grid::unit(-1.25, "line"),
15 | panel.grid = element_blank(),
16 | legend.key = element_blank(),
17 | legend.text = element_text(hjust = 0),
18 | plot.title = element_text(
19 | lineheight = 1.05,
20 | face = "bold",
21 | size = 14.3,
22 | hjust = 0.5),
23 | complete = TRUE)
24 | }
25 |
26 | #' @rdname theme_bcea
27 | #'
28 | theme_ceac <- function() {
29 | theme_default()
30 | }
31 |
32 | #' @rdname theme_bcea
33 | #'
34 | theme_ceplane <- function() {
35 | theme_default()
36 | }
37 |
38 | #' @rdname theme_bcea
39 | #'
40 | theme_eib <- function() {
41 | theme_default()
42 | }
43 |
44 | #' @rdname theme_bcea
45 | #'
46 | theme_contour <- function() {
47 | theme_default()
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/R/validate_bcea.R:
--------------------------------------------------------------------------------
1 |
2 | #' Validate bcea
3 | #'
4 | #' @param eff Effectiveness matrix
5 | #' @param cost Cost matrix
6 | #' @param ref Reference intervention
7 | #' @param interventions All interventions
8 | #'
9 | #' @export
10 | #' @keywords internal
11 | #'
12 | validate_bcea <- function(eff,
13 | cost,
14 | ref,
15 | interventions) {
16 |
17 | if (!is.matrix(cost) || !is.matrix(eff))
18 | stop("eff and cost must be matrices.", call. = FALSE)
19 |
20 | if (ncol(cost) == 1 || ncol(eff) == 1)
21 | stop("Require at least 2 comparators.", call. = FALSE)
22 |
23 | if (!is.null(interventions) && length(interventions) != ncol(eff))
24 | stop("interventions names wrong length.", call. = FALSE)
25 |
26 | if (any(dim(eff) != dim(cost)))
27 | stop("eff and cost are not the same dimensions.", call. = FALSE)
28 |
29 | if (!is.numeric(ref) || ref < 1 || ref > ncol(eff))
30 | stop("reference is not in available interventions.", call. = FALSE)
31 |
32 | return()
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/R/xy_params.R:
--------------------------------------------------------------------------------
1 |
2 | ##TODO: need to compare with master
3 | #
4 | xy_params <- function(he,
5 | wtp,
6 | graph_params) {
7 |
8 | e_dat <- he$delta_e
9 | c_dat <- he$delta_c
10 |
11 | min_e <- min(e_dat)
12 | max_e <- max(e_dat)
13 |
14 | min_c <- min(c_dat)
15 | max_c <- max(c_dat)
16 |
17 | # force negative
18 | min_e <- -abs(min_e)
19 | min_c <- -abs(min_c)
20 |
21 | # square plotting area
22 | min_e <- min(min_e, min_c/wtp)
23 | max_e <- max(max_e, max_c/wtp)
24 |
25 | # min_c <- min_e*wtp
26 | # max_c <- max_e*wtp
27 |
28 | list(xlim = c(min_e, max_e),
29 | ylim = c(min_c, max_c))
30 | }
31 |
--------------------------------------------------------------------------------
/R/zzz.R:
--------------------------------------------------------------------------------
1 | .bcea_env <- new.env(parent = emptyenv())
2 |
3 | .onLoad <- function(libname, pkgname) {
4 | op <- options()
5 | op.bcea <- list(
6 | scipen = 10)
7 | toset <- !(names(op.bcea) %in% names(op))
8 | if (any(toset)) options(op.bcea[toset])
9 |
10 | ps.options(encoding = "CP1250")
11 | pdf.options(encoding = "CP1250")
12 |
13 | Sys.setenv("_R_CHECK_LENGTH_1_CONDITION_" = "TRUE")
14 |
15 | invisible()
16 | }
17 |
18 | #' @title .onAttach
19 | #' @description prints out a friendly reminder message to the user
20 | #' @inheritParams base .onAttach
21 | #' @return NULL
22 | #' @noRd
23 | .onAttach <- function(libname, pkgname) {
24 | packageStartupMessage("The BCEA version loaded is: ", utils::packageVersion("BCEA"))
25 | }
26 |
--------------------------------------------------------------------------------
/_pkgdown.yml:
--------------------------------------------------------------------------------
1 | url: https://n8thangreen.github.io/BCEA/
2 |
3 | news:
4 | cran_dates: false
5 |
6 | template:
7 | bootstrap: 5
8 | theme: atom-one-light
9 | bslib:
10 | font_scale: 1.0
11 |
12 | navbar:
13 | structure:
14 | left: [intro, reference, articles, tutorials, news, cheatsheet]
15 | right: [search, github]
16 | components:
17 | cheatsheet:
18 | text: "Cheatsheet"
19 | href: "bcea_cheatsheet.pdf"
20 |
21 | reference:
22 | - title: "Main"
23 | contents:
24 | - BCEA-package
25 | - bcea
26 | - new_bcea
27 | - title: "Setters"
28 | desc: "Functions for modifying or extending a `bcea()` analysis."
29 | contents:
30 | - starts_with("setComparisons")
31 | - starts_with("setKmax")
32 | - starts_with("setReferenceGroup")
33 | - mixedAn<-
34 | - CEriskav
35 | - multi.ce
36 | - struct.psa
37 | - title: "Plotting"
38 | desc: "Functions for plotting a wide variety of cost-effectiveness plots in base R, ggplot2 and plotly."
39 | contents:
40 | - starts_with("ceac")
41 | - starts_with("ceaf")
42 | - starts_with("ceef")
43 | - starts_with("ceplane")
44 | - starts_with("contour")
45 | - starts_with("eib.plot")
46 | - starts_with("evi.plot")
47 | - starts_with("evi_plot_graph")
48 | - ib.plot
49 | - starts_with("ib_plot")
50 | - info.rank
51 | - starts_with("info_rank_graph")
52 | - plot.bcea
53 | - plot.CEriskav
54 | - starts_with("CEriskav_plot_graph")
55 | - plot.evppi
56 | - starts_with("evppi_plot_graph")
57 | - title: "Statistics"
58 | desc: "Lower level functions for computing a range of cost-effectiveness statistics."
59 | contents:
60 | - best_interv_given_k
61 | - starts_with("compute_")
62 | - title: "Outputs"
63 | desc: "Functions for reporting the results of the cost-effectiveness analysis."
64 | contents:
65 | - make.report
66 | - sim_table
67 | - tabulate_means
68 | - starts_with("summary")
69 | - title: "Miscellaneous"
70 | desc: "Helper functions and other intermediate computations."
71 | contents:
72 | - starts_with("createInputs")
73 | - evppi
74 | - is.bcea
75 | - print.bcea
76 | - select_plot_type
77 | - title: "Data"
78 | contents:
79 | - Smoking
80 | - Vaccine
81 | - statins_base
82 | - statins_HC
83 | - title: "Deprecated"
84 | contents:
85 | - mce.plot
86 | - plot.mixedAn
87 |
88 |
89 |
--------------------------------------------------------------------------------
/cran-comments.md:
--------------------------------------------------------------------------------
1 | ## R CMD check results
2 |
3 | 0 errors | 0 warnings | 0 notes
4 |
5 | * This is an updated release.
6 |
--------------------------------------------------------------------------------
/data/Smoking.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/data/Smoking.RData
--------------------------------------------------------------------------------
/data/Vaccine.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/data/Vaccine.RData
--------------------------------------------------------------------------------
/data/datalist:
--------------------------------------------------------------------------------
1 | Smoking: cost data eff life.years pi_post smoking smoking_output treats
2 | Vaccine: c.pts cost cost.GP cost.hosp cost.otc cost.time.off cost.time.vac cost.travel cost.trt1 cost.trt2 cost.vac e.pts eff N N.outcomes N.resources QALYs.adv QALYs.death QALYs.hosp QALYs.inf QALYs.pne treats vaccine_mat
3 | statins_base: BUGS object
4 | statins_HC: BUGS object
5 |
--------------------------------------------------------------------------------
/data/statins_HC.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/data/statins_HC.RData
--------------------------------------------------------------------------------
/data/statins_base.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/data/statins_base.RData
--------------------------------------------------------------------------------
/inst/CITATION:
--------------------------------------------------------------------------------
1 | citHeader("To cite BCEA in publications use:")
2 |
3 | bibentry(
4 | bibtype = "Book",
5 | title = "Bayesian Cost-Effectiveness Analysis with the R package {BCEA}",
6 | author = "Baio, G and Berardi, A and Heath, A",
7 | year = "2017",
8 | publisher = "Springer",
9 | month = "Jul",
10 | address = "New York, NY",
11 | url = "https://link.springer.com/book/10.1007/978-3-319-55718-2",
12 | doi = "10.1007/978-3-319-55718-2",
13 | isbn = "978-3-319-55718-2",
14 | textVersion =
15 | paste("Baio et al (2017).",
16 | "Bayesian Cost Effectiveness Analysis with the R package BCEA.",
17 | "Springer, New York, NY.",
18 | "doi: 10.1007/978-3-319-55718-2,",
19 | "URL: https://link.springer.com/book/10.1007/978-3-319-55718-2")
20 | )
--------------------------------------------------------------------------------
/inst/extdata/smoking_output.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/inst/extdata/smoking_output.RData
--------------------------------------------------------------------------------
/inst/extdata/statins_HC.Rdata:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/inst/extdata/statins_HC.Rdata
--------------------------------------------------------------------------------
/inst/extdata/statins_base.Rdata:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/inst/extdata/statins_base.Rdata
--------------------------------------------------------------------------------
/inst/extdata/vaccine_jags.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/inst/extdata/vaccine_jags.RData
--------------------------------------------------------------------------------
/inst/jags/smoking-jags.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "smoking-jags"
3 | output: rmarkdown::html_vignette
4 | vignette: >
5 | %\VignetteIndexEntry{smoking-jags}
6 | %\VignetteEngine{knitr::rmarkdown}
7 | %\VignetteEncoding{UTF-8}
8 | ---
9 |
10 | ```{r, include = FALSE}
11 | knitr::opts_chunk$set(
12 | collapse = TRUE,
13 | comment = "#>"
14 | )
15 | ```
16 |
17 | ```{r setup}
18 | library(BCEA)
19 | ```
20 |
21 | Load the R2jags package and the the data file
22 | ```{r}
23 | library(R2jags)
24 | ```
25 |
26 | Specify the name of the jags model file.
27 | ```{r}
28 | model.file <- here::here("inst/jags/smoking_model_RE.txt")
29 | ```
30 |
31 | Load smoking data.
32 | ```{r}
33 | data("Smoking")
34 | ```
35 |
36 | Copy smoking data frame columns to local variables.
37 | ```{r}
38 | attach(smoking)
39 | nobs <- nobs
40 | s <- s
41 | t <- i
42 | r <- r_i
43 | n <- n_i
44 | b <- b_i + 1
45 | detach(smoking)
46 | ```
47 |
48 | ```{r}
49 | # number of trials
50 | ns <- length(unique(s))
51 |
52 | # number of comparators
53 | nt <- length(unique(t))
54 |
55 | # number of observations
56 | nobs <- dim(smoking)[1]
57 |
58 | # how many studies include baseline
59 | incb <- sum(table(s, b)[, 1] > 0)
60 | ```
61 |
62 | Define data and parameters to monitor and run.
63 | ```{r}
64 | inputs <- list ("s", "n", "r", "t", "ns", "nt", "b", "nobs", "incb")#, "na")
65 | pars <- c("rr ", "pi ", "p", "d", "sd ")#, "T")
66 |
67 | smoking_output <-
68 | jags(
69 | data = inputs,
70 | inits = NULL,
71 | parameters.to.save = pars,
72 | model.file = model.file,
73 | n.burnin = 5000,
74 | n.chains = 2,
75 | n.iter = 10000,
76 | n.thin = 20)
77 | ```
78 |
79 |
80 | ```{r}
81 | smoking_output
82 | ```
83 |
84 | ```{r}
85 | save(smoking_output, file = here::here("inst/extdata/smoking_output.RData"))
86 | ```
87 |
--------------------------------------------------------------------------------
/inst/jags/smoking_model_RE.txt:
--------------------------------------------------------------------------------
1 | ### JAGS model ###
2 | model {
3 | for(i in 1:nobs){
4 | r[i] ~ dbin(p[i], n[i])
5 | p[i] <- ilogit(mu[s[i]] + delta[s[i], t[i]])
6 | delta[s[i], t[i]] ~ dnorm(md[i], tau)
7 | md[i] <- d[t[i]] - d[b[s[i]]]
8 | }
9 | for(i in 1:ns){
10 | mu[i] ~ dnorm(0, 0.0001)
11 | AbsTrEf[i] <- ifelse(b[i] == 1, mu[i] , 0)
12 | }
13 | pi0 <- sum(AbsTrEf[])/incb
14 | tau <- pow(sd, -2)
15 | sd ~ dunif(0.00001, 2)
16 | d[1] <- 0
17 | for(k in 2:nt){
18 | d[k] ~ dnorm(0, 0.0001)
19 | }
20 | for(j in 1:nt){
21 | logit(pi[j]) <- pi0 + d[j]
22 | for (k in 1:nt){
23 | lor[j, k] <- d[j] - d[k]
24 | log(or[j, k]) <- lor[j, k]
25 | rr[j, k] <- pi[j]/pi[k]
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/inst/rmarkdown/report/biblio.bib:
--------------------------------------------------------------------------------
1 | @BOOK{Baioetal:2017,
2 | title = {{Bayesian Cost-Effectiveness Analysis with the R package BCEA}},
3 | publisher = {Springer},
4 | year = {2017},
5 | author = {Baio, G and Berardi, A and Heath, A},
6 | month = {Jul},
7 | address = {New York, NY},
8 | url = {http://www.springer.com/us/book/9783319557168},
9 | doi = {10.1007/978-3-319-55718-2},
10 | isbn = {978-3-319-55718-2}
11 | }
12 |
--------------------------------------------------------------------------------
/inst/rmarkdown/report/section_CEAC.Rmd:
--------------------------------------------------------------------------------
1 |
2 | ## Cost-effectiveness acceptability curve
3 |
4 | The _Cost-Effectiveness Acceptability Curve_ (CEAC) estimates the probability of cost-effectiveness, for different willingness to pay thresholds. The CEAC is used to evaluate the uncertainty associated with the decision-making process, since it quantifies the degree to which a treatment is preferred. This is measured in terms of the difference in utilities, normally the incremental benefit. Effectively, the CEAC represents the proportion of simulations in which $t=1$ is associated with a higher utility than $t=0$.
5 |
6 | The following graph shows the cost-effectiveness acceptability curve (CEAC). The CEAC represents the proportion of 'potential futures' in which the reference intervention is estimated to be more cost-effective than the comparator. Thus, it can be interpreted as the 'probability of cost-effectiveness'.
7 |
8 |
9 | ```{r, echo=echo, fig.width=4.6, fig.height=4.6, fig.align=align, warning=FALSE, message=FALSE, comment=NA}
10 | ceac.plot(m)
11 | ```
12 |
--------------------------------------------------------------------------------
/inst/rmarkdown/report/section_CEAF.Rmd:
--------------------------------------------------------------------------------
1 |
2 | ## Cost-effectiveness acceptability frontier
3 |
4 | In addition to the CEAC, we can also visualise the uncertainty in the decision-making process using the _Cost-Effectiveness Acceptability Frontier_ (CEAF). The frontier is defined as the maximum value of the probability of cost-effectiveness among all comparators. It is an indication of the uncertainty associated with choosing the cost effective intervention. In other terms, higher frontier values correspond to lower decision uncertainty.
5 |
6 |
7 | ```{r, echo=echo, fig.width=4.6, fig.height=4.6, fig.align=align, warning=FALSE, message=FALSE, comment=NA}
8 | n.ints <- m$n_comparators
9 |
10 | if (n.ints == 2) {
11 | graph <- "base"
12 | pos <- c(1, 1)
13 | } else {
14 | graph <- "ggplot2"
15 | pos <- TRUE
16 | }
17 | ceaf.plot(multi.ce(m), graph = graph)
18 | ```
--------------------------------------------------------------------------------
/inst/rmarkdown/report/section_CEEF.Rmd:
--------------------------------------------------------------------------------
1 |
2 | ## Cost-effectiveness efficiency frontier
3 |
4 | The _Cost-Effectiveness Efficiency Frontier_ (CEEF) compares the net costs and benefits of different interventions in a given therapeutic area. It is different from the common differential approach (e.g. based on the Cost-Effectiveness plane), because it is based on the _net_ measures. The predicted costs and effectiveness for the interventions under consideration are compared directly to the costs and effectiveness for the treatments that are currently available. The frontier in itself defines the set of interventions for which cost is at an acceptable level for the benefits given by the treatment. A new intervention is _efficient_ if its average effectiveness is greater than any of the currently available alternatives, or its cost are lower than that associated with other interventions of the same effectiveness.
5 |
6 | In the following plot, the circles indicate the mean for the cost and effectiveness distributions for each treatment option. The number in each circle corresponds to the order of the treatments in the legend. If the number is black then the intervention is on the efficiency frontier. Grey numbers indicate dominated treatments.
7 |
8 |
9 | ```{r, echo=echo, comment=" ", warning=FALSE, message=FALSE, fig.width=4.6, fig.height=4.6, fig.align=align, warning=FALSE, message=FALSE, comment=NA}
10 | n.ints <- m$n_comparators
11 |
12 | if (n.ints == 2) {
13 | graph <- "base"
14 | pos <- c(1, 1)
15 | } else {
16 | graph <- "ggplot2"
17 | pos <- TRUE
18 | }
19 | ceef.plot(m, graph = graph)
20 | ```
21 |
22 | The summary is composed of two tables, reporting information for the comparators included on the frontier. It also details the average health effects and costs for the comparators not on the frontier, if any. For the interventions included on the frontier, the slope of the frontier segment connecting the intervention to the previous efficient one and the angle inclination of the segment (with respect to the $x-$axis), measured in radians, are also reported. In particular, the slope can be interpreted as the increase in costs for an additional unit in effectiveness, i.e. the ICER for the comparison against the previous treatment.
23 |
24 | The dominance type for comparators not on the efficiency frontier is reported in the output table. This can be of two types: absolute or extended dominance. An intervention is absolutely dominated if another comparator has both lower costs and greater health benefits, i.e. the ICER for at least one pairwise comparison is negative. Comparators in a situation of extended dominance are not wholly inefficient, but are dominated because a combination of two other interventions will provide more benefits for lower costs.
25 |
--------------------------------------------------------------------------------
/inst/rmarkdown/report/section_EIB.Rmd:
--------------------------------------------------------------------------------
1 |
2 | ## Expected Incremental Benefit
3 |
4 | The following graph shows the _Expected Incremental Benefit_ (EIB), as a function of a grid of values for the willingness to pay $k$ (in this case in the interval `r min(m$k)` - `r max(m$k)`).
5 |
6 | The EIB can be directly linked with the decision rule applied to the ICER. If a willingness to pay value $k^*$ exists in correspondence of which $\mbox{EIB}=0$ this value of $k$ is called the _break-even point_. It corresponds to the maximum uncertainty associated with the decision between the two comparators, with equal expected utilities for the two interventions. In other terms, for two willingness to pay values, one greater and one less than $k^*$, there will be two different optimal decisions. The graph also reports the 95% credible limits around the EIB.
7 |
8 |
9 | ```{r, echo=echo, fig.width=4.6, fig.height=4.6, fig.align=align, warning=FALSE, message=FALSE, comment=NA}
10 | n.ints <- m$n_comparators
11 |
12 | if (n.ints == 2) {
13 | graph <- "base"
14 | pos <- c(1, 1)
15 | } else {
16 | graph <- "ggplot2"
17 | pos <- TRUE
18 | }
19 |
20 | eib.plot(m, graph = graph, pos = pos)
21 | ```
22 |
--------------------------------------------------------------------------------
/inst/rmarkdown/report/section_ceplane.Rmd:
--------------------------------------------------------------------------------
1 |
2 | ## Cost-effectiveness plane
3 |
4 | The following graph shows the _cost-effectiveness plane_. This presents the joint distribution of the population average benefit and cost differential, $(\Delta_e,\Delta_c)$ and can be used to assess the uncertainty underlying the decision-making problem.
5 |
6 | Each point in the graph represents a 'potential future' in terms of expected incremental economic outcomes. The shaded portion of the plane is the _'sustainability area'_. The more points lay in the sustainability area, the more likely that the reference intervention will turn out to be cost-effective, at a given willingness to pay threshold, $k$ (in this case selected at $k=$ `r rmd_params$wtp`).
7 |
8 |
9 | ```{r, echo=echo, fig.width=4.6, fig.height=4.6, fig.align=align, warning=FALSE, message=FALSE, comment=NA}
10 | n.ints <- m$n_comparators
11 |
12 | if (n.ints == 2) {
13 | graph <- "base"
14 | pos <- c(1, 1)
15 | } else {
16 | graph <- "ggplot2"
17 | pos <- TRUE
18 | }
19 | ceplane.plot(m, graph = graph, pos = pos, wtp = rmd_params$wtp)
20 | ```
21 |
--------------------------------------------------------------------------------
/man-roxygen/args-comparison.R:
--------------------------------------------------------------------------------
1 | #' @param comparison Selects the comparator, in case of more than two
2 | #' interventions being analysed. Default as NULL plots all the comparisons
3 | #' together. Any subset of the possible comparisons can be selected (e.g.,
4 | #' `comparison=c(1,3)` or `comparison=2`).
5 |
6 |
--------------------------------------------------------------------------------
/man-roxygen/args-graph.R:
--------------------------------------------------------------------------------
1 | #' @param graph A string used to select the graphical engine to use for
2 | #' plotting. Should (partial-)match the three options `"base"`,
3 | #' `"ggplot2"` or `"plotly"`. Default value is `"base"`.
4 | #' Not all plotting functions have a `"plotly"` implementation yet.
5 |
--------------------------------------------------------------------------------
/man-roxygen/args-he.R:
--------------------------------------------------------------------------------
1 | #' @param he A `bcea` object containing the results of the Bayesian
2 | #' modelling and the economic evaluation.
3 |
--------------------------------------------------------------------------------
/man-roxygen/args-pos.R:
--------------------------------------------------------------------------------
1 | #' @param pos Parameter to set the position of the legend (only relevant for
2 | #' multiple interventions, ie more than 2 interventions being compared).
3 | #' Can be given in form
4 | #' of a string `(bottom|top)(right|left)` for base graphics and
5 | #' `bottom|top|left|right` for ggplot2. It can be a two-elements vector,
6 | #' which specifies the relative position on the x and y axis respectively, or
7 | #' alternatively it can be in form of a logical variable, with `FALSE`
8 | #' indicating to use the default position and `TRUE` to place it on the
9 | #' bottom of the plot.
10 |
11 |
--------------------------------------------------------------------------------
/man/BCEA-deprecated.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/BCEA-deprecated.R, R/plot.mixedAn.R
3 | \name{BCEA-deprecated}
4 | \alias{BCEA-deprecated}
5 | \alias{plot.mixedAn}
6 | \title{Deprecated functions in package \pkg{BCEA}.}
7 | \usage{
8 | plot.mixedAn(x, y.limits=NULL, pos=c(0,1), graph=c("base","ggplot2"),...)
9 | }
10 | \arguments{
11 | \item{x}{An object of class \code{mixedAn}, given as output of the call to
12 | the function \code{\link[=mixedAn]{mixedAn()}}.}
13 |
14 | \item{y.limits}{Range of the y-axis for the graph. The default value is
15 | \code{NULL}, in which case the maximum range between the optimal and the
16 | mixed analysis scenarios is considered.}
17 |
18 | \item{pos}{Parameter to set the position of the legend. Can be given in form
19 | of a string \code{(bottom|top)(right|left)} for base graphics and
20 | \code{bottom|top|left|right} for ggplot2. It can be a two-elements vector,
21 | which specifies the relative position on the x and y axis respectively, or
22 | alternatively it can be in form of a logical variable, with \code{FALSE}
23 | indicating to use the default position and \code{TRUE} to place it on the
24 | bottom of the plot. Default value is \code{c(0,1)}, that is in the topleft
25 | corner inside the plot area.}
26 |
27 | \item{graph}{A string used to select the graphical engine to use for
28 | plotting. Should (partial-)match the two options \code{"base"} or
29 | \code{"ggplot2"}. Default value is \code{"base"}.}
30 |
31 | \item{...}{Arguments to be passed to methods, such as graphical parameters
32 | (see \code{\link[=par]{par()}}).}
33 | }
34 | \value{
35 | \item{evi}{ A ggplot object containing the plot. Returned only if
36 | \code{graph="ggplot2"}. } The function produces a graph showing the
37 | difference between the ''optimal'' version of the EVPI (when only the most
38 | cost-effective intervention is included in the market) and the mixed
39 | strategy one (when more than one intervention is considered in the market).
40 | }
41 | \description{
42 | The functions listed below are deprecated and will be defunct in
43 | the near future. When possible, alternative functions with similar
44 | functionality are also mentioned. Help pages for deprecated functions are
45 | available at \code{help("-deprecated")}.
46 | }
47 | \section{\code{plot.mixedAn}}{
48 |
49 | For \code{plot.mixedAn}, use \code{\link[=evi.plot]{evi.plot()}}.
50 |
51 | Summary plot of the health economic analysis when the mixed analysis is
52 | considered
53 |
54 | Compares the optimal scenario to the mixed case in terms of the EVPI.
55 | }
56 |
57 | \author{
58 | Gianluca Baio, Andrea Berardi
59 | }
60 | \keyword{internal}
61 |
--------------------------------------------------------------------------------
/man/BCEA-package.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/BCEA-package.R
3 | \docType{package}
4 | \name{BCEA-package}
5 | \alias{BCEA}
6 | \alias{BCEA-package}
7 | \title{BCEA: Bayesian Cost Effectiveness Analysis}
8 | \description{
9 | \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}}
10 |
11 | Produces an economic evaluation of a sample of suitable variables of cost and effectiveness / utility for two or more interventions, e.g. from a Bayesian model in the form of MCMC simulations. This package computes the most cost-effective alternative and produces graphical summaries and probabilistic sensitivity analysis, see Baio et al (2017) \doi{10.1007/978-3-319-55718-2}.
12 | }
13 | \seealso{
14 | Useful links:
15 | \itemize{
16 | \item \url{https://gianluca.statistica.it/software/bcea/}
17 | \item \url{https://gianluca.statistica.it/}
18 | \item \url{https://github.com/giabaio/BCEA/}
19 | \item \url{https://n8thangreen.github.io/BCEA/}
20 | \item Report bugs at \url{https://github.com/n8thangreen/BCEA/issues/}
21 | }
22 |
23 | }
24 | \author{
25 | \strong{Maintainer}: Gianluca Baio \email{g.baio@ucl.ac.uk} (\href{https://orcid.org/0000-0003-4314-2570}{ORCID}) [copyright holder]
26 |
27 | Authors:
28 | \itemize{
29 | \item Andrea Berardi \email{a.berardi@ucl.ac.uk} (\href{https://orcid.org/0000-0002-2906-496X}{ORCID})
30 | \item Anna Heath \email{anna.heath@sickkids.ca} (\href{https://orcid.org/0000-0002-7263-4251}{ORCID})
31 | \item Nathan Green \email{n.green@ucl.ac.uk} (\href{https://orcid.org/0000-0003-2745-1736}{ORCID})
32 | }
33 |
34 | }
35 | \keyword{internal}
36 |
--------------------------------------------------------------------------------
/man/CEriskav_plot_graph.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/CEriskav_plot_graph.R
3 | \name{CEriskav_plot_graph}
4 | \alias{CEriskav_plot_graph}
5 | \alias{CEriskav_plot_base}
6 | \alias{CEriskav_plot_ggplot}
7 | \title{Cost-effectiveness Plot Including a Parameter of Risk Aversion}
8 | \usage{
9 | CEriskav_plot_base(he, pos_legend)
10 |
11 | CEriskav_plot_ggplot(he, pos_legend)
12 | }
13 | \arguments{
14 | \item{he}{A \code{bcea} object containing the results of the Bayesian
15 | modelling and the economic evaluation.}
16 |
17 | \item{pos_legend}{Legend position}
18 | }
19 | \description{
20 | Choice of base R, \pkg{ggplot2}.
21 | }
22 |
--------------------------------------------------------------------------------
/man/GrassmannOptim.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/GrassmannOptim.R
3 | \name{GrassmannOptim}
4 | \alias{GrassmannOptim}
5 | \title{GrassmannOptim}
6 | \usage{
7 | GrassmannOptim(
8 | objfun,
9 | W,
10 | sim_anneal = FALSE,
11 | temp_init = 20,
12 | cooling_rate = 2,
13 | max_iter_sa = 100,
14 | eps_conv = 1e-05,
15 | max_iter = 100,
16 | eps_grad = 1e-05,
17 | eps_f = .Machine$double.eps,
18 | verbose = FALSE
19 | )
20 | }
21 | \arguments{
22 | \item{objfun}{objfun}
23 |
24 | \item{W}{W}
25 |
26 | \item{sim_anneal}{sim_anneal}
27 |
28 | \item{temp_init}{temp_init}
29 |
30 | \item{cooling_rate}{cooling_rate}
31 |
32 | \item{max_iter_sa}{max_iter_sa}
33 |
34 | \item{eps_conv}{eps_conv}
35 |
36 | \item{max_iter}{max_iter}
37 |
38 | \item{eps_grad}{eps_grad}
39 |
40 | \item{eps_f}{eps_f}
41 |
42 | \item{verbose}{verbose}
43 | }
44 | \value{
45 | List
46 | }
47 | \description{
48 | This function is taken from the GrassmannOptim package
49 | by Kofi Placid Adragni and Seongho Wu
50 | https://cran.r-project.org/web/packages/GrassmannOptim/index.html
51 | }
52 | \keyword{internal}
53 |
--------------------------------------------------------------------------------
/man/add_contour_quadrants.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/add_contour_quadrants.R
3 | \name{add_contour_quadrants}
4 | \alias{add_contour_quadrants}
5 | \title{Add Contour Quadrants}
6 | \usage{
7 | add_contour_quadrants(he, params)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{params}{List}
14 | }
15 | \value{
16 | Plot side effect
17 | }
18 | \description{
19 | Add Contour Quadrants
20 | }
21 | \keyword{aplot}
22 | \keyword{internal}
23 |
--------------------------------------------------------------------------------
/man/add_contours.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/add_contours.R
3 | \name{add_contours}
4 | \alias{add_contours}
5 | \title{Add Contours to Base R Plot}
6 | \usage{
7 | add_contours(he, params)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{params}{List}
14 | }
15 | \value{
16 | plot side effect
17 | }
18 | \description{
19 | Add Contours to Base R Plot
20 | }
21 | \keyword{aplot}
22 | \keyword{internal}
23 |
--------------------------------------------------------------------------------
/man/best_interv_given_k.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/best_interv_given_k.R
3 | \name{best_interv_given_k}
4 | \alias{best_interv_given_k}
5 | \title{Optimal intervention}
6 | \usage{
7 | best_interv_given_k(eib, ref, comp)
8 | }
9 | \arguments{
10 | \item{eib}{Expected incremental benefit}
11 |
12 | \item{ref}{Reference group number}
13 |
14 | \item{comp}{Comparison group number(s)}
15 | }
16 | \value{
17 | Group index
18 | }
19 | \description{
20 | Select the best option for each value of willingness to pay.
21 | }
22 |
--------------------------------------------------------------------------------
/man/ce_table.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/ce_table.R
3 | \name{ce_table}
4 | \alias{ce_table}
5 | \title{Cost-effectiveness summary statistics table}
6 | \usage{
7 | ce_table(he, wtp = 25000, ...)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{wtp}{Willingness to pay}
14 |
15 | \item{...}{Additional parameters}
16 | }
17 | \description{
18 | As is commonly shown in a journal paper.
19 | }
20 | \examples{
21 | data(Vaccine)
22 |
23 | # Runs the health economic evaluation using BCEA
24 | m <- bcea(
25 | e=eff,
26 | c=cost, # defines the variables of
27 | # effectiveness and cost
28 | ref=2, # selects the 2nd row of (e, c)
29 | # as containing the reference intervention
30 | interventions=treats, # defines the labels to be associated
31 | # with each intervention
32 | Kmax=50000, # maximum value possible for the willingness
33 | # to pay threshold; implies that k is chosen
34 | # in a grid from the interval (0, Kmax)
35 | )
36 | ce_table(m)
37 | }
38 | \keyword{internal}
39 |
--------------------------------------------------------------------------------
/man/ceac_matplot.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/ceac_plot_graph.R
3 | \name{ceac_matplot}
4 | \alias{ceac_matplot}
5 | \title{CEAC Matrix Plot}
6 | \usage{
7 | ceac_matplot(he, pos_legend, graph_params, ceac)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{pos_legend}{Legend position}
14 |
15 | \item{graph_params}{Aesthetic ggplot parameters}
16 |
17 | \item{ceac}{\code{ceac} index in \code{he}}
18 | }
19 | \description{
20 | CEAC plot using \code{matplot} in Base R.
21 | }
22 | \keyword{hplot}
23 | \keyword{internal}
24 |
--------------------------------------------------------------------------------
/man/ceac_plot_graph.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/ceac_plot_graph.R
3 | \name{ceac_plot_graph}
4 | \alias{ceac_plot_graph}
5 | \alias{ceac_plot_base}
6 | \alias{ceac_plot_base.pairwise}
7 | \alias{ceac_plot_base.bcea}
8 | \alias{ceac_plot_ggplot}
9 | \alias{ceac_plot_ggplot.pairwise}
10 | \alias{ceac_plot_ggplot.bcea}
11 | \alias{ceac_ggplot}
12 | \alias{ceac_plot_plotly}
13 | \title{Cost-Effectiveness Acceptability Curve (CEAC) Plot By Graph Device}
14 | \usage{
15 | ceac_plot_base(he, pos_legend, graph_params, ...)
16 |
17 | \method{ceac_plot_base}{pairwise}(he, pos_legend, graph_params, ...)
18 |
19 | \method{ceac_plot_base}{bcea}(he, pos_legend, graph_params, ...)
20 |
21 | ceac_plot_ggplot(he, pos_legend, graph_params, ...)
22 |
23 | \method{ceac_plot_ggplot}{pairwise}(he, pos_legend, graph_params, ...)
24 |
25 | \method{ceac_plot_ggplot}{bcea}(he, pos_legend, graph_params, ...)
26 |
27 | ceac_ggplot(he, pos_legend, graph_params, ceac, ...)
28 |
29 | ceac_plot_plotly(he, pos_legend = "left", graph_params)
30 | }
31 | \arguments{
32 | \item{he}{A \code{bcea} object containing the results of the Bayesian
33 | modelling and the economic evaluation.}
34 |
35 | \item{pos_legend}{Legend position}
36 |
37 | \item{graph_params}{Aesthetic ggplot parameters}
38 |
39 | \item{...}{Additional arguments}
40 |
41 | \item{ceac}{ceac index in \code{he}}
42 | }
43 | \description{
44 | Choice of base R, \pkg{ggplot2} or \pkg{plotly}.
45 | }
46 | \keyword{hplot}
47 | \keyword{internal}
48 |
--------------------------------------------------------------------------------
/man/ceaf.plot.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/ceaf.plot.R
3 | \name{ceaf.plot.pairwise}
4 | \alias{ceaf.plot.pairwise}
5 | \alias{ceaf.plot}
6 | \title{Cost-Effectiveness Acceptability Frontier (CEAF) plot}
7 | \usage{
8 | \method{ceaf.plot}{pairwise}(mce, graph = c("base", "ggplot2"), ...)
9 |
10 | ceaf.plot(mce, ...)
11 | }
12 | \arguments{
13 | \item{mce}{The output of the call to the function \code{\link[=multi.ce]{multi.ce()}}}
14 |
15 | \item{graph}{A string used to select the graphical engine to use for
16 | plotting. Should (partial-) match the two options \code{"base"} or
17 | \code{"ggplot2"}. Default value is \code{"base"}.}
18 |
19 | \item{...}{Additional arguments}
20 | }
21 | \value{
22 | \item{ceaf}{A ggplot object containing the plot. Returned only if
23 | \code{graph="ggplot2"}.}
24 | }
25 | \description{
26 | Produces a plot the Cost-Effectiveness Acceptability Frontier (CEAF)
27 | against the willingness to pay threshold.
28 | }
29 | \examples{
30 |
31 | # See Baio G., Dawid A.P. (2011) for a detailed description of the
32 | # Bayesian model and economic problem
33 |
34 | # Load the processed results of the MCMC simulation model
35 | data(Vaccine)
36 |
37 | # Runs the health economic evaluation using BCEA
38 | m <- bcea(
39 | e=eff,
40 | c=cost, # defines the variables of
41 | # effectiveness and cost
42 | ref=2, # selects the 2nd row of (e, c)
43 | # as containing the reference intervention
44 | interventions=treats, # defines the labels to be associated
45 | # with each intervention
46 | Kmax=50000, # maximum value possible for the willingness
47 | # to pay threshold; implies that k is chosen
48 | # in a grid from the interval (0, Kmax)
49 | plot=FALSE # inhibits graphical output
50 | )
51 |
52 | \donttest{
53 | mce <- multi.ce(m) # uses the results of the economic analysis
54 | }
55 |
56 | \donttest{
57 | ceaf.plot(mce) # plots the CEAF
58 | }
59 |
60 | \donttest{
61 | ceaf.plot(mce, graph = "g") # uses ggplot2
62 | }
63 |
64 | \donttest{
65 | # Use the smoking cessation dataset
66 | data(Smoking)
67 | m <- bcea(eff, cost, ref = 4, intervention = treats, Kmax = 500, plot = FALSE)
68 | mce <- multi.ce(m)
69 | ceaf.plot(mce)
70 | }
71 |
72 | }
73 | \references{
74 | \insertRef{Baio2011}{BCEA}
75 |
76 | \insertRef{Baio2013}{BCEA}
77 | }
78 | \seealso{
79 | \code{\link[=bcea]{bcea()}},
80 | \code{\link[=multi.ce]{multi.ce()}}
81 | }
82 | \author{
83 | Gianluca Baio, Andrea Berardi
84 | }
85 | \keyword{hplot}
86 |
--------------------------------------------------------------------------------
/man/ceef.summary.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/ceef.summary.R
3 | \name{ceef.summary}
4 | \alias{ceef.summary}
5 | \title{Summary table for CEEF}
6 | \usage{
7 | ceef.summary(he, frontier_data, frontier_params, include.ICER = FALSE, ...)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{frontier_data}{Frontier data}
14 |
15 | \item{frontier_params}{Frontier parameters}
16 |
17 | \item{include.ICER}{Should we include the ICER? default: FALSE}
18 |
19 | \item{...}{Additional arguments}
20 | }
21 | \value{
22 | Summary printed to console
23 | }
24 | \description{
25 | Summary table for CEEF
26 | }
27 | \keyword{internal}
28 | \keyword{print}
29 |
--------------------------------------------------------------------------------
/man/ceef_plot_graph.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/ceef_plot_graph.R
3 | \name{ceef_plot_graph}
4 | \alias{ceef_plot_graph}
5 | \alias{ceef_plot_ggplot}
6 | \alias{ceef_plot_base}
7 | \title{Cost-effectiveness Efficiency Frontier Plot By Graph Device}
8 | \usage{
9 | ceef_plot_ggplot(he, frontier_data, frontier_params, ...)
10 |
11 | ceef_plot_base(he, frontier_data, frontier_params)
12 | }
13 | \arguments{
14 | \item{he}{A \code{bcea} object containing the results of the Bayesian
15 | modelling and the economic evaluation.}
16 |
17 | \item{frontier_data}{Frontier data}
18 |
19 | \item{frontier_params}{Frontier parameters}
20 |
21 | \item{...}{Additional arguments}
22 | }
23 | \description{
24 | Choice of base R, \pkg{ggplot2}.
25 | }
26 |
--------------------------------------------------------------------------------
/man/ceplane_geom_params.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/ceplane_geom_params.R
3 | \name{ceplane_geom_params}
4 | \alias{ceplane_geom_params}
5 | \title{Extract Separate Parameter Sets}
6 | \usage{
7 | ceplane_geom_params(...)
8 | }
9 | \arguments{
10 | \item{...}{Additional arguments}
11 | }
12 | \description{
13 | Extract Separate Parameter Sets
14 | }
15 | \keyword{internal}
16 |
--------------------------------------------------------------------------------
/man/ceplane_ggplot_params.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/ceplane_ggplot_params.R
3 | \name{ceplane_ggplot_params}
4 | \alias{ceplane_ggplot_params}
5 | \title{CE-plane ggplot Parameters}
6 | \usage{
7 | ceplane_ggplot_params(he, pos_legend, graph_params, ...)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{pos_legend}{Position of legend}
14 |
15 | \item{graph_params}{Other graphical parameters}
16 |
17 | \item{...}{Additional arguments}
18 | }
19 | \description{
20 | CE-plane ggplot Parameters
21 | }
22 | \keyword{internal}
23 |
--------------------------------------------------------------------------------
/man/comp_names_from_.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{comp_names_from_}
4 | \alias{comp_names_from_}
5 | \title{Comparison Names From}
6 | \usage{
7 | comp_names_from_(df_ce)
8 | }
9 | \arguments{
10 | \item{df_ce}{Cost-effectiveness dataframe}
11 | }
12 | \description{
13 | Comparison Names From
14 | }
15 | \keyword{internal}
16 |
--------------------------------------------------------------------------------
/man/compute_CEAC.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_CEAC}
4 | \alias{compute_CEAC}
5 | \title{Compute Cost-Effectiveness Acceptability Curve}
6 | \usage{
7 | compute_CEAC(ib)
8 | }
9 | \arguments{
10 | \item{ib}{Incremental benefit}
11 | }
12 | \value{
13 | Array with dimensions (interv x k)
14 | }
15 | \description{
16 | Compute Cost-Effectiveness Acceptability Curve
17 | }
18 | \seealso{
19 | \code{\link[=ceac.plot]{ceac.plot()}}
20 | }
21 |
--------------------------------------------------------------------------------
/man/compute_EIB.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_EIB}
4 | \alias{compute_EIB}
5 | \title{Compute Expected Incremental Benefit}
6 | \usage{
7 | compute_EIB(ib)
8 | }
9 | \arguments{
10 | \item{ib}{Incremental benefit}
11 | }
12 | \value{
13 | Array with dimensions (interv x k)
14 | }
15 | \description{
16 | A summary measure useful to assess the potential changes in the decision
17 | under different scenarios.
18 | }
19 | \details{
20 | When considering a pairwise comparison
21 | (e.g. in the simple case of a reference intervention \eqn{t = 1} and a comparator,
22 | such as the status quo, \eqn{t = 0}), it is defined as the difference between the
23 | expected utilities of the two alternatives:
24 |
25 | \deqn{eib := \mbox{E}[u(e,c;1)] - \mbox{E}[u(e,c;0)] = \mathcal{U}^1 - \mathcal{U}^0.}
26 |
27 | Analysis of the expected incremental benefit describes how the decision changes
28 | for different values of the threshold. The EIB marginalises out the uncertainty,
29 | and does not incorporate and describe explicitly the uncertainty in the outcomes.
30 | To overcome this problem the tool of choice is the CEAC.
31 | }
32 | \seealso{
33 | \code{\link[=ceac.plot]{ceac.plot()}}, \code{\link[=compute_CEAC]{compute_CEAC()}}, \code{\link[=compute_IB]{compute_IB()}}
34 | }
35 |
--------------------------------------------------------------------------------
/man/compute_EVI.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_EVI}
4 | \alias{compute_EVI}
5 | \title{Compute Expected Value of Information}
6 | \usage{
7 | compute_EVI(ol)
8 | }
9 | \arguments{
10 | \item{ol}{Opportunity loss}
11 | }
12 | \value{
13 | EVI
14 | }
15 | \description{
16 | Compute Expected Value of Information
17 | }
18 |
--------------------------------------------------------------------------------
/man/compute_IB.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_IB}
4 | \alias{compute_IB}
5 | \title{Compute Incremental Benefit}
6 | \usage{
7 | compute_IB(df_ce, k)
8 | }
9 | \arguments{
10 | \item{df_ce}{Dataframe of cost and effectiveness deltas}
11 |
12 | \item{k}{Vector of willingness to pay values}
13 | }
14 | \value{
15 | Array with dimensions (k x sim x ints)
16 | }
17 | \description{
18 | Sample of incremental net monetary benefit for each
19 | willingness-to-pay threshold, \eqn{k}, and comparator.
20 | }
21 | \details{
22 | Defined as:
23 |
24 | \deqn{IB = u(e,c; 1) - u(e,c; 0).}
25 |
26 | If the net benefit function is used as utility function,
27 | the definition can be re-written as
28 |
29 | \deqn{IB = k\cdot\Delta_e - \Delta_c.}
30 | }
31 | \seealso{
32 | \code{\link[=compute_EIB]{compute_EIB()}}
33 | }
34 |
--------------------------------------------------------------------------------
/man/compute_ICER.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_ICER}
4 | \alias{compute_ICER}
5 | \title{Compute Incremental Cost-Effectiveness Ratio}
6 | \usage{
7 | compute_ICER(df_ce)
8 | }
9 | \arguments{
10 | \item{df_ce}{Cost-effectiveness dataframe}
11 | }
12 | \value{
13 | ICER for all comparisons
14 | }
15 | \description{
16 | Defined as
17 | }
18 | \details{
19 | \deqn{ICER = \Delta_c/\Delta_e}
20 | }
21 |
--------------------------------------------------------------------------------
/man/compute_U.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_U}
4 | \alias{compute_U}
5 | \title{Compute U Statistic}
6 | \usage{
7 | compute_U(df_ce, k)
8 | }
9 | \arguments{
10 | \item{df_ce}{Cost-effectiveness dataframe}
11 |
12 | \item{k}{Willingness to pay vector}
13 | }
14 | \value{
15 | Array with dimensions (sim x k x ints)
16 | }
17 | \description{
18 | Sample of net (monetary) benefit for each
19 | willingness-to-pay threshold and intervention.
20 | }
21 |
--------------------------------------------------------------------------------
/man/compute_Ubar.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_Ubar}
4 | \alias{compute_Ubar}
5 | \title{Compute NB for mixture of interventions}
6 | \usage{
7 | compute_Ubar(he, value)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{value}{Mixture weights}
14 | }
15 | \description{
16 | Compute NB for mixture of interventions
17 | }
18 |
--------------------------------------------------------------------------------
/man/compute_Ustar.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_Ustar}
4 | \alias{compute_Ustar}
5 | \title{Compute Ustar Statistic}
6 | \usage{
7 | compute_Ustar(U)
8 | }
9 | \arguments{
10 | \item{U}{Net monetary benefit (sim x k x intervs)}
11 | }
12 | \value{
13 | Array with dimensions (sim x k)
14 | }
15 | \description{
16 | The maximum utility value among the comparators, indicating which
17 | intervention produced the most benefits at each simulation.
18 | }
19 |
--------------------------------------------------------------------------------
/man/compute_ceaf.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_ceaf}
4 | \alias{compute_ceaf}
5 | \title{Compute Cost-Effectiveness Acceptability Frontier}
6 | \usage{
7 | compute_ceaf(p_best_interv)
8 | }
9 | \arguments{
10 | \item{p_best_interv}{Probability of being best intervention}
11 | }
12 | \description{
13 | Compute Cost-Effectiveness Acceptability Frontier
14 | }
15 |
--------------------------------------------------------------------------------
/man/compute_eib_cri.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_eib_cri.R
3 | \name{compute_eib_cri}
4 | \alias{compute_eib_cri}
5 | \title{Calculate Credible Intervals}
6 | \usage{
7 | compute_eib_cri(he, alpha_cri = 0.05, cri.quantile = TRUE)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{alpha_cri}{Significance level, 0 - 1}
14 |
15 | \item{cri.quantile}{Credible interval quantile?; logical}
16 | }
17 | \value{
18 | cri
19 | }
20 | \description{
21 | For expected incremental benefit plot.
22 | }
23 |
--------------------------------------------------------------------------------
/man/compute_kstar.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_kstar}
4 | \alias{compute_kstar}
5 | \title{Compute k^*}
6 | \usage{
7 | compute_kstar(k, best, ref)
8 | }
9 | \arguments{
10 | \item{k}{Willingness-to-pay grid approximation of the budget willing to invest (vector)}
11 |
12 | \item{best}{Best intervention for each \code{k} (int)}
13 |
14 | \item{ref}{Reference intervention (int)}
15 | }
16 | \value{
17 | integer representing intervention
18 | }
19 | \description{
20 | Find willingness-to-pay threshold when optimal decision changes.
21 | }
22 | \details{
23 | \deqn{k^* := \min\{k : IB < 0 \}}
24 |
25 | The value of the break-even point corresponds to the ICER and quantifies
26 | the point at which the decision-maker is indifferent between the two options.
27 | }
28 | \seealso{
29 | \code{\link[=ceac.plot]{ceac.plot()}}
30 | }
31 |
--------------------------------------------------------------------------------
/man/compute_ol.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_ol}
4 | \alias{compute_ol}
5 | \title{Compute Opportunity Loss}
6 | \usage{
7 | compute_ol(Ustar, U, best)
8 | }
9 | \arguments{
10 | \item{Ustar}{Maximum utility value (sim x k)}
11 |
12 | \item{U}{Net monetary benefit (sim x k x interv)}
13 |
14 | \item{best}{Best intervention for given willingness-to-pay (k)}
15 | }
16 | \value{
17 | Array with dimensions (sim x k)
18 | }
19 | \description{
20 | The difference between the maximum utility computed for the current
21 | parameter configuration (e.g. at the current simulation) \eqn{U^*} and the current
22 | utility of the intervention associated with the maximum utility overall.
23 | }
24 | \details{
25 | In mathematical notation,
26 | \deqn{\textrm{OL}(\theta) := U^*(\theta) - U(\theta^\tau)}
27 |
28 | where \eqn{\tau} is the intervention associated with the overall maximum utility
29 | and \eqn{U^*(\theta)} is the maximum utility value among the comparators in the given simulation.
30 | The opportunity loss is a non-negative quantity, since \eqn{U(\theta^\tau)\leq U^*(\theta)}.
31 |
32 | In all simulations where the intervention is more
33 | cost-effective (i.e. when incremental benefit is positive), then \eqn{\textrm{OL}(\theta) = 0}
34 | as there would be no opportunity loss, if the parameter configuration were the
35 | one obtained in the current simulation.
36 | }
37 | \seealso{
38 | \code{\link[=compute_vi]{compute_vi()}}
39 | }
40 |
--------------------------------------------------------------------------------
/man/compute_p_best_interv.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_p_best_interv}
4 | \alias{compute_p_best_interv}
5 | \title{Compute Probability Best Intervention}
6 | \usage{
7 | compute_p_best_interv(he)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 | }
13 | \description{
14 | Compute Probability Best Intervention
15 | }
16 |
--------------------------------------------------------------------------------
/man/compute_vi.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compute_xxx.R
3 | \name{compute_vi}
4 | \alias{compute_vi}
5 | \title{Compute Value of Information}
6 | \usage{
7 | compute_vi(Ustar, U)
8 | }
9 | \arguments{
10 | \item{Ustar}{Maximum utility value (sim x k)}
11 |
12 | \item{U}{Net monetary benefit (sim x k x interv)}
13 | }
14 | \value{
15 | Array with dimensions (sim x k)
16 | }
17 | \description{
18 | The difference between the maximum utility computed for the current
19 | parameter configuration \eqn{U^*} and the utility of the intervention which
20 | is associated with the maximum utility overall.
21 | }
22 | \details{
23 | The value of obtaining additional information on the parameter \eqn{\theta}
24 | to reduce the uncertainty in the decisional process.
25 | It is defined as:
26 |
27 | \deqn{\textrm{VI}(\theta) := U^*(\theta) - \mathcal{U}^*}
28 |
29 | with \eqn{U^*(\theta)} the maximum utility value for the given simulation
30 | among all comparators and \eqn{\mathcal{U}^*(\theta)} the expected utility
31 | gained by the adoption of the cost-effective intervention.
32 | }
33 | \seealso{
34 | \code{\link[=compute_ol]{compute_ol()}}
35 | }
36 |
--------------------------------------------------------------------------------
/man/contour_ggplot_params.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/contour_ggplot_params.R
3 | \name{contour_ggplot_params}
4 | \alias{contour_ggplot_params}
5 | \title{Contour ggplot Parameters}
6 | \usage{
7 | contour_ggplot_params(he, graph_params, ...)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{graph_params}{Other graphical parameters}
14 |
15 | \item{...}{Additional arguments}
16 | }
17 | \description{
18 | Contour ggplot Parameters
19 | }
20 | \keyword{internal}
21 |
--------------------------------------------------------------------------------
/man/contour_graph.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/contour_graph.R
3 | \name{contour_graph}
4 | \alias{contour_graph}
5 | \alias{contour_base}
6 | \alias{contour_ggplot}
7 | \title{Contour Cost-Effectiveness Plane}
8 | \usage{
9 | contour_base(he, pos_legend, graph_params, ...)
10 |
11 | contour_ggplot(he, pos_legend, graph_params, ...)
12 | }
13 | \arguments{
14 | \item{he}{A \code{bcea} object containing the results of the Bayesian
15 | modelling and the economic evaluation.}
16 |
17 | \item{pos_legend}{Legend position}
18 |
19 | \item{graph_params}{Plot parameters; list}
20 |
21 | \item{...}{Additional arguments}
22 | }
23 | \description{
24 | Choice of base R, \pkg{ggplot2}.
25 | }
26 | \seealso{
27 | \code{\link[=contour]{contour()}}
28 | }
29 |
--------------------------------------------------------------------------------
/man/convert_pts_to_mm.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/convert_pts_to_mm.R
3 | \name{convert_pts_to_mm}
4 | \alias{convert_pts_to_mm}
5 | \title{Use from Base R to ggplot}
6 | \usage{
7 | convert_pts_to_mm(x)
8 | }
9 | \arguments{
10 | \item{x}{points}
11 | }
12 | \description{
13 | Use from Base R to ggplot
14 | }
15 | \keyword{internal}
16 |
--------------------------------------------------------------------------------
/man/createInputs.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/CreateInputs.R
3 | \name{createInputs.default}
4 | \alias{createInputs.default}
5 | \alias{createInputs}
6 | \alias{createInputs.rjags}
7 | \alias{createInputs.bugs}
8 | \alias{createInputs.stanfit}
9 | \alias{createInputs.data.frame}
10 | \alias{createInputs.numeric}
11 | \title{Create Inputs for EVPI Calculation}
12 | \usage{
13 | \method{createInputs}{default}(inputs, print_is_linear_comb = TRUE)
14 |
15 | createInputs(inputs, print_is_linear_comb = TRUE)
16 |
17 | \method{createInputs}{rjags}(inputs, print_is_linear_comb = TRUE)
18 |
19 | \method{createInputs}{bugs}(inputs, print_is_linear_comb = TRUE)
20 |
21 | \method{createInputs}{stanfit}(inputs, print_is_linear_comb = TRUE)
22 |
23 | \method{createInputs}{data.frame}(inputs, print_is_linear_comb = TRUE)
24 |
25 | \method{createInputs}{numeric}(inputs, print_is_linear_comb = TRUE)
26 | }
27 | \arguments{
28 | \item{inputs}{A \code{rjags}, \code{bugs} or \code{stanfit} object, containing
29 | the results of a call to either JAGS, (using \code{R2jags}), BUGS
30 | (using \code{R2WinBUGS}, or Stan (using \code{rstan}).}
31 |
32 | \item{print_is_linear_comb}{Logical indicator. If set to \code{TRUE} (default)
33 | then prints the output of the procedure trying to assess whether there are
34 | some parameters that are a linear combination of others (in which case
35 | they are removed).}
36 | }
37 | \value{
38 | \item{mat}{Data.frame containing all the simulations
39 | for all the monitored parameters}
40 | \item{parameters}{Character vectors of the names
41 | of all the monitored parameters}
42 | }
43 | \description{
44 | Creates an object containing the matrix with the parameters simulated using
45 | the MCMC procedure (using JAGS, BUGS or Stan) and a vector of parameters
46 | (strings) that can be used to perform the expected value of partial
47 | information analysis. In the process, \code{createInputs} also checks for
48 | linear dependency among columns of the PSA samples or columns having
49 | constant values and removes them to only leave the fundamental parameters
50 | (to run VoI analysis). This also deals with simulations stored in a
51 | \code{.csv} or \code{.txt} file (e.g. as obtained using bootstrapping from a
52 | non-Bayesian model).
53 | }
54 | \seealso{
55 | \code{\link[=bcea]{bcea()}},
56 | \code{\link[=evppi]{evppi()}}
57 | }
58 | \author{
59 | Gianluca Baio, Anna Heath and Mark Strong
60 | }
61 |
--------------------------------------------------------------------------------
/man/diag.evppi.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/diag.evppi.R
3 | \name{diag.evppi}
4 | \alias{diag.evppi}
5 | \title{Diagnostic Plots For The Results Of The EVPPI}
6 | \usage{
7 | diag.evppi(evppi, he, plot_type = c("residuals", "qqplot"), interv = 1)
8 | }
9 | \arguments{
10 | \item{evppi}{A \code{evppi} object obtained by running the function \code{evppi}
11 | on a \code{bcea} model.}
12 |
13 | \item{he}{A \code{bcea} object containing the results of the Bayesian
14 | modelling and the economic evaluation.}
15 |
16 | \item{plot_type}{The type of diagnostics to be performed. It can be the 'residual
17 | plot' (\code{residuals}) or the Q-Q (quantile-quantile) plot (\code{qqplot}).}
18 |
19 | \item{interv}{Specifies the interventions for which diagnostic tests should be
20 | performed (if there are many options being compared)}
21 | }
22 | \value{
23 | Plot
24 | }
25 | \description{
26 | The function produces either a residual plot comparing the fitted
27 | values from the INLA-SPDE Gaussian Process regression to the residuals.
28 | This is a scatter plot of residuals on the y axis and fitted values (estimated
29 | responses) on the x axis. The plot is used to detect non-linearity, unequal
30 | error variances, and outliers. A well-behaved residual plot supporting the
31 | appropriateness of the simple linear regression model has the following
32 | characteristics:
33 | \enumerate{
34 | \item The residuals bounce randomly around the 0 line. This suggests that
35 | the assumption that the relationship is linear is reasonable.
36 | \item The residuals roughly form a horizontal band around the 0 line. This
37 | suggests that the variances of the error terms are equal.
38 | \item None of the residual stands out from the basic random pattern of residuals.
39 | This suggests that there are no outliers.
40 | }
41 | }
42 | \details{
43 | The second possible diagnostic is the Q-Q plot for the fitted value. This is a
44 | graphical method for comparing the fitted values distributions with the
45 | assumed underlying normal distribution by plotting their quantiles against
46 | each other. First, the set of intervals for the quantiles is chosen. A point
47 | (x,y) on the plot corresponds to one of the quantiles of the second
48 | distribution (y-coordinate) plotted against the same quantile of the first
49 | distribution (x-coordinate). If the two distributions being compared are
50 | identical, the Q-Q plot follows the 45 degrees line.
51 | }
52 | \references{
53 | \insertRef{Baio2011}{BCEA}
54 |
55 | \insertRef{Baio2013}{BCEA}
56 | }
57 | \seealso{
58 | \code{\link[=bcea]{bcea()}}, \code{\link[=evppi]{evppi()}}
59 | }
60 | \author{
61 | Gianluca Baio, Anna Heath
62 | }
63 | \keyword{hplot}
64 | \keyword{internal}
65 |
--------------------------------------------------------------------------------
/man/eib_params_base.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/eib_params_base.R
3 | \name{eib_params_base}
4 | \alias{eib_params_base}
5 | \title{EIB parameters specific to base R plot}
6 | \usage{
7 | eib_params_base(he, graph_params, cri_params)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{graph_params}{Type of plot device}
14 |
15 | \item{cri_params}{Credible interval parameters}
16 | }
17 | \value{
18 | list
19 | }
20 | \description{
21 | EIB parameters specific to base R plot
22 | }
23 | \keyword{internal}
24 |
--------------------------------------------------------------------------------
/man/eib_params_cri.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/eib_params_cri.R
3 | \name{eib_params_cri}
4 | \alias{eib_params_cri}
5 | \title{EIB Parameters CrI}
6 | \usage{
7 | eib_params_cri(he, graph_params)
8 | }
9 | \description{
10 | EIB Parameters CrI
11 | }
12 | \keyword{aplot}
13 | \keyword{internal}
14 |
--------------------------------------------------------------------------------
/man/eib_plot_graph.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/eib_plot_graph.R
3 | \name{eib_plot_graph}
4 | \alias{eib_plot_graph}
5 | \alias{eib_plot_base}
6 | \alias{eib_plot_ggplot}
7 | \alias{eib_plot_plotly}
8 | \title{Expected Incremental Benefit Plot By Graph Device}
9 | \usage{
10 | eib_plot_base(he, graph_params, ...)
11 |
12 | eib_plot_ggplot(he, graph_params, ...)
13 |
14 | eib_plot_plotly(he, graph_params, ...)
15 | }
16 | \arguments{
17 | \item{he}{A \code{bcea} object containing the results of the Bayesian
18 | modelling and the economic evaluation.}
19 |
20 | \item{graph_params}{Graph parameters}
21 |
22 | \item{...}{Additional parameters}
23 | }
24 | \description{
25 | Choice of base R, ggplot2 or plotly.
26 | }
27 |
--------------------------------------------------------------------------------
/man/evi_plot_graph.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/evi_plot_graph.R
3 | \name{evi_plot_graph}
4 | \alias{evi_plot_graph}
5 | \alias{evi_plot_base}
6 | \alias{evi_plot_ggplot}
7 | \alias{evi_plot_plotly}
8 | \title{Expected Value of Information Plot By Graph Device}
9 | \usage{
10 | evi_plot_base(he, data.psa, plot_aes, plot_annotations)
11 |
12 | evi_plot_ggplot(he, data.psa, plot_aes, plot_annotations)
13 |
14 | evi_plot_plotly(data.psa, plot_aes, plot_annotations)
15 | }
16 | \arguments{
17 | \item{he}{A \code{bcea} object containing the results of the Bayesian
18 | modelling and the economic evaluation.}
19 |
20 | \item{data.psa}{Data}
21 |
22 | \item{plot_aes}{Aesthetic parameters}
23 |
24 | \item{plot_annotations}{Plot parameters}
25 | }
26 | \description{
27 | Choice of base R, \pkg{ggplot2} or \pkg{plotly}.
28 | }
29 |
--------------------------------------------------------------------------------
/man/evppi_plot_graph.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/evppi_plot_base.R, R/evppi_plot_ggplot.R
3 | \name{evppi_plot_graph}
4 | \alias{evppi_plot_graph}
5 | \alias{evppi_plot_base}
6 | \alias{evppi_plot_ggplot}
7 | \title{Plot Expected Value of Partial Information With Respect to a
8 | Set of Parameters}
9 | \usage{
10 | evppi_plot_base(evppi_obj, pos_legend, col = NULL, annot = FALSE)
11 |
12 | evppi_plot_ggplot(evppi_obj, pos_legend = c(0, 0.8), col = c(1, 1), ...)
13 | }
14 | \arguments{
15 | \item{evppi_obj}{Object of class evppi}
16 |
17 | \item{pos_legend}{Position of legend}
18 |
19 | \item{col}{Colour}
20 |
21 | \item{annot}{Annotate EVPPI curve with parameter names}
22 |
23 | \item{...}{Additional arguments}
24 | }
25 | \description{
26 | Base R and \pkg{ggplot2} versions.
27 | }
28 |
--------------------------------------------------------------------------------
/man/evppi_qq_plot.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/diag.evppi.R
3 | \name{evppi_qq_plot}
4 | \alias{evppi_qq_plot}
5 | \title{Q-Q Plot}
6 | \usage{
7 | evppi_qq_plot(evppi, he, interv)
8 | }
9 | \description{
10 | Q-Q Plot
11 | }
12 | \keyword{hplot}
13 | \keyword{internal}
14 |
--------------------------------------------------------------------------------
/man/evppi_residual_plot.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/diag.evppi.R
3 | \name{evppi_residual_plot}
4 | \alias{evppi_residual_plot}
5 | \title{Residual Plot}
6 | \usage{
7 | evppi_residual_plot(evppi, he, interv)
8 | }
9 | \description{
10 | Residual Plot
11 | }
12 | \keyword{hplot}
13 | \keyword{internal}
14 |
--------------------------------------------------------------------------------
/man/figures/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/man/figures/logo.png
--------------------------------------------------------------------------------
/man/geom_cri.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/geom_cri.R
3 | \name{geom_cri}
4 | \alias{geom_cri}
5 | \title{Credible interval ggplot geom}
6 | \usage{
7 | geom_cri(plot.cri = TRUE, params = NA)
8 | }
9 | \arguments{
10 | \item{plot.cri}{Should we plot CrI? Logical}
11 |
12 | \item{params}{Plot parameters including data}
13 | }
14 | \description{
15 | Credible interval ggplot geom
16 | }
17 | \keyword{aplot}
18 | \keyword{internal}
19 |
--------------------------------------------------------------------------------
/man/geom_quad_txt.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/add_contour_quadrants.R
3 | \name{geom_quad_txt}
4 | \alias{geom_quad_txt}
5 | \title{Geom Quadrant Text}
6 | \usage{
7 | geom_quad_txt(he, graph_params)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{graph_params}{Plot parameters; list}
14 | }
15 | \description{
16 | Geom Quadrant Text
17 | }
18 | \keyword{aplot}
19 | \keyword{internal}
20 |
--------------------------------------------------------------------------------
/man/get_fitted_.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/evppi.default.R
3 | \name{get_fitted_}
4 | \alias{get_fitted_}
5 | \title{Get fitted values from evppi object}
6 | \usage{
7 | get_fitted_(val, voi_methods, voi_models)
8 | }
9 | \value{
10 | matrix
11 | }
12 | \description{
13 | Get fitted values from evppi object
14 | }
15 | \keyword{internal}
16 |
--------------------------------------------------------------------------------
/man/ib.plot.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/ib.plot.R
3 | \name{ib.plot.bcea}
4 | \alias{ib.plot.bcea}
5 | \alias{ib.plot}
6 | \title{Incremental Benefit (IB) Distribution Plot}
7 | \usage{
8 | \method{ib.plot}{bcea}(
9 | he,
10 | comparison = NULL,
11 | wtp = 25000,
12 | bw = "bcv",
13 | n = 512,
14 | xlim = NULL,
15 | graph = c("base", "ggplot2"),
16 | ...
17 | )
18 |
19 | ib.plot(he, ...)
20 | }
21 | \arguments{
22 | \item{he}{A \code{bcea} object containing the results of the Bayesian
23 | modelling and the economic evaluation.}
24 |
25 | \item{comparison}{In the case of multiple interventions, specifies the one
26 | to be used in comparison with the reference. Default value of \code{NULL}
27 | forces R to consider the first non-reference intervention as the comparator.
28 | Controls which comparator is used when more than 2 interventions are present}
29 |
30 | \item{wtp}{The value of the willingness to pay threshold. Default value at
31 | \code{25000}.}
32 |
33 | \item{bw}{Identifies the smoothing bandwidth used to construct the kernel
34 | estimation of the IB density.}
35 |
36 | \item{n}{The number of equally spaced points at which the density is to be
37 | estimated.}
38 |
39 | \item{xlim}{The limits of the plot on the x-axis.}
40 |
41 | \item{graph}{A string used to select the graphical engine to use for
42 | plotting. Should (partial-) match the two options \code{"base"} or
43 | \code{"ggplot2"}. Default value is \code{"base"}.}
44 |
45 | \item{...}{Additional arguments}
46 | }
47 | \value{
48 | \item{ib}{ A ggplot object containing the requested plot. Returned
49 | only if \code{graph="ggplot2"}. } The function produces a plot of the
50 | distribution of the Incremental Benefit for a given value of the willingness
51 | to pay parameter. The dashed area indicates the positive part of the
52 | distribution (i.e. when the reference is more cost-effective than the
53 | comparator).
54 | }
55 | \description{
56 | Plots the distribution of the Incremental Benefit (IB) for a given value of
57 | the willingness to pay threshold.
58 | }
59 | \examples{
60 | data("Vaccine")
61 | he <- BCEA::bcea(eff, cost)
62 | ib.plot(he)
63 |
64 | }
65 | \references{
66 | \insertRef{Baio2011}{BCEA}
67 |
68 | \insertRef{Baio2013}{BCEA}
69 | }
70 | \seealso{
71 | \code{\link[=bcea]{bcea()}},
72 | \code{\link[=ceplane.plot]{ceplane.plot()}}
73 | }
74 | \author{
75 | Gianluca Baio, Andrea Berardi
76 | }
77 | \keyword{hplot}
78 |
--------------------------------------------------------------------------------
/man/ib_plot_graph.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/ib_plot_base.R, R/ib_plot_ggplot.R
3 | \name{ib_plot_base}
4 | \alias{ib_plot_base}
5 | \alias{ib_plot_graph}
6 | \alias{ib_plot_ggplot}
7 | \title{IB plot base R version}
8 | \usage{
9 | ib_plot_base(he, comparison, wtp, bw, n, xlim)
10 |
11 | ib_plot_ggplot(he, comparison, wtp, bw, n, xlim)
12 | }
13 | \arguments{
14 | \item{he}{A \code{bcea} object containing the results of the Bayesian
15 | modelling and the economic evaluation.}
16 |
17 | \item{comparison}{Comparison intervention}
18 |
19 | \item{wtp}{Willingness to pay}
20 |
21 | \item{bw}{band width}
22 |
23 | \item{n}{Number}
24 |
25 | \item{xlim}{x-axis limits}
26 | }
27 | \description{
28 | Choice of base R, ggplot2
29 | }
30 |
--------------------------------------------------------------------------------
/man/info_rank_graph.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/info_rank_graph.R
3 | \name{info_rank_graph}
4 | \alias{info_rank_graph}
5 | \alias{info_rank_base}
6 | \alias{info_rank_ggplot}
7 | \alias{info_rank_plotly}
8 | \title{Info Rank Plot By Graph Device}
9 | \usage{
10 | info_rank_base(he, params)
11 |
12 | info_rank_ggplot(he, params)
13 |
14 | info_rank_plotly(params)
15 | }
16 | \arguments{
17 | \item{he}{A \code{bcea} object containing the results of the Bayesian
18 | modelling and the economic evaluation.}
19 |
20 | \item{params}{Graph Parameters including data}
21 | }
22 | \description{
23 | Choice of base R, \pkg{ggplot2} and \pkg{plotly}.
24 | }
25 |
--------------------------------------------------------------------------------
/man/inforank_params.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/inforank_params.R
3 | \name{inforank_params}
4 | \alias{inforank_params}
5 | \title{Prepare Info Rank plot parameters}
6 | \usage{
7 | inforank_params(he, inp, wtp = NULL, rel, howManyPars, extra_args)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{inp}{Inputs}
14 |
15 | \item{wtp}{Willingness to pay}
16 |
17 | \item{rel}{Relative size}
18 |
19 | \item{howManyPars}{How mnay parameters to use?}
20 |
21 | \item{extra_args}{Additional arguments}
22 | }
23 | \description{
24 | Prepare Info Rank plot parameters
25 | }
26 | \keyword{internal}
27 |
--------------------------------------------------------------------------------
/man/is.bcea.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/base_methods.R
3 | \name{is.bcea}
4 | \alias{is.bcea}
5 | \title{Check bcea Class}
6 | \usage{
7 | is.bcea(he)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 | }
13 | \value{
14 | \code{is.bcea} returns TRUE or FALSE depending on whether its argument
15 | is a bcea class object.
16 | }
17 | \description{
18 | Check bcea Class
19 | }
20 |
--------------------------------------------------------------------------------
/man/is.rel.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/misc_helpers.R
3 | \name{is.rel}
4 | \alias{is.rel}
5 | \title{Reports whether x is a rel object
6 | Copied from ggplot2}
7 | \usage{
8 | is.rel(x)
9 | }
10 | \arguments{
11 | \item{x}{An object to test}
12 | }
13 | \description{
14 | Reports whether x is a rel object
15 | Copied from ggplot2
16 | }
17 | \keyword{internal}
18 |
--------------------------------------------------------------------------------
/man/kstar_vlines.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/kstar_vlines.R
3 | \name{kstar_vlines}
4 | \alias{kstar_vlines}
5 | \title{Prepare K-star vertical lines}
6 | \usage{
7 | kstar_vlines(he, plot_params)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{plot_params}{Plots parameters}
14 | }
15 | \description{
16 | Prepare K-star vertical lines
17 | }
18 | \keyword{internal}
19 |
--------------------------------------------------------------------------------
/man/line_labels.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/line_labels.R
3 | \name{line_labels}
4 | \alias{line_labels}
5 | \alias{line_labels.default}
6 | \alias{line_labels.pairwise}
7 | \title{Create Labels for Plot}
8 | \usage{
9 | line_labels(he, ...)
10 |
11 | \method{line_labels}{default}(he, ref_first = TRUE, ...)
12 |
13 | \method{line_labels}{pairwise}(he, ...)
14 | }
15 | \arguments{
16 | \item{he}{A \code{bcea} object containing the results of the Bayesian
17 | modelling and the economic evaluation.}
18 |
19 | \item{...}{Additional arguments}
20 | }
21 | \description{
22 | Create Labels for Plot
23 |
24 | Swapped labels so that reference is second
25 | }
26 | \keyword{internal}
27 |
--------------------------------------------------------------------------------
/man/loo_rank.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/CreateInputs.R
3 | \name{loo_rank}
4 | \alias{loo_rank}
5 | \title{Leave-one-out ranking}
6 | \usage{
7 | loo_rank(params)
8 | }
9 | \arguments{
10 | \item{params}{Parameters}
11 | }
12 | \description{
13 | Leave-one-out ranking
14 | }
15 | \keyword{internal}
16 |
--------------------------------------------------------------------------------
/man/make.report.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/make.report.R
3 | \name{make.report}
4 | \alias{make.report}
5 | \title{Make Report}
6 | \usage{
7 | make.report(he, evppi = NULL, ext = "pdf", echo = FALSE, ...)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{evppi}{An object obtained as output to a call to \code{evppi}
14 | (default is NULL, so not essential to producing the report).}
15 |
16 | \item{ext}{A string of text to indicate the extension of the
17 | resulting output file. Possible options are \code{"pdf"}, \code{"docx"}.
18 | This requires the use of pandoc, knitr and rmarkdown.}
19 |
20 | \item{echo}{A string (default to \code{FALSE}) to instruct whether
21 | the report should also include the \code{BCEA} commands used to
22 | produce the analyses. If the optional argument \code{echo} is set
23 | to \code{TRUE} (default = \code{FALSE}), then the commands are also
24 | printed.}
25 |
26 | \item{...}{Additional parameters. For example, the user can specify the
27 | value of the willingness to pay \code{wtp}, which is used in some of
28 | the resulting analyses (default at the break even point).
29 | Another additional parameter that the user can specify is the name
30 | of the file to which the report should be written. This can be done
31 | by simply passing the optional argument \code{filename="NAME"}.
32 | The user can also specify an object including the PSA simulations
33 | for all the relevant model parameters. If this is passed to the
34 | function (in the object \code{psa_sims}),
35 | then \code{make.report} will automatically construct an "Info-rank
36 | plot", which is a probabilistic form of tornado plot, based on the
37 | Expected Value of Partial Information. The user can also specify
38 | the optional argument \code{show.tab} (default=FALSE); if set to
39 | \code{TRUE}, then a table with the values of the Info-rank is also
40 | shown.}
41 | }
42 | \description{
43 | Constructs the automated report from the output of the BCEA.
44 | }
45 | \examples{
46 |
47 | \dontrun{
48 | data(Vaccine, package = "BCEA")
49 | m <- bcea(eff, cost, ref = 2)
50 | make.report(m)
51 | }
52 |
53 | }
54 | \references{
55 | \insertRef{Baio2011}{BCEA}
56 |
57 | \insertRef{Baio2013}{BCEA}
58 | }
59 | \seealso{
60 | \code{\link[=bcea]{bcea()}}
61 | }
62 | \author{
63 | Gianluca Baio
64 | }
65 |
--------------------------------------------------------------------------------
/man/make_legend_plotly.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/make_legend_plotly.R
3 | \name{make_legend_plotly}
4 | \alias{make_legend_plotly}
5 | \title{Legend Positioning}
6 | \usage{
7 | make_legend_plotly(pos_legend)
8 | }
9 | \arguments{
10 | \item{pos_legend}{Position of legend}
11 | }
12 | \value{
13 | String
14 | }
15 | \description{
16 | Legend Positioning
17 | }
18 | \keyword{internal}
19 |
--------------------------------------------------------------------------------
/man/multi.ce.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/multi.ce.R
3 | \name{multi.ce}
4 | \alias{multi.ce}
5 | \alias{multi.ce.bcea}
6 | \title{Cost-effectiveness Analysis With Multiple Comparison}
7 | \usage{
8 | \method{multi.ce}{bcea}(he)
9 | }
10 | \arguments{
11 | \item{he}{A \code{bcea} object containing the results of the Bayesian
12 | modelling and the economic evaluation.}
13 | }
14 | \value{
15 | Original \code{bcea} object (list) of class "pairwise" with additional:
16 | \item{p_best_interv}{A matrix including the probability that each
17 | intervention is the most cost-effective for all values of the willingness to
18 | pay parameter}
19 | \item{ceaf}{A vector containing the cost-effectiveness acceptability frontier}
20 | }
21 | \description{
22 | Computes and plots the probability that each of the \code{n_int} interventions
23 | being analysed is the most cost-effective and the cost-effectiveness
24 | acceptability frontier.
25 | }
26 | \examples{
27 | # See Baio G., Dawid A.P. (2011) for a detailed description of the
28 | # Bayesian model and economic problem
29 |
30 | # Load the processed results of the MCMC simulation model
31 | data(Vaccine)
32 |
33 | # Runs the health economic evaluation using BCEA
34 |
35 | m <- bcea(e=eff, c=cost, # defines the variables of
36 | # effectiveness and cost
37 | ref=2, # selects the 2nd row of (e,c)
38 | # as containing the reference intervention
39 | interventions=treats, # defines the labels to be associated
40 | # with each intervention
41 | Kmax=50000, # maximum value possible for the willingness
42 | # to pay threshold; implies that k is chosen
43 | # in a grid from the interval (0,Kmax)
44 | plot=FALSE # inhibits graphical output
45 | )
46 |
47 | mce <- multi.ce(m) # uses the results of the economic analysis
48 |
49 | ceac.plot(mce)
50 | ceaf.plot(mce)
51 |
52 | }
53 | \seealso{
54 | \code{\link[=bcea]{bcea()}},
55 | \code{\link[=ceaf.plot]{ceaf.plot()}}
56 | }
57 | \author{
58 | Gianluca Baio
59 | }
60 | \keyword{dplot}
61 | \keyword{hplot}
62 |
--------------------------------------------------------------------------------
/man/multiplot.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/multiplot.R
3 | \name{multiplot}
4 | \alias{multiplot}
5 | \title{Plot Multiple bcea Graphs}
6 | \usage{
7 | multiplot(plotlist = NULL, cols = 1, layout_config = NULL)
8 | }
9 | \arguments{
10 | \item{plotlist}{List of ggplot objects}
11 |
12 | \item{cols}{Number of columns}
13 |
14 | \item{layout_config}{Matrix of plot configuration}
15 | }
16 | \value{
17 | ggplot TableGrob object
18 | }
19 | \description{
20 | Arrange plots in grid. Sourced from R graphics cookbook.
21 | }
22 | \keyword{internal}
23 |
--------------------------------------------------------------------------------
/man/new_bcea.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/new_bcea.R
3 | \name{new_bcea}
4 | \alias{new_bcea}
5 | \title{Constructor for bcea}
6 | \usage{
7 | new_bcea(df_ce, k)
8 | }
9 | \arguments{
10 | \item{df_ce}{Dataframe of all simulation eff and cost}
11 |
12 | \item{k}{Vector of willingness to pay values}
13 | }
14 | \value{
15 | List object of class bcea.
16 | }
17 | \description{
18 | Constructor for bcea
19 | }
20 | \seealso{
21 | \code{\link[=bcea]{bcea()}}
22 | }
23 |
--------------------------------------------------------------------------------
/man/num_lines.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/num_lines.R
3 | \name{num_lines}
4 | \alias{num_lines}
5 | \alias{num_lines.pairwise}
6 | \alias{num_lines.bcea}
7 | \alias{num_lines.evppi}
8 | \alias{num_lines.default}
9 | \title{Get number of lines}
10 | \usage{
11 | num_lines(dat)
12 |
13 | \method{num_lines}{pairwise}(dat)
14 |
15 | \method{num_lines}{bcea}(dat)
16 |
17 | \method{num_lines}{evppi}(dat)
18 |
19 | \method{num_lines}{default}(dat)
20 | }
21 | \arguments{
22 | \item{dat}{Data}
23 | }
24 | \description{
25 | Get number of lines
26 | }
27 | \keyword{internal}
28 |
--------------------------------------------------------------------------------
/man/openPDF.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/make.report.R
3 | \name{openPDF}
4 | \alias{openPDF}
5 | \title{Automatically open pdf output using default pdf viewer}
6 | \usage{
7 | openPDF(file_name)
8 | }
9 | \arguments{
10 | \item{file_name}{String file names for pdf}
11 | }
12 | \description{
13 | Automatically open pdf output using default pdf viewer
14 | }
15 | \keyword{internal}
16 |
--------------------------------------------------------------------------------
/man/plot_eib_cri.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/plot_eib_cri.R
3 | \name{plot_eib_cri}
4 | \alias{plot_eib_cri}
5 | \title{Plot Credible Intervals}
6 | \usage{
7 | plot_eib_cri(he, params)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{params}{Graph parameters}
14 | }
15 | \description{
16 | Bayesian posterior credible intervals against willingness to pay.
17 | }
18 | \keyword{internal}
19 |
--------------------------------------------------------------------------------
/man/prep_ceplane_params.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/prep_ceplane_params.R
3 | \name{prep_ceplane_params}
4 | \alias{prep_ceplane_params}
5 | \title{Prepare CE-plane Parameters}
6 | \usage{
7 | prep_ceplane_params(he, wtp_params, ...)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{wtp_params}{Willingness-to-pay parameters. This can be a single value or a list.}
14 |
15 | \item{...}{Additional arguments}
16 | }
17 | \value{
18 | List pf graph parameters
19 | }
20 | \description{
21 | In ggplot format, combine user-supplied
22 | parameters with defaults.
23 | }
24 | \keyword{internal}
25 |
--------------------------------------------------------------------------------
/man/prep_contour_params.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/prep_contour_params.R
3 | \name{prep_contour_params}
4 | \alias{prep_contour_params}
5 | \title{Prepare contour plot parameters
6 | Additional to ceplane parameters}
7 | \usage{
8 | prep_contour_params(he, ...)
9 | }
10 | \arguments{
11 | \item{he}{A \code{bcea} object containing the results of the Bayesian
12 | modelling and the economic evaluation.}
13 |
14 | \item{...}{Additional parameters}
15 | }
16 | \value{
17 | A list of parameters
18 | }
19 | \description{
20 | Prepare contour plot parameters
21 | Additional to ceplane parameters
22 | }
23 | \keyword{internal}
24 |
--------------------------------------------------------------------------------
/man/prep_eib_params.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/prep_eib_params.R
3 | \name{prep_eib_params}
4 | \alias{prep_eib_params}
5 | \title{Prepare EIB plot parameters}
6 | \usage{
7 | prep_eib_params(he, plot.cri, ...)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{plot.cri}{Make title including credible interval? Logical}
14 |
15 | \item{...}{Additional parameters}
16 | }
17 | \value{
18 | List of graph parameters
19 | }
20 | \description{
21 | Parameters general to all plotting devices.
22 | }
23 | \keyword{internal}
24 |
--------------------------------------------------------------------------------
/man/prep_frontier_data.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/prep_frontier_data.R
3 | \name{prep_frontier_data}
4 | \alias{prep_frontier_data}
5 | \title{Prepare frontier data}
6 | \usage{
7 | prep_frontier_data(he, threshold = NULL, start.origin = TRUE)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{threshold}{Cost-effectiveness threshold i.e angle of line. Must be >=0 or NULL.}
14 |
15 | \item{start.origin}{Where should the frontier start from?}
16 | }
17 | \value{
18 | List with scatter.data, ceef.points, orig.avg
19 | }
20 | \description{
21 | Prepare frontier data
22 | }
23 | \seealso{
24 | ceef.plot
25 | }
26 | \keyword{internal}
27 |
--------------------------------------------------------------------------------
/man/print.bcea.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/base_methods.R
3 | \name{print.bcea}
4 | \alias{print.bcea}
5 | \title{bcea Print Method}
6 | \usage{
7 | \method{print}{bcea}(x, digits = getOption("digits"), give.attr = FALSE, no.list = TRUE, ...)
8 | }
9 | \arguments{
10 | \item{x}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{digits}{Minimal number of significant digits, see \code{\link[=print.default]{print.default()}}.}
14 |
15 | \item{give.attr}{Logical; if TRUE (default), show attributes as sub structures.}
16 |
17 | \item{no.list}{Logical; if TRUE, no ‘list of ...’ nor the class are printed.}
18 |
19 | \item{...}{Potential further arguments.}
20 | }
21 | \description{
22 | bcea Print Method
23 | }
24 | \examples{
25 | data("Vaccine")
26 | he <- BCEA::bcea(eff, cost)
27 |
28 | }
29 | \keyword{print}
30 |
--------------------------------------------------------------------------------
/man/quadrant_params.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/quadrant_params.R
3 | \name{quadrant_params}
4 | \alias{quadrant_params}
5 | \title{Quadrant Parameters
6 | requires just a single comparison group}
7 | \usage{
8 | quadrant_params(he, params)
9 | }
10 | \description{
11 | Quadrant Parameters
12 | requires just a single comparison group
13 | }
14 | \keyword{aplot}
15 | \keyword{internal}
16 |
--------------------------------------------------------------------------------
/man/quiet.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/make.report.R
3 | \name{quiet}
4 | \alias{quiet}
5 | \title{Allow disabling of the cat messages}
6 | \usage{
7 | quiet(x)
8 | }
9 | \arguments{
10 | \item{x}{Object to quietly return}
11 | }
12 | \description{
13 | Allow disabling of the cat messages
14 | }
15 | \keyword{internal}
16 |
--------------------------------------------------------------------------------
/man/select_plot_type.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/select_plot_type.R
3 | \name{select_plot_type}
4 | \alias{select_plot_type}
5 | \title{Choose Graphical Engine}
6 | \usage{
7 | select_plot_type(graph)
8 | }
9 | \arguments{
10 | \item{graph}{Type names; string}
11 | }
12 | \value{
13 | Plot ID integer 1:base R; 2:ggplot2; 3:plotly
14 | }
15 | \description{
16 | From base R, ggplot2 or plotly.
17 | }
18 | \keyword{dplot}
19 | \keyword{internal}
20 |
--------------------------------------------------------------------------------
/man/setComparisons.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/setComparisons.R
3 | \name{setComparisons}
4 | \alias{setComparisons}
5 | \title{Set Comparisons Group}
6 | \usage{
7 | setComparisons(he, comparison)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{comparison}{Selects the comparator, in case of more than two
14 | interventions being analysed. Default as NULL plots all the comparisons
15 | together. Any subset of the possible comparisons can be selected (e.g.,
16 | \code{comparison=c(1,3)} or \code{comparison=2}).}
17 | }
18 | \description{
19 | One of the alternative way to set (e,c) comparison group.
20 | Simply recompute all comparisons and drop unwanted.
21 | }
22 | \seealso{
23 | \code{\link[=setComparisons<-]{setComparisons<-()}}
24 | }
25 |
--------------------------------------------------------------------------------
/man/setComparisons_assign.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/setComparisons.R
3 | \name{setComparisons_assign}
4 | \alias{setComparisons_assign}
5 | \alias{setComparisons<-}
6 | \alias{setComparisons<-.bcea}
7 | \alias{setComparisons<-.default}
8 | \title{Set Comparison Group}
9 | \usage{
10 | setComparisons(he) <- value
11 |
12 | \method{setComparisons}{bcea}(he) <- value
13 |
14 | \method{setComparisons}{default}(he) <- value
15 | }
16 | \arguments{
17 | \item{he}{A \code{bcea} object containing the results of the Bayesian
18 | modelling and the economic evaluation.}
19 |
20 | \item{value}{Comparison}
21 | }
22 | \value{
23 | bcea-type object
24 | }
25 | \description{
26 | One of the alternative way to set (e,c) comparison group.
27 | }
28 | \seealso{
29 | \code{\link[=setComparisons]{setComparisons()}}
30 | }
31 |
--------------------------------------------------------------------------------
/man/setKmax_assign.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/bcea_setters.R
3 | \name{setKmax_assign}
4 | \alias{setKmax_assign}
5 | \alias{setKmax<-}
6 | \alias{setKmax<-.bcea}
7 | \alias{setKmax<-.default}
8 | \title{Set Maximum Willingness to Pay}
9 | \usage{
10 | setKmax(he) <- value
11 |
12 | \method{setKmax}{bcea}(he) <- value
13 |
14 | \method{setKmax}{default}(he) <- value
15 | }
16 | \arguments{
17 | \item{he}{A \code{bcea} object containing the results of the Bayesian
18 | modelling and the economic evaluation.}
19 |
20 | \item{value}{Maximum willingness to pay}
21 | }
22 | \value{
23 | bcea-type object
24 | }
25 | \description{
26 | Alternative way to define \code{K} statistic.
27 | }
28 |
--------------------------------------------------------------------------------
/man/setReferenceGroup_assign.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/bcea_setters.R
3 | \name{setReferenceGroup_assign}
4 | \alias{setReferenceGroup_assign}
5 | \alias{setReferenceGroup<-}
6 | \alias{setReferenceGroup<-.bcea}
7 | \alias{setReferenceGroup<-.default}
8 | \title{Set Reference Group}
9 | \usage{
10 | setReferenceGroup(he) <- value
11 |
12 | \method{setReferenceGroup}{bcea}(he) <- value
13 |
14 | \method{setReferenceGroup}{default}(he) <- value
15 | }
16 | \arguments{
17 | \item{he}{A \code{bcea} object containing the results of the Bayesian
18 | modelling and the economic evaluation.}
19 |
20 | \item{value}{Reference group number}
21 | }
22 | \value{
23 | bcea-type object
24 | }
25 | \description{
26 | Alternative way to define (e,c) reference group.
27 | }
28 |
--------------------------------------------------------------------------------
/man/sim_table.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/sim_table.R
3 | \name{sim_table}
4 | \alias{sim_table}
5 | \alias{sim_table.bcea}
6 | \title{Table of Simulation Statistics for the Health Economic Model}
7 | \usage{
8 | sim_table(he, ...)
9 |
10 | \method{sim_table}{bcea}(he, wtp = 25000, ...)
11 | }
12 | \arguments{
13 | \item{he}{A \code{bcea} object containing the results of the Bayesian
14 | modelling and the economic evaluation.}
15 |
16 | \item{...}{Additional arguments}
17 |
18 | \item{wtp}{The value of the willingness to pay threshold to be used in the
19 | summary table.}
20 | }
21 | \value{
22 | Produces the following elements:
23 | \item{table}{A table with simulation statistics from the economic model}
24 | \item{names.cols}{A vector of labels to be associated with each column of the table}
25 | \item{wtp}{The selected value of the willingness to pay}
26 | \item{idx_wtp}{The index associated with the selected value of the willingness
27 | to pay threshold in the grid used to run the analysis}
28 | }
29 | \description{
30 | Using the input in the form of MCMC simulations and after having run the
31 | health economic model, produces a summary table of the simulations from the
32 | cost-effectiveness analysis.
33 | }
34 | \examples{
35 | # See Baio G., Dawid A.P. (2011) for a detailed description of the
36 | # Bayesian model and economic problem
37 |
38 | # Load the processed results of the MCMC simulation model
39 | data(Vaccine)
40 |
41 | # Runs the health economic evaluation using BCEA
42 | m <- bcea(e=eff, # defines the variables of
43 | c=cost, # effectiveness and cost
44 | ref=2, # selects the 2nd row of (e, c)
45 | # as containing the reference intervention
46 | interventions=treats, # defines the labels to be associated
47 | # with each intervention
48 | Kmax=50000) # maximum value possible for the willingness
49 | # to pay threshold; implies that k is chosen
50 | # in a grid from the interval (0, Kmax)
51 |
52 | # Now can save the simulation exercise in an object using sim_table()
53 | sim_table(m, # uses the results of the economic evaluation
54 | wtp=25000) # selects the particular value for k
55 |
56 | }
57 | \references{
58 | \insertRef{Baio2011}{BCEA}
59 |
60 | \insertRef{Baio2013}{BCEA}
61 | }
62 | \seealso{
63 | \code{\link[=bcea]{bcea()}}
64 | }
65 | \author{
66 | Gianluca Baio
67 | }
68 | \keyword{print}
69 |
--------------------------------------------------------------------------------
/man/statins_HC.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/data.R
3 | \docType{data}
4 | \name{statins_HC}
5 | \alias{statins_HC}
6 | \alias{Statins}
7 | \alias{robust}
8 | \alias{model}
9 | \title{Data set for the Bayesian model for the evidence-synthesis of statins
10 | (robust model using Half Cauchy priors for the structured effects standard
11 | deviations)}
12 | \format{
13 | A BUGS object containing the simulations for the evidence synthesis
14 | model
15 | \describe{
16 | \item{list("statins_HC")}{a BUGS object}
17 | }
18 | \source{
19 | A systematic review and economic evaluation of statins for the
20 | prevention of coronary events. Ward 2007.
21 | }
22 | \description{
23 | This data set contains the results of the Bayesian analysis used to model
24 | the effectiveness of various statins. The analysis is based on the simplest
25 | model, using robust priors.
26 | }
27 | \references{
28 | Baio G. (2012). Bayesian Methods in Health Economics.
29 | CRC/Chapman Hall, London
30 | }
31 | \keyword{datasets}
32 |
--------------------------------------------------------------------------------
/man/statins_base.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/data.R
3 | \docType{data}
4 | \name{statins_base}
5 | \alias{statins_base}
6 | \alias{Statins}
7 | \alias{base}
8 | \alias{model}
9 | \title{Data set for the Bayesian model for the evidence-synthesis of statins
10 | (base model)}
11 | \format{
12 | A BUGS object containing the simulations for the evidence synthesis
13 | model
14 | \describe{
15 | \item{list("statins_base")}{a BUGS object}
16 | }
17 | \source{
18 | A systematic review and economic evaluation of statins for the
19 | prevention of coronary events. Ward 2007.
20 | }
21 | \description{
22 | This data set contains the results of the Bayesian analysis used to model
23 | the effectiveness of various statins. The analysis is based on the simplest
24 | model, using vague priors.
25 | }
26 | \references{
27 | Baio G. (2012). Bayesian Methods in Health Economics.
28 | CRC/Chapman Hall, London
29 | }
30 | \keyword{datasets}
31 |
--------------------------------------------------------------------------------
/man/summary.bcea.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/summary.bcea.R
3 | \name{summary.bcea}
4 | \alias{summary.bcea}
5 | \title{Summary Method for Objects of Class \code{bcea}}
6 | \usage{
7 | \method{summary}{bcea}(object, wtp = 25000, ...)
8 | }
9 | \arguments{
10 | \item{object}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{wtp}{The value of the willingness to pay threshold used in the summary table.}
14 |
15 | \item{...}{Additional arguments affecting the summary produced.}
16 | }
17 | \value{
18 | Prints a summary table with some information on the health economic
19 | output and synthetic information on the economic measures (EIB, CEAC, EVPI).
20 | }
21 | \description{
22 | Produces a table printout with some summary results of the health economic
23 | evaluation.
24 | }
25 | \examples{
26 | data(Vaccine)
27 |
28 | he <- bcea(eff, cost, interventions = treats, ref = 2)
29 | summary(he)
30 |
31 | }
32 | \references{
33 | \insertRef{Baio2011}{BCEA}
34 |
35 | \insertRef{Baio2013}{BCEA}
36 | }
37 | \seealso{
38 | \code{\link[=bcea]{bcea()}}
39 | }
40 | \author{
41 | Gianluca Baio
42 | }
43 | \keyword{print}
44 |
--------------------------------------------------------------------------------
/man/summary.pairwise.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/summary.pairwise.R
3 | \name{summary.pairwise}
4 | \alias{summary.pairwise}
5 | \title{Summary Method for Objects of Class \code{pairwise}}
6 | \usage{
7 | \method{summary}{pairwise}(object, wtp = 25000, ...)
8 | }
9 | \arguments{
10 | \item{object}{A \code{pairwise} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{wtp}{The value of the willingness to pay threshold used in the
14 | summary table.}
15 |
16 | \item{...}{Additional arguments affecting the summary produced.}
17 | }
18 | \value{
19 | Prints a summary table with some information on the health economic
20 | output and synthetic information on the economic measures (EIB, CEAC, EVPI).
21 | }
22 | \description{
23 | Produces a table printout with some summary results of the health economic
24 | evaluation.
25 | }
26 | \examples{
27 | data(Vaccine)
28 | he <- bcea(eff, cost, interventions = treats, ref = 2)
29 | he_multi <- multi.ce(he)
30 | summary(he_multi)
31 |
32 | }
33 | \references{
34 | \insertRef{Baio2011}{BCEA}
35 |
36 | \insertRef{Baio2013}{BCEA}
37 | }
38 | \seealso{
39 | \code{\link[=bcea]{bcea()}} \code{\link[=multi.ce]{multi.ce()}}
40 | }
41 | \author{
42 | Gianluca Baio
43 | }
44 | \keyword{print}
45 |
--------------------------------------------------------------------------------
/man/tabulate_means.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/ce_table.R
3 | \name{tabulate_means}
4 | \alias{tabulate_means}
5 | \title{Calculate Dataset For ICERs From bcea Object}
6 | \usage{
7 | tabulate_means(he, comp_label = NULL, ...)
8 | }
9 | \arguments{
10 | \item{he}{A \code{bcea} object containing the results of the Bayesian
11 | modelling and the economic evaluation.}
12 |
13 | \item{comp_label}{Optional vector of strings with comparison labels}
14 |
15 | \item{...}{Additional arguments}
16 | }
17 | \value{
18 | A data.frame object including mean outcomes, comparison identifier,
19 | comparison label and associated ICER
20 | }
21 | \description{
22 | Calculate Dataset For ICERs From bcea Object
23 | }
24 | \examples{
25 | data("Smoking")
26 | he <- BCEA::bcea(eff, cost)
27 | tabulate_means(he)
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/man/theme_bcea.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/themes_ggplot.R
3 | \name{theme_bcea}
4 | \alias{theme_bcea}
5 | \alias{theme_default}
6 | \alias{theme_ceac}
7 | \alias{theme_ceplane}
8 | \alias{theme_eib}
9 | \alias{theme_contour}
10 | \title{bcea theme ggplot2}
11 | \usage{
12 | theme_default()
13 |
14 | theme_ceac()
15 |
16 | theme_ceplane()
17 |
18 | theme_eib()
19 |
20 | theme_contour()
21 | }
22 | \description{
23 | bcea theme ggplot2
24 | }
25 | \keyword{aplot}
26 | \keyword{internal}
27 |
--------------------------------------------------------------------------------
/man/validate_bcea.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/validate_bcea.R
3 | \name{validate_bcea}
4 | \alias{validate_bcea}
5 | \title{Validate bcea}
6 | \usage{
7 | validate_bcea(eff, cost, ref, interventions)
8 | }
9 | \arguments{
10 | \item{eff}{Effectiveness matrix}
11 |
12 | \item{cost}{Cost matrix}
13 |
14 | \item{ref}{Reference intervention}
15 |
16 | \item{interventions}{All interventions}
17 | }
18 | \description{
19 | Validate bcea
20 | }
21 | \keyword{internal}
22 |
--------------------------------------------------------------------------------
/man/validate_eib_params.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/prep_eib_params.R
3 | \name{validate_eib_params}
4 | \alias{validate_eib_params}
5 | \title{Validate EIB parameters}
6 | \usage{
7 | validate_eib_params(params)
8 | }
9 | \arguments{
10 | \item{params}{Graph parameters}
11 | }
12 | \value{
13 | List of graph parameters
14 | }
15 | \description{
16 | Validate EIB parameters
17 | }
18 | \seealso{
19 | \code{\link[=prep_eib_params]{prep_eib_params()}}
20 | }
21 | \keyword{internal}
22 |
--------------------------------------------------------------------------------
/pkgdown/assets/bcea_cheatsheet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/pkgdown/assets/bcea_cheatsheet.pdf
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/pkgdown/favicon/apple-touch-icon-120x120.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/pkgdown/favicon/apple-touch-icon-60x60.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/pkgdown/favicon/apple-touch-icon-76x76.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/pkgdown/favicon/apple-touch-icon.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/pkgdown/favicon/favicon-16x16.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/pkgdown/favicon/favicon-32x32.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/pkgdown/favicon/favicon.ico
--------------------------------------------------------------------------------
/revdep/cran.md:
--------------------------------------------------------------------------------
1 | ## revdepcheck results
2 |
3 | We checked 3 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.
4 |
5 | * We saw 0 new problems
6 | * We failed to check 0 packages
7 |
8 |
--------------------------------------------------------------------------------
/revdep/failures.md:
--------------------------------------------------------------------------------
1 | *Wow, no problems at all. :)*
--------------------------------------------------------------------------------
/revdep/problems.md:
--------------------------------------------------------------------------------
1 | *Wow, no problems at all. :)*
--------------------------------------------------------------------------------
/tests/figs/deps.txt:
--------------------------------------------------------------------------------
1 | - vdiffr-svg-engine: 1.0
2 | - vdiffr: 0.3.2
3 | - freetypeharfbuzz: 0.2.5
4 |
--------------------------------------------------------------------------------
/tests/testthat.R:
--------------------------------------------------------------------------------
1 | library(testthat)
2 | library(BCEA)
3 |
4 | test_check("BCEA")
5 |
--------------------------------------------------------------------------------
/tests/testthat/ce_mock.stan:
--------------------------------------------------------------------------------
1 | data {
2 | real x[2];
3 | real y[2];
4 | }
5 |
6 | parameters {
7 | real cost[2];
8 | real eff[2];
9 | }
10 |
11 | model {
12 | for (i in 1:2) {
13 | cost[i] ~ uniform(0, 1);
14 | eff[i] ~ uniform(0, 1);
15 |
16 | x[i] ~ normal(cost[i], 1);
17 | y[i] ~ normal(eff[i], 1);
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/tests/testthat/ce_mock.txt:
--------------------------------------------------------------------------------
1 | model {
2 | for (i in 1:2) {
3 |
4 | cost[i] ~ dunif(0, 1)
5 | eff[i] ~ dunif(0, 1)
6 |
7 | x[i] ~ dnorm(cost[i], 1)
8 | y[i] ~ dnorm(eff[i], 1)
9 | }
10 | }
--------------------------------------------------------------------------------
/tests/testthat/ce_smoking.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/ce_smoking.RData
--------------------------------------------------------------------------------
/tests/testthat/ce_vaccine.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/ce_vaccine.RData
--------------------------------------------------------------------------------
/tests/testthat/create_ce_mock.R:
--------------------------------------------------------------------------------
1 |
2 | # create jags, BUGS and Stan mocked
3 | # cost and eff posterior samples
4 | # to test bcea() methods
5 |
6 |
7 | ##TODO: why doesn't this MC forward sampling work?
8 | # cat("model {
9 | # eff ~ dunif(0, 1)
10 | # cost ~ dnorm(0, 1)
11 | # }", file = "ce_mock.txt")
12 |
13 | ## ... a work-around
14 | cat("model {
15 | for (i in 1:2) {
16 |
17 | cost[i] ~ dunif(0, 1)
18 | eff[i] ~ dunif(0, 1)
19 |
20 | x[i] ~ dnorm(cost[i], 1)
21 | y[i] ~ dnorm(eff[i], 1)
22 | }
23 | }", file = "ce_mock.txt")
24 |
25 | writeLines(
26 | "data {
27 | real x[2];
28 | real y[2];
29 | }
30 |
31 | parameters {
32 | real cost[2];
33 | real eff[2];
34 | }
35 |
36 | model {
37 | for (i in 1:2) {
38 | cost[i] ~ uniform(0, 1);
39 | eff[i] ~ uniform(0, 1);
40 |
41 | x[i] ~ normal(cost[i], 1);
42 | y[i] ~ normal(eff[i], 1);
43 | }
44 | }
45 | ", con = "ce_mock.stan")
46 |
47 | model.params <- c("cost", "eff")
48 | model.data <- list(x = c(1,1), y = c(1,1))
49 |
50 | jagsfit <- jags(data = model.data,
51 | parameters.to.save = model.params,
52 | n.iter = 10,
53 | n.chains = 1,
54 | model.file = "ce_mock.txt")
55 |
56 | bugsfit <- openbugs(data = model.data,
57 | parameters.to.save = model.params,
58 | n.iter = 10,
59 | n.chains = 1,
60 | inits = list(list(cost = 0, eff = 0)),
61 | model.file = "ce_mock.txt")
62 |
63 | # stanfit <- stan(data = model.data,
64 | # pars = model.params,
65 | # chains = 1,
66 | # iter = 10,
67 | # init = 0,
68 | # file = "ce_mock.stan")
69 |
70 | save(jagsfit, file = test_path("data", "jagsfit.RData"))
71 | save(bugsfit, file = test_path("data", "bugsfit.RData"))
72 | # save(stanfit, file = test_path("data", "stanfit.RData"))
73 |
74 |
--------------------------------------------------------------------------------
/tests/testthat/df_ce.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/df_ce.RData
--------------------------------------------------------------------------------
/tests/testthat/test-CEriskav.R:
--------------------------------------------------------------------------------
1 |
2 | # risk aversion
3 |
4 | # library(dplyr)
5 | # library(reshape2)
6 |
7 | ##TODO:...
8 |
9 | test_that("zero risk aversion is equal to default", {
10 |
11 | load(test_path("ce_smoking.RData"))
12 |
13 | treats <- c("No intervention", "Self-help", "Individual counselling", "Group counselling")
14 | bcea_smoke <- bcea(eff, cost, ref = 4, interventions = treats, Kmax = 500)
15 |
16 | r <- 0
17 | CEriskav(bcea_smoke) <- r
18 | tol <- 0.0001
19 |
20 | expect_equivalent(bcea_smoke$U[,,1], bcea_smoke$Ur[,,1,1], tolerance = tol)
21 | expect_equivalent(bcea_smoke$U[,,2], bcea_smoke$Ur[,,2,1], tolerance = tol)
22 | expect_equivalent(bcea_smoke$U[,,3], bcea_smoke$Ur[,,3,1], tolerance = tol)
23 | expect_equivalent(bcea_smoke$U[,,4], bcea_smoke$Ur[,,4,1], tolerance = tol)
24 | })
25 |
--------------------------------------------------------------------------------
/tests/testthat/test-bcea_setters.R:
--------------------------------------------------------------------------------
1 |
2 | # library(dplyr)
3 |
4 | # data(Vaccine)
5 |
6 | test_that("setKmax", {
7 |
8 | load(test_path("testdata", "ce.RData"))
9 |
10 | m <- bcea(e = eff,
11 | c = cost,
12 | ref = 2,
13 | Kmax = 50000,
14 | plot = FALSE)
15 |
16 | setKmax(m) <- 20000
17 |
18 | expect_equal(m$Kmax, 20000)
19 | expect_equal(max(m$k), 20000)
20 | expect_equal(m$step, 40)
21 | })
22 |
23 |
24 | test_that("setReferenceGroup", {
25 |
26 | load(test_path("testdata", "ce.RData"))
27 |
28 | m <- bcea(e = eff,
29 | c = cost,
30 | ref = 2,
31 | Kmax = 50000,
32 | plot = FALSE)
33 |
34 | setReferenceGroup(m) <- 1
35 |
36 | expect_equal(m$ref, 1)
37 | expect_equal(m$comp, 2)
38 | })
39 |
40 |
41 | test_that("setComparison", {
42 |
43 | load(test_path("testdata", "ce.RData"))
44 |
45 | m_r1 <- bcea(e = eff,
46 | c = cost,
47 | Kmax = 50000,
48 | plot = FALSE)
49 |
50 | m_c2 <- bcea(e = eff,
51 | c = cost,
52 | .comparison = 2,
53 | Kmax = 50000,
54 | plot = FALSE)
55 |
56 | expect_equivalent(m_r1, m_c2)
57 |
58 | m_r2 <- bcea(e = eff,
59 | c = cost,
60 | ref = 2,
61 | Kmax = 50000,
62 | plot = FALSE)
63 |
64 | m_r2c1 <- bcea(e = eff,
65 | c = cost,
66 | .comparison = 1,
67 | ref = 2,
68 | Kmax = 50000,
69 | plot = FALSE)
70 |
71 | expect_equivalent(m_r2, m_r2c1)
72 |
73 | expect_error(
74 | bcea(e = eff,
75 | c = cost,
76 | .comparison = 1,
77 | Kmax = 50000,
78 | plot = FALSE),
79 | "Can't select Reference group. Change Reference first.")
80 |
81 | expect_error(
82 | bcea(e = eff,
83 | c = cost,
84 | .comparison = 2,
85 | ref = 2,
86 | Kmax = 50000,
87 | plot = FALSE),
88 | "Can't select Reference group. Change Reference first.")
89 | })
90 |
--------------------------------------------------------------------------------
/tests/testthat/test-ceac_plot_ggplot.R:
--------------------------------------------------------------------------------
1 | # vdiffr::manage_cases(filter = "ceac")
2 |
3 | # library(purrr)
4 |
5 | test_that("ceac.plot_ggplot draws correctly", {
6 | load(test_path("testdata", "ce.RData"))
7 |
8 | he <- BCEA::bcea(eff, cost)
9 |
10 | ceac_plot <- ceac.plot(he, graph = "ggplot2", title = "my title")
11 | # vdiffr::expect_doppelganger(title = "ceac plot ggplot", fig = ceac_plot)
12 | })
13 |
--------------------------------------------------------------------------------
/tests/testthat/test-compute_U.R:
--------------------------------------------------------------------------------
1 |
2 | # library(dplyr)
3 | # library(reshape2)
4 |
5 | ##TODO:
6 |
7 | test_that("compute_U", {
8 |
9 | load(test_path("testdata", "ce.RData"))
10 |
11 | # single wtp
12 |
13 | # c_tmp <- matrix(c(0, 0, 100, 10), nrow = 2)
14 | # e_tmp <- matrix(c(0, 0, 1, -2), nrow = 2)
15 | #
16 | # res <-
17 | # bcea(e = e_tmp,
18 | # c = c_tmp, k = 5)
19 | #
20 | # k <- 5
21 | # n_comparisons <- 1
22 | # delta_e <- c(-1, 2)
23 | # delta_c <- c(-100, -10) # this actually a saving for intervention
24 | # n_sim <- 2
25 | #
26 | # ib_1 <- k*delta_e[1] - delta_c[1] # 5*(-1) - (-100) = 95
27 | # ib_2 <- k*delta_e[2] - delta_c[2] # 5*2 - (-10) = 20
28 | #
29 | # expect_equivalent(c(ib_1, ib_2), res$ib)
30 | #
31 | #
32 | # # multiple wtp
33 | #
34 | # k <- c(5, 10)
35 | # K <- 2
36 | #
37 | # res <-
38 | # bcea(e = e_tmp,
39 | # c = c_tmp, k = k)
40 | #
41 | # ib_1 <- k*delta_e[1] - delta_c[1] # 95, 10*(-1) - (-100) = 90
42 | # ib_2 <- k*delta_e[2] - delta_c[2] # 20, 10*2 - (-10) = 30
43 | #
44 | # expect_equivalent(cbind(ib_1, ib_2), drop(res$ib))
45 | #
46 | #
47 | # # multiple comparisons
48 | #
49 | # c_tmp <- matrix(c(0, 0, 100, 10, 0, 1), nrow = 2)
50 | # e_tmp <- matrix(c(0, 0, 1, -2, -3, -4), nrow = 2)
51 | # n_comparisons <- 2
52 | #
53 | # res <-
54 | # bcea(e = e_tmp,
55 | # c = c_tmp, k = k)
56 | #
57 | # # sim x comprison
58 | # delta_e <- matrix(c(-1,3,
59 | # 2,4), nrow = 2, byrow = TRUE)
60 | # delta_c <- matrix(c(-100, 0,
61 | # -10, -1), nrow = 2, byrow = TRUE)
62 | #
63 | # ib_11 <- k*delta_e[1,1] - delta_c[1,1] # 15 30
64 | # ib_12 <- k*delta_e[1,2] - delta_c[1,2] # 15 30
65 | # ib_21 <- k*delta_e[2,1] - delta_c[2,1] # 15 30
66 | # ib_22 <- k*delta_e[2,2] - delta_c[2,2] # 21 41
67 | #
68 | # expect_equivalent(cbind(ib_11, ib_21), res$ib[,,1 ])
69 | # expect_equivalent(cbind(ib_12, ib_22), res$ib[,,2 ])
70 | })
71 |
72 |
--------------------------------------------------------------------------------
/tests/testthat/test-compute_kstar.R:
--------------------------------------------------------------------------------
1 |
2 | test_that("Smoking example in BCEA book", {
3 |
4 | best <-
5 | c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
6 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
7 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
8 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
9 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,
10 | 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
11 | ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
12 | 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
13 | 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
14 | ,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
15 | 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
16 | 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
17 | 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
18 | 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
19 | 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
20 | 4,4,4,4,4,4,4,4,4)
21 |
22 | ref <- 4
23 | k <- 0:500
24 |
25 | expect_equal(compute_kstar(k, best, ref),
26 | c(159, 225))
27 | })
28 |
29 | test_that("simple data", {
30 |
31 | # empty return
32 | expect_equal(compute_kstar(k = 1, best = 1, ref = 2), numeric(0))
33 |
34 | # only ref as optimal
35 | expect_equal(compute_kstar(k = 1, best = 1, ref = 1), numeric(0))
36 | expect_equal(compute_kstar(k = c(0,1,2,3), best = c(4,4,4,4), ref = 4), numeric(0))
37 |
38 | expect_equal(compute_kstar(k = 0:1, best = c(1,2), ref = 2), 1)
39 | expect_equal(compute_kstar(k = 0:2, best = c(1,1,2), ref = 2), 2)
40 | expect_equal(compute_kstar(k = c(0,1,2,3), best = c(1,1,2,3), ref = 2), c(2,3))
41 |
42 |
43 | # opposite way round (from status-quo to alternative)
44 | expect_equal(compute_kstar(k = c(0,1,2,3), best = c(4,4,4,1), ref = 4), 3)
45 | })
46 |
47 |
--------------------------------------------------------------------------------
/tests/testthat/test-compute_ol.R:
--------------------------------------------------------------------------------
1 |
2 | # opportunity loss
3 |
4 | # library(dplyr)
5 | # library(reshape2)
6 |
7 |
8 |
9 | test_that("simple data input parameters", {
10 |
11 | load(test_path("testdata", "ce.RData"))
12 |
13 | # only one intervention
14 | # limiting case
15 |
16 | U <- array(c(1,1,1,
17 | 1,1,1),
18 | dim = c(3,2,1)) # sim, k, ints
19 |
20 | Ustar <- array(c(1,1,1,
21 | 1,1,1),
22 | dim = c(3,2)) # sim, k
23 |
24 | # no loss i.e all optimal
25 | best <- c(1,1) # k
26 |
27 | expect_equal(
28 | compute_ol(Ustar,
29 | U,
30 | best),
31 | array(c(0,0,0,
32 | 0,0,0),
33 | dim = c(3,2)))
34 |
35 | U <- array(c(1,1,1,1,1,1,
36 | 0,0,0,0,0,0),
37 | dim = c(3,2,2))
38 |
39 | Ustar <- array(c(1,1,1,
40 | 1,1,1),
41 | dim = c(3,2))
42 |
43 | # no loss i.e all optimal
44 | best <- c(1,1)
45 |
46 | expect_equal(
47 | compute_ol(Ustar,
48 | U,
49 | best),
50 | array(c(0,0,0,
51 | 0,0,0),
52 | dim = c(3,2)))
53 |
54 | # all loss
55 | best <- c(2,2)
56 |
57 | expect_equal(
58 | compute_ol(Ustar,
59 | U,
60 | best),
61 | array(c(1,1,1,
62 | 1,1,1),
63 | dim = c(3,2)))
64 |
65 | })
66 |
67 | test_that("call via bcea", {
68 |
69 | load(test_path("testdata", "ce.RData"))
70 |
71 | res <-
72 | bcea(e = eff,
73 | c = cost)
74 |
75 | ol <- res$ol
76 | n_sim <- nrow(cost)
77 |
78 | expect_equal(dim(ol), c(n_sim, length(res$k)))
79 |
80 | expect_true(all(ol >= 0))
81 | })
82 |
83 | test_that("errors in dimensions", {
84 |
85 | U <- array(c(1,1,1,1,1,1,
86 | 0,0,0,0,0,0),
87 | dim = c(3,2,2))
88 |
89 | Ustar <- array(c(1,1,1,
90 | 1,1,1),
91 | dim = c(3,2))
92 |
93 | # too long
94 | best <- c(1,1,1)
95 |
96 | expect_error(
97 | compute_ol(Ustar,
98 | U,
99 | best))
100 | # too short
101 | best <- 1
102 |
103 | expect_error(
104 | compute_ol(Ustar,
105 | U,
106 | best))
107 |
108 | # k out of bounds
109 | best <- c(0,1)
110 |
111 | expect_error(
112 | compute_ol(Ustar,
113 | U,
114 | best))
115 |
116 | best <- c(1,3)
117 |
118 | expect_error(
119 | compute_ol(Ustar,
120 | U,
121 | best))
122 | })
123 |
--------------------------------------------------------------------------------
/tests/testthat/test-compute_vi.R:
--------------------------------------------------------------------------------
1 |
2 | # value of information
3 |
4 | # library(dplyr)
5 | # library(reshape2)
6 |
7 |
8 |
9 | test_that("simple data", {
10 |
11 | load(test_path("testdata", "ce.RData"))
12 |
13 | # only one intervention
14 | # limiting case
15 | U <- array(c(1,1,1,1,1,1),
16 | dim = c(3,2,1)) # sim, k, ints
17 |
18 | Ustar <- array(c(1,1,1,
19 | 1,1,1),
20 | dim = c(3,2)) # sim, k
21 |
22 | expect_error(
23 | compute_vi(Ustar, U))
24 |
25 | U <- array(c(1,1,1,1,1,1,
26 | 0,0,0,0,0,0),
27 | dim = c(3,2,2))
28 |
29 | Ustar <- array(c(1,1,1,
30 | 1,1,1),
31 | dim = c(3,2))
32 |
33 | expect_equal(
34 | compute_vi(Ustar, U),
35 | array(c(0,0,0,0,
36 | 0,0,0,0),
37 | dim = c(3,2)))
38 |
39 | U <- array(c(1,1,1,1,1,1,
40 | 2,2,2,2,2,2),
41 | dim = c(3,2,2))
42 |
43 | expect_equal(
44 | compute_vi(Ustar, U),
45 | array(c(-1,-1,-1,-1,
46 | -1,-1,-1,-1),
47 | dim = c(3,2)))
48 |
49 | })
50 |
51 | test_that("call via bcea", {
52 |
53 | load(test_path("testdata", "ce.RData"))
54 |
55 | res <-
56 | bcea(e = eff,
57 | c = cost)
58 |
59 | vi <- res$vi
60 | n_sim <- nrow(cost)
61 |
62 | expect_equal(dim(vi), c(n_sim, length(res$k)))
63 | })
64 |
65 | test_that("errors in dimensions", {
66 |
67 | U <- array(c(1,1,1,1,1,1,
68 | 0,0,0,0,0,0),
69 | dim = c(3,2,2))
70 |
71 | Ustar <- array(c(1,1,
72 | 1,1),
73 | dim = c(2,2))
74 |
75 | expect_error(
76 | compute_vi(Ustar, U))
77 |
78 | Ustar <- array(c(1,1,1,
79 | 1,1,1,
80 | 1,1,1),
81 | dim = c(3,3))
82 |
83 | expect_error(
84 | compute_vi(Ustar, U))
85 | })
86 |
87 | test_that("using sim_table", {
88 |
89 | load(test_path("testdata", "ce.RData"))
90 |
91 | res <-
92 | bcea(e = eff,
93 | c = cost)
94 |
95 | tab <- sim_table(res)$Table
96 |
97 | ol <- tab$`U*` - tab$U2
98 | vi <- tab$`U*` - mean(tab$U2)
99 |
100 | expect_equivalent(apply(tab[,c("OL","VI")], 2, mean),
101 | c(mean(vi), mean(ol)))
102 | })
103 |
--------------------------------------------------------------------------------
/tests/testthat/test-createInputs.R:
--------------------------------------------------------------------------------
1 |
2 |
3 | test_that("createInputs bad arguments", {
4 |
5 | data(Vaccine, package = "BCEA")
6 | treats <- c("Status quo", "Vaccination")
7 |
8 | m <- bcea(e.pts, c.pts, ref = 2, interventions = treats)
9 |
10 | dat <- vaccine_mat[, 1:5]
11 | datNA <- cbind(dat, NA)
12 |
13 | expect_equal(createInputs(dat), createInputs(datNA))
14 | expect_message(createInputs(datNA), regexp = "Dropped any columns containing NAs")
15 | })
16 |
17 |
--------------------------------------------------------------------------------
/tests/testthat/test-eib.plot.R:
--------------------------------------------------------------------------------
1 |
2 | # expected incremental benefit plot
3 |
4 | # library(BCEA)
5 |
6 |
7 | load(test_path("ce_smoking.RData"))
8 |
9 | test_that("errors for comparison groups base R", {
10 |
11 | he <- bcea(eff, cost, ref = 4, Kmax = 500)
12 |
13 | # expect_silent(eib.plot(he, comparison = 2))
14 | # expect_silent(eib.plot(he, comparison = c(2,3)))
15 |
16 | expect_error(eib.plot(he, comparison = 4),
17 | "Can't select Reference group. Change Reference first.")
18 |
19 | expect_error(eib.plot(he, comparison = c(1,4)),
20 | "Can't select Reference group. Change Reference first.")
21 |
22 | expect_error(eib.plot(he, comparison = 0),
23 | "Comparison index not in available comparisons.")
24 |
25 | expect_error(eib.plot(he, comparison = c(1,0)),
26 | "Comparison index not in available comparisons.")
27 | })
28 |
29 |
--------------------------------------------------------------------------------
/tests/testthat/test-eib_plot_ggplot.R:
--------------------------------------------------------------------------------
1 |
2 | # library(ggplot2)
3 | # library(dplyr)
4 | # library(reshape2)
5 | # library(purrr)
6 | # library(vdiffr)
7 |
8 |
9 | test_that("eib.plot_ggplot draws correctly", {
10 | load(test_path("testdata", "ce.RData"))
11 |
12 | he <- BCEA::bcea(eff, cost)
13 |
14 | eib_plot <- eib.plot(he, graph = "ggplot2", title = "my title")
15 | # vdiffr::expect_doppelganger(title = "eib plot ggplot", fig = eib_plot)
16 | })
17 |
--------------------------------------------------------------------------------
/tests/testthat/test-summary.R:
--------------------------------------------------------------------------------
1 |
2 | # library(BCEA)
3 |
4 | ##TODO:
5 | # data(Vaccine, package = "BCEA")
6 | # he <- bcea(eff = e, cost = c, interventions = treats, ref = 2)
7 | #
8 | # test_that("vaccine data", {
9 | #
10 | # testthat::local_edition(3)
11 | # expect_snapshot_output(summary(he))
12 | # })
13 |
14 | # test_that("smoking data", {
15 | # load("bcea_smoking.RData")
16 | #
17 | # testthat::local_edition(3)
18 | # expect_snapshot_output(summary(he))
19 | # })
20 |
21 |
22 | test_that("eib in summary print is same as bcea", {
23 |
24 | load(test_path("ce_vaccine.RData"))
25 |
26 | vacc_bcea <- bcea(eff, cost, ref = 1, interventions = c("1", "2"))
27 |
28 | capture_wtp <- capture.output(summary(vacc_bcea, wtp = 20000))
29 |
30 | expect_equal(tolerance = 0.0001,
31 | as.double(strsplit(capture_wtp[17], split = " ")[[1]][4]),
32 | vacc_bcea$eib[201])
33 |
34 | capture_wtp <- capture.output(summary(vacc_bcea, wtp = 30000))
35 |
36 | expect_equal(tolerance = 0.0001,
37 | as.double(strsplit(capture_wtp[17], split = " ")[[1]][4]),
38 | vacc_bcea$eib[301])
39 | })
40 |
41 |
42 | test_that("subset of interventions included in comp and ref", {
43 |
44 | load(test_path("ce_smoking.RData"))
45 |
46 | # just dont error
47 | smoke_bcea <- bcea(eff, cost, ref = 1)
48 | expect_output(summary(smoke_bcea),
49 | regexp = "Cost-effectiveness analysis summary")
50 |
51 | smoke_bcea <- bcea(eff, cost, ref = 1, .comparison = c(2,4))
52 | expect_output(summary(smoke_bcea),
53 | regexp = "Cost-effectiveness analysis summary")
54 |
55 | smoke_bcea <- bcea(eff, cost, ref = 1, .comparison = 3)
56 | expect_output(summary(smoke_bcea),
57 | regexp = "Cost-effectiveness analysis summary")
58 |
59 | smoke_bcea <- bcea(eff, cost, ref = 1, .comparison = c(2,4), interventions = c("a", "b", "c", "d"))
60 | expect_output(summary(smoke_bcea),
61 | regexp = "Cost-effectiveness analysis summary")
62 | })
63 |
64 |
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_GAM_default.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_GAM_default.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_gam.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_gam.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_gam_3_residuals.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_gam_3_residuals.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_gam_residuals.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_gam_residuals.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_gp.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_gp.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_gp_3_residuals.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_gp_3_residuals.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_gp_residuals.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_gp_residuals.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_idx.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_idx.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_inla_3_residuals.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_inla_3_residuals.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_inla_default.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_inla_default.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_inla_residuals.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_inla_residuals.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_psa.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_psa.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_sad_default.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_sad_default.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_sad_residuals.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_sad_residuals.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_smoke.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_smoke.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/EVPPI_so_default.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/EVPPI_so_default.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/bugsfit.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/bugsfit.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/ce.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/ce.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/jagsfit.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/jagsfit.RData
--------------------------------------------------------------------------------
/tests/testthat/testdata/stanfit.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giabaio/BCEA/152c2b444a31bdef3cf84451fd690eeeb64cbb9d/tests/testthat/testdata/stanfit.RData
--------------------------------------------------------------------------------
/vignettes/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 | *.R
3 | figure
--------------------------------------------------------------------------------
/vignettes/bcea.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Getting Started"
3 | output: rmarkdown::html_vignette
4 | vignette: >
5 | %\VignetteIndexEntry{Getting Started}
6 | %\VignetteEngine{knitr::rmarkdown}
7 | %\VignetteEncoding{UTF-8}
8 | ---
9 |
10 | ```{r, include = FALSE}
11 | knitr::opts_chunk$set(
12 | collapse = TRUE,
13 | comment = "#>"
14 | )
15 | ```
16 |
17 | This vignette will demonstrate a simple cost-effectiveness analysis using __BCEA__ using the smoking cessation data set contained in the package.
18 |
19 | ```{r setup, warning=FALSE, message=FALSE}
20 | library(BCEA)
21 | ```
22 |
23 | Load the data.
24 |
25 | ```{r}
26 | data(Smoking)
27 | ```
28 |
29 | This study has four interventions.
30 |
31 | ```{r}
32 | treats <- c("No intervention", "Self-help", "Individual counselling", "Group counselling")
33 | ```
34 |
35 | Setting the reference group (`ref`) to _Group counselling_ and the maximum willingness to pay (`Kmax`) as 500.
36 |
37 | ```{r}
38 | bcea_smoke <- bcea(eff, cost, ref = 4, interventions = treats, Kmax = 500)
39 | ```
40 |
41 | We can easily create a grid of the most common plots
42 |
43 | ```{r fig.width=10, fig.height=10}
44 | library(ggplot2)
45 | library(purrr)
46 |
47 | plot(bcea_smoke)
48 | ```
49 |
50 | Individual plots can be plotting using their own functions.
51 |
52 | ```{r}
53 | ceplane.plot(bcea_smoke, comparison = 2, wtp = 250)
54 |
55 | eib.plot(bcea_smoke)
56 |
57 | contour(bcea_smoke)
58 |
59 | ceac.plot(bcea_smoke)
60 |
61 | ib.plot(bcea_smoke)
62 | ```
63 |
64 | More on this in the other vignettes but you can change the default plotting style, such as follows.
65 |
66 | ```{r}
67 | plot(bcea_smoke,
68 | graph = "ggplot2",
69 | wtp = 250,
70 | line = list(color = "red", size = 1),
71 | point = list(color = c("plum", "tomato", "springgreen"), shape = 3:5, size = 2),
72 | icer = list(color = c("red", "orange", "black"), size = 5))
73 | ```
74 |
75 |
76 |
--------------------------------------------------------------------------------
/vignettes/paired_vs_multiple_comps.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Paired vs Multiple Comparisons"
3 | output: rmarkdown::html_vignette
4 | vignette: >
5 | %\VignetteIndexEntry{Paired vs Multiple Comparisons}
6 | %\VignetteEngine{knitr::rmarkdown}
7 | %\VignetteEncoding{UTF-8}
8 | ---
9 |
10 | ```{r, include = FALSE}
11 | knitr::opts_chunk$set(
12 | collapse = TRUE,
13 | comment = "#>",
14 | fig.width = 6
15 | )
16 | ```
17 |
18 | ```{r setup, results='hide', message=FALSE, warning=FALSE, echo=FALSE}
19 | library(BCEA)
20 | library(dplyr)
21 | library(reshape2)
22 | library(ggplot2)
23 | library(purrr)
24 | ```
25 |
26 | ## Introduction
27 |
28 | The intention of this vignette is to show how to plot the CEAC and EIB plots depending on whether we consider all interventions simultaneously or pair-wise against a reference.
29 |
30 | ## Multiple interventions
31 |
32 | This situation is when there are more than two interventions to consider.
33 | Incremental values can be obtained either always against a fixed reference intervention, such as status-quo, or for all comparisons simultaneously.
34 | We will call these a paired comparison or a multiple comparison.
35 |
36 | ### Against a fixed reference intervention
37 |
38 | #### R code
39 |
40 | This is the default plot for `ceac.plot()` so we simply follow the same steps as above with the new data set.
41 |
42 | ```{r}
43 | data("Smoking")
44 | he <- bcea(eff, cost, ref = 4, Kmax = 500)
45 | ```
46 |
47 | ```{r fig.height=10}
48 | par(mfrow = c(2,1))
49 | ceac.plot(he)
50 | abline(h = 0.5, lty = 2)
51 | abline(v = c(160, 225), lty = 3)
52 | eib.plot(he, plot.cri = FALSE)
53 | ```
54 |
55 |
56 | ### Pair-wise comparisons
57 |
58 | #### R code
59 |
60 | In _BCEA_ we first we must determine all combinations of paired interventions using the `multi.ce()` function.
61 |
62 | ```{r}
63 | he.multi <- multi.ce(he)
64 | ```
65 |
66 | ```{r fig.height=10}
67 | par(mfrow = c(2, 1))
68 | ceac.plot(he.multi)
69 | abline(h = 0.5, lty = 2)
70 | abline(v = c(160, 225), lty = 3)
71 | eib.plot(he, plot.cri = FALSE)
72 | ```
73 |
74 |
--------------------------------------------------------------------------------