Skip to contents

Draw theta from a uniform prior box, simulate summaries, accept iff the Euclidean distance to the observed summaries is <= eps (Pritchard et al. 1999; algorithm as stated in Sisson-Fan-Beaumont 2018, Sec 1.5).

Usage

Abcrej(sim, obs, eps, prior, n_draws = 1000L, seed = 0L)

Arguments

sim

function(theta, e) returning a summary vector; e is the shared RNG environment (use .ghc_* helpers for stochastic sims).

obs

Observed summary vector.

eps

Acceptance tolerance (> 0).

prior

List of c(low, high) pairs (uniform box).

n_draws

Number of prior draws.

seed

SplitMix64 seed.

Value

List with samples, n_accepted, acceptance_rate, distances, posterior_mean, eps, n_draws, seed, method.

References

Pritchard, J. K., Seielstad, M. T., Perez-Lezaun, A. and Feldman, M. W. (1999), Molecular Biology and Evolution 16(12), 1791-1798; Sisson, S. A., Fan, Y. and Beaumont, M. A. (2018), arXiv:1802.09720, Sec 1.5.

Examples

sim <- function(theta, e) theta[1] + 0.1 * rmorie:::.ghc_norm(e, 1L)
r <- Abcrej(sim, obs = 1.5, eps = 0.3, prior = list(c(0, 3)),
            n_draws = 400)
str(r, max.level = 1)
#> List of 9
#>  $ samples        :List of 84
#>  $ n_accepted     : int 84
#>  $ acceptance_rate: num 0.21
#>  $ distances      : num [1:84] 0.0596 0.083 0.0127 0.2243 0.2808 ...
#>  $ posterior_mean : num 1.49
#>  $ eps            : num 0.3
#>  $ n_draws        : int 400
#>  $ seed           : int 0
#>  $ method         : chr "ABC rejection (Pritchard et al. 1999)"