Skip to content

Commit

Permalink
doc check
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Nov 28, 2019
1 parent b5c7c53 commit af8d9f9
Show file tree
Hide file tree
Showing 36 changed files with 183 additions and 142 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# getTBinR 0.1.0
# SpeedyMarkov 0.1.0

## Feature updates

Expand Down
10 changes: 5 additions & 5 deletions R/analyse_ce.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#'
#'
#'@description This function produces cost effectiveness summary measures using the output of `markov_simulation_pipeline`
#' or similar data structures. At least two intervetions must be present.
#' or similar data structures. At least two interventions must be present.
#' @param markov_simulations A dataframe of markov samples and simulations as produced by `markov_simulation_pipeline`. At least two
#' interventions must be present.
#' @param baseline Numeric, the intervetion to consider as the baseline for pairwise comparisons.
#' @param willingness_to_pay_thresold Numeric, defaulting to 20,000. This is the thresold at which an intervention
#' @param baseline Numeric, the intervention to consider as the baseline for pairwise comparisons.
#' @param willingness_to_pay_threshold Numeric, defaulting to 20,000. This is the threshold at which an intervention
#' may be considered cost effective in the UK.
#' @param type A character string specifying the approach to use to simulate the model. Currently implemented
#' approaches are "base" with "base" as the default.
Expand All @@ -25,7 +25,7 @@
#'
analyse_ce <- function(markov_simulations = NULL,
baseline = 1,
willingness_to_pay_thresold = 20000,
willingness_to_pay_threshold = 20000,
type = "base") {

## NULL out variables to deal with package notes
Expand All @@ -41,7 +41,7 @@ analyse_ce <- function(markov_simulations = NULL,
list(total_costs - total_costs[baseline],
total_qalys - total_qalys[baseline]),
by = "sample"][,
incremental_net_benefit := willingness_to_pay_thresold * incremental_qalys - incremental_costs
incremental_net_benefit := willingness_to_pay_threshold * incremental_qalys - incremental_costs
,]

## Summarise costs
Expand Down
2 changes: 1 addition & 1 deletion R/example_two_state_markov.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' but instead represents a model definition.
#'
#' @return A named list of functions that all require a samples argument. The list contains:
#' * transitions_list: a list of transition functions, with the first taking the number of samples as an arguement
#' * transitions_list: a list of transition functions, with the first taking the number of samples as an argument
#' and the following being dependent on the a previous transition.
#' * qalys: a function that samples the qaly cost for each intervention.
#' * intervention_costs: a function that returns the costs for each intervention.
Expand Down
6 changes: 4 additions & 2 deletions R/markov_ce_pipeline.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#' Markov Sampling, Simulation, and Cost Effectiveness Analysis Pipeline
#'
#' @description This functions wraps multiple modular functions and allows an end-to-end cost effectiveness to
#' be run, including final analysis of the findings.
#' @return A list containing the model samples and simulations and cost effectiveness summary measures.
#' @export
#' @inheritParams markov_simulation_pipeline
Expand All @@ -11,7 +13,7 @@
#'
markov_ce_pipeline <- function(markov_model = NULL, duration = NULL,
discount = 1.035, samples = 1, baseline = 1,
willingness_to_pay_thresold = 20000,
willingness_to_pay_threshold = 20000,
sample_type = "base", sim_type = "base", debug = FALSE,
batches = 1, batch_fn = NULL, ...) {

Expand All @@ -31,7 +33,7 @@ markov_ce_pipeline <- function(markov_model = NULL, duration = NULL,
# Analyse model -----------------------------------------------------------

sum <- SpeedyMarkov::analyse_ce(simulations, baseline = baseline,
willingness_to_pay_thresold = willingness_to_pay_thresold)
willingness_to_pay_threshold = willingness_to_pay_threshold)

return(sum)
}
Expand Down
2 changes: 1 addition & 1 deletion R/markov_loop.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @param transition A transition matrix, see `example_two_state_markov` for an example of setting this up.
#' @param duration Numeric, how many long to run the model for.
#'
#' @return A matrix of the same size as the inputed sim matrix.
#' @return A matrix of the same size as the inputted sim matrix.
#' @export
#'
#' @examples
Expand Down
5 changes: 4 additions & 1 deletion R/markov_simulation_pipeline.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#' Markov Sampling and Simulation Pipeline
#'
#' @description This functions wraps multiple modular functions and allows an end-to-end cost effectiveness to
#' be run, excluding the final analysis of the findings. It may also be used in batch mode to run analyses in
#' parallel.
#' @param samples Numeric, defaults to 1. The number of markov model samples to use.
#' @param sample_type A character string specifying the approach to use to sample the model.
#' Options and defaults inherited from `sample_markov`.
Expand All @@ -11,7 +14,7 @@
#' be to use a batch number that corresponds to the number of cores being utilised.
#' @param batch_fn Function, defaults to `NULL`. This is the function to be used to parallise across batches. Potential options
#' include `parallel::mclapply` (not Windows) or `furrr::future_map` (requires the use of `future::plan` outside the function). When
#' not given the funciton will default to using no batching.
#' not given the function will default to using no batching.
#' @param ... Additional options to pass to `batch_fn`. For example this may be the `mc.cores` argument of `parallel::mclapply`.
#' @return A list containing the model samples and simulations.
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/reference_two_state_markov.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' over using a series of nested for loops with a core loop running a the markov model for each sample and intervention.
#' Profiling suggestions that this core loop may take the majority of compute time.
#'
#' @param cycles Numeric, the number of cylces (time horizon / cycle length). No default supplied.
#' @param cycles Numeric, the number of cycles (time horizon / cycle length). No default supplied.
#' @param samples Numeric, the number of samples to use. No default supplied.
#' @return A named list of cost effectiveness output.
#' @export
Expand Down
4 changes: 2 additions & 2 deletions R/simulate_markov.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ simulate_markov <- function(markov_sample = NULL,
#' @param intervention_cost A vector of intervention costs, see `example_two_state_markov` for an example of setting this up.
#' @param qalys A list of QALYs for each intervention, see `example_two_state_markov` for an example of setting this up.
#' @param discounting Numeric vector, the discount that should be applied to the costs and QALYs for each time period.
#' This must be the same legnth as `duration`.
#' This must be the same length as `duration`.
#' @param sim Matrix with the same number of rows as the duration of the model and the same number of columns as the number of
#' states in the model. Used to store model simulatons.
#' states in the model. Used to store model simulations.
#' @param markov_loop_fn A function, defaults to ] \code{NULL}. The function to use to solve the inner markov loops. Built in examples
#' are `markov_loop` (using `R`) and `ArmaMarkovLoop` (using `RcppArmadillo`)
#' @return A list containing total costs and total QALYs as matrices across states
Expand Down
14 changes: 7 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ knitr::opts_chunk$set(

**Work in progress**

This package aims to:
This package:

* Compare a functional markov modelling approach to a reference approach for several example models.
* Explore approaches to speeding up Markov modelling in a principled fashion making use of C++ when required.
* Detail the benefits of parallisation and provide a code structure in which parallisation is easy to make use of.
* Provide a toolkit for use in discrete Markov modelling.
* Provide optimised code that may be ported into other applications and workflows.
* Compares a functional markov modelling approach to a reference approach for several example models.
* Explores approaches to speeding up Markov modelling in a principled fashion making use of C++ when required.
* Details the benefits of parallisation and provide a code structure in which parallisation is easy to make use of.
* Provides a toolkit for use in discrete Markov modelling.
* Provides optimised code that may be ported into other applications and workflows.

The work in this package was started at the Health Economic 2019 hackathon hosted at Imperial. Much of this work is based on that developed by the [hermes6](https://github.com/HealthEconomicsHackathon/hermes6) team. The original reference approach was developed by [Howard Thom](https://orcid.org/0000-0001-8576-5552).

Expand Down Expand Up @@ -60,7 +60,7 @@ remotes::install_github("seabbs/SpeedyMarkov")

## Quick start

The first step is to specify a Markov model in the format specificed by `SpeedyMarkov`. An example framework is `example_two_state_markov` which is a two state Markov model that compares an intervention to a baseline. See `?example_two_state_markov` for more details.
The first step is to specify a Markov model in the format specified by `SpeedyMarkov`. An example framework is `example_two_state_markov` which is a two state Markov model that compares an intervention to a baseline. See `?example_two_state_markov` for more details.

```{r}
SpeedyMarkov::example_two_state_markov()
Expand Down
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

**Work in progress**

This package aims to:
This package:

- Compare a functional markov modelling approach to a reference
- Compares a functional markov modelling approach to a reference
approach for several example models.
- Explore approaches to speeding up Markov modelling in a principled
- Explores approaches to speeding up Markov modelling in a principled
fashion making use of C++ when required.
- Detail the benefits of parallisation and provide a code structure in
which parallisation is easy to make use of.
- Provide a toolkit for use in discrete Markov modelling.
- Provide optimised code that may be ported into other applications
- Details the benefits of parallisation and provide a code structure
in which parallisation is easy to make use of.
- Provides a toolkit for use in discrete Markov modelling.
- Provides optimised code that may be ported into other applications
and workflows.

The work in this package was started at the Health Economic 2019
Expand Down Expand Up @@ -62,7 +62,7 @@ Status](https://img.shields.io/codecov/c/github/seabbs/SpeedyMarkov/master.svg)]

## Quick start

The first step is to specify a Markov model in the format specificed by
The first step is to specify a Markov model in the format specified by
`SpeedyMarkov`. An example framework is `example_two_state_markov` which
is a two state Markov model that compares an intervention to a baseline.
See `?example_two_state_markov` for more details.
Expand All @@ -81,8 +81,8 @@ SpeedyMarkov::example_two_state_markov()
#>
#> return(tmp)
#> }
#> <bytecode: 0x55b103d9a6e8>
#> <environment: 0x55b103de7060>
#> <bytecode: 0x558322c5d100>
#> <environment: 0x558322ca9a78>
#>
#> $transitions_list$`Soc with Website`
#> function(baseline = NULL) {
Expand All @@ -100,8 +100,8 @@ SpeedyMarkov::example_two_state_markov()
#>
#> return(updated)
#> }
#> <bytecode: 0x55b103da26e8>
#> <environment: 0x55b103de7060>
#> <bytecode: 0x558322c631e0>
#> <environment: 0x558322ca9a78>
#>
#>
#> $qalys
Expand All @@ -126,8 +126,8 @@ SpeedyMarkov::example_two_state_markov()
#>
#> return(out)
#> }
#> <bytecode: 0x55b103dad2c8>
#> <environment: 0x55b103de7060>
#> <bytecode: 0x558322c6fca8>
#> <environment: 0x558322ca9a78>
#>
#> $intervention_costs
#> function(samples = NULL) {
Expand All @@ -139,8 +139,8 @@ SpeedyMarkov::example_two_state_markov()
#>
#> return(out)
#> }
#> <bytecode: 0x55b103dc09c0>
#> <environment: 0x55b103de7060>
#> <bytecode: 0x558322c7f5a8>
#> <environment: 0x558322ca9a78>
#>
#> $state_costs
#> function(samples = NULL) {
Expand All @@ -164,8 +164,8 @@ SpeedyMarkov::example_two_state_markov()
#>
#> return(out)
#> }
#> <bytecode: 0x55b103dc44f0>
#> <environment: 0x55b103de7060>
#> <bytecode: 0x558322c86f08>
#> <environment: 0x558322ca9a78>
#>
#> $cohorts
#> function(samples = NULL) {
Expand All @@ -189,8 +189,8 @@ SpeedyMarkov::example_two_state_markov()
#>
#> return(out)
#> }
#> <bytecode: 0x55b103dd7db8>
#> <environment: 0x55b103de7060>
#> <bytecode: 0x558322c95228>
#> <environment: 0x558322ca9a78>
#>
#> attr(,"class")
#> [1] "SpeedyMarkov" "list"
Expand Down Expand Up @@ -236,8 +236,8 @@ SpeedyMarkov::markov_ce_pipeline(SpeedyMarkov::example_two_state_markov(),
#> # A tibble: 2 x 13
#> intervention mean_costs sd_costs mean_qalys sd_qlays mean_incrementa…
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 SoC 0 0 14.0 0.105 0
#> 2 Soc with We… 50 0 14.0 0.115 0.0279
#> 1 SoC 0 0 14.0 0.0790 0
#> 2 Soc with We… 50 0 14.0 0.0727 -0.0148
#> # … with 7 more variables: sd_incremental_qlays <dbl>,
#> # mean_incremental_costs <dbl>, sd_incremental_costs <dbl>,
#> # mean_incremental_net_benefit <dbl>, sd_incremental_net_benefit <dbl>,
Expand Down
2 changes: 1 addition & 1 deletion docs/articles/benchmarking.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/profile_reference.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/articles/profile_two_state_example.html

Large diffs are not rendered by default.

Loading

0 comments on commit af8d9f9

Please sign in to comment.