Skip to contents

Introduction to IMABC

A thorough introduction to Incremental Mixture Approximate Bayesian Computation (IMABC) method can be found in C. M. Rutter et al. (2019). Here we will walk through the code found in C. Rutter et al. (2022).

Step 1 - Define the priors

For a more detailed explanation of how the priors functions work, see the vignette("priors")

priors <- define_priors(
  # x1: Uniform Prior (from base R)
  x1 = add_prior(
    dist_base_name = "unif",
    min = 0.2, max = 0.9
  ),
  # x2: Truncated Normal (from truncnorm package)
  add_prior(
    parameter_name = "x2",
    density_fn = "dtruncnorm",
    mean = 0.5, sd = 0.05, a = 0.4, b = 0.8, # a = min and b = max
    min = 0.4, max = 0.8 # User must specify both in truncnorm
  ),
  # V3: Fixed parameter (not calibrated)
  add_prior(0.5)
)

Step 2 - Define target values

A more detailed description will be available in the near future at vignette("targets")

targets <- define_targets(
  # G1: Grouped targets include T1 and T2
  G1 = group_targets(
    T1 = add_target(
      target = 1.5,
      starting_range = c(1.0, 2.0),
      stopping_range = c(1.49, 1.51)
    ),
    add_target(
      target_name = "T2",
      target = 0.5,
      starting_range = c(0.2, 0.9),
      stopping_range = c(0.49, 0.51)
    )
  )
)

Step 3 - Define the target function

A more detailed description will be available in the near future at vignette("target_functions")

fn1 <- function(x1, x2) { x1 + x2 + sample(c(-1, 1), 1)*rnorm(1, 0, 0.1) }
fn2 <- function(x1, x2) { x1 * x2 + sample(c(-1, 1), 1)*rnorm(1, 0, 0.1) }
fn <- function(x1, x2) {
  res <- c()
  res["T2"] <- fn1(x1, x2)
  res["T1"] <- fn2(x1, x2)
  return(res)
}
target_fun <- define_target_function(
  targets, priors, FUN = fn, use_seed = FALSE
)

Step 4 - Calibrate the model

The primary function is imabc(). The inputs and their descriptions are as follows:

calibration_results <- imabc(
  priors = priors,
  targets = targets_nogroup,
  target_fun = target_fun,
  seed = 54321,
  N_start = 2000,
  N_centers = 2,
  Center_n = 500,
  N_cov_points = 50,
  N_post = 100
)
Rutter, Carolyn M., Jonathan Ozik, Maria Deyoreo, and Nicholson Collier. 2019. “Microsimulation Model Calibration Using Incremental Mixture Approximate Bayesian Computation.” Annals of Applied Statistics 13 (4): 2189–2212. https://doi.org/10.1214/19-AOAS1279.
Rutter, Carolyn, Jonathan Ozik, Nicholson Collier, and Christopher E. Maerzluft. 2022. Imabc: Incremental Mixture Approximate Bayesian Computation (IMABC). https://github.com/c-rutter/imabc.