Skip to contents

Run Probabilistic Uncertainty Analysis

Usage

run_psa(model, psa, N, keep = FALSE)

Arguments

model

The result of run_model().

psa

Resampling distribution for parameters defined by define_psa().

N

> 0. Number of simulation to run.

keep

logical; if TRUE, all models will be returned

Value

A list with the following elements

  • psa: a data.frame with one row per model.

  • run_model: a data.frame with mean cost and utility for each strategy

  • model: the initial model object

  • N: the number of simulations ran

  • resamp_par: the resampled parameters

  • full: if keep is TRUE, a list of each model objects created at each iteration

Examples

# example for run_psa

mod1 <- define_strategy(
  transition = define_transition(
    .5, .5,
    .1, .9
  ),
  define_state(
    cost = cost_init + age * 5,
    ly = 1
  ),
  define_state(
    cost = cost_init + age,
    ly = 0
  )
)
#> No named state -> generating names.
#> No named state -> generating names.

mod2 <- define_strategy(
  transition = define_transition(
    p_trans, C,
    .1, .9
  ),
  define_state(
    cost = 789 * age / 10,
    ly = 1
  ),
  define_state(
    cost = 456 * age / 10,
    ly = 0
  )
  
)
#> No named state -> generating names.
#> No named state -> generating names.

res2 <- run_model(
  mod1, mod2,
  parameters = define_parameters(
    age_init = 60,
    cost_init = 1000,
    age = age_init + model_time,
    p_trans = .7
  ),
  init = 1:0,
  cycles = 10,
  cost = cost,
  effect = ly
)
#> No named model -> generating names.

rsp <- define_psa(
  age_init ~ normal(60, 10),
  cost_init ~ normal(1000, 100),
  p_trans ~ binomial(.7, 100),
  correlation = matrix(c(
    1,  .4, 0,
    .4, 1,  0,
    0,  0,  1
  ), byrow = TRUE, ncol = 3)
)


# with run_model result
# (only 10 resample for speed)
ndt1 <- run_psa(res2, psa = rsp, N = 10)
#> Resampling strategy 'I'...
#> Resampling strategy 'I'...
#> Resampling strategy 'II'...
#> Resampling strategy 'II'...