SABC: Simulated Annealing approach to Approximate Bayesian...

Description Usage Arguments Details Value Author(s) References Examples

Description

Algorithms for the Simulated Annealing approach to Approximate Bayesian Computation (SABC).

Usage

1
2
3
4
5
SABC(r.model, r.prior, d.prior, n.sample, eps.init, iter.max,
     v=ifelse(method=="informative",0.4,1.2), beta=0.8,
     delta=0.1, resample=5*n.sample, verbose=n.sample,
     method="noninformative", adaptjump=TRUE,
     summarystats=FALSE, y=NULL, f.summarystats=NULL, ...)

Arguments

r.model

Function that returns either a random sample from the likelihood or a scalar distance between such a sample and the data. The first argument must be the parameter vector.

r.prior

Function that returns a random sample from the prior.

d.prior

Function that returns the density of the prior distribution.

n.sample

Size of the ensemble.

eps.init

Initial tolerance or temperature.

iter.max

Total number of simulations from the likelihood.

v

Tuning parameter that governs the annealing speed. Defaults to 1.2, for the noninformative algorithm and 0.4, for the informative algorithm.

beta

Tuning parameter that governs the mixing in parameter space. Defaults to 0.8.

delta

Tuning parameter for the resampling steps. Defaults to 0.1.

resample

Number of accepted particle updates after which a resampling step is performed. Defaults to 5*n.sample.

verbose

Shows the iteration progress each verbose simulations from the likelihood. NULL for no output. Defaults to verbose = n.sample.

adaptjump

Whether to adapt covariance of jump distribution. Default is TRUE.

method

Argument to select algorithm. Accepts noninformative or informative.

summarystats

Whether summary statistics shall be calculated (semi-) automatically. Defaults to FALSE.

y

Data vector. Needs to be provided if either summarystats = TRUE or if r.model returns a sample from the likelihood.

f.summarystats

If summarystats = TRUE this function is needed for the calculation of the summary statistics. Defaults to f.summarystats(x)=(x,x^2,x^3), where the powers are to be understood element-wise.

...

further arguments passed to r.model

Details

SABC defines a class of algorithms for particle ABC that are inspired by Simulated Annealing. Unlike other algorithms, this class is not based on importance sampling, and hence does not suffer from a loss of effective sample size due to re-sampling. The approach is presented in detail in Albert, Kuensch, and Scheidegger (2014; see references).

This package implements two versions of SABC algorithms, for the cases of a non-informative or an informative prior. These are described in detail in the paper. The algorithms can be selected using the method argument: method=noninformative or method=informative. In the informative case, the algorithm corrects for the bias caused by an over- or under-representation of the prior.

The argument adaptjump allows a choice of whether to adapt the covariance of the jump distribution. Default is TRUE.

Furthermore, the package allows for three different ways of using the data. If y is not provided, the algorithm expects r.model to return a scalar measuring the distance between a random sample from the likelihood and the data. If y is provided and summarystats = FALSE, the algorithm expects r.model to return a random sample from the likelihood and uses the relative sum of squares to measure the distances between y and random likelihood samples. If summarystats = TRUE the algorithm calculates summary statistics semi-automatically, as described in detail in the paper by Fearnhead et al. (2012; see references). The summary statistics are calculated by means of a linear regression applied to a sample from the prior and the image of f.summarystats of an associated sample from the likelihood.

Value

Returns a list with the following components:

E

Matrix with ensemble of samples.

P

Matrix with prior ensemble of samples.

eps

Value of tolerance (temperature) at final iteration.

ESS

Effective sample size, due to final bias correction (informative algorithm only).

Author(s)

Carlo Albert <carlo.albert@eawag.ch>, Andreas Scheidegger, Tobia Fasciati. Package initially compiled by Lukas M. Weber.

References

C. Albert, H. R. Kuensch and A. Scheidegger, Statistics and Computing 0960-3174 (2014), arXiv:1208.2157, A Simulated Annealing Approach to Approximate Bayes Computations.

P. Fearnhead and D. Prangle, J. R. Statist. Soc. B 74 (2012), Constructing summary statistics for approximate Bayesian computation: semi-automatic approximate Bayesian computation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
 ## Not run:  
## Example for "noninformative" case
# Prior is uniform on [-10,10]
d.prior <- function(par)
    dunif(par,-10,10)
r.prior <- function()
    runif(1,-10,10)

# Model is the sum of two normal distributions. Return distance to observation 0:
f.dist <- function(par)
    return( abs(rnorm( 1 , par , ifelse(runif(1)<0.5,1,0.1 ) )))

# Run algorithm ("noninformative" case)
res <- SABC(f.dist,r.prior,d.prior,n.sample=500,eps.init=2,iter.max=50000)
 
## End(Not run)

 ## Not run: 
# Histogram of results
hist(res$E[,1],breaks=200)
 
## End(Not run)

Example output

Loading required package: abc
Loading required package: abc.data
Loading required package: nnet
Loading required package: quantreg
Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve

Loading required package: MASS
Loading required package: locfit
locfit 1.5-9.1 	 2013-03-22
updates 6.116 % 	 eps  0.07862174 	 u.mean 0.1806591 
updates 7.116 % 	 eps  0.06594613 	 u.mean 0.1570758 
updates 8.116 % 	 eps  0.05658461 	 u.mean 0.1391251 
updates 9.116 % 	 eps  0.04722193 	 u.mean 0.1206052 
updates 10.116 % 	 eps  0.04030466 	 u.mean 0.1064707 
updates 11.116 % 	 eps  0.03423051 	 u.mean 0.09366458 
updates 12.116 % 	 eps  0.02978602 	 u.mean 0.0840086 
updates 13.116 % 	 eps  0.02509272 	 u.mean 0.07349023 
updates 14.116 % 	 eps  0.02159585 	 u.mean 0.06539093 
updates 15.116 % 	 eps  0.01973803 	 u.mean 0.06097889 
updates 16.116 % 	 eps  0.01782054 	 u.mean 0.05633307 
updates 17.116 % 	 eps  0.01598018 	 u.mean 0.05177404 
updates 18.116 % 	 eps  0.01424343 	 u.mean 0.04736826 
updates 19.116 % 	 eps  0.01257731 	 u.mean 0.04303206 
updates 20.116 % 	 eps  0.0115393 	 u.mean 0.04026818 
updates 21.116 % 	 eps  0.0107103 	 u.mean 0.03802189 
Resampling. Effective sampling size:  492.5573 
updates 22.116 % 	 eps  0.007245253 	 u.mean 0.02816419 
updates 23.116 % 	 eps  0.006450074 	 u.mean 0.02576544 
updates 24.116 % 	 eps  0.005868194 	 u.mean 0.02396794 
updates 25.116 % 	 eps  0.005371113 	 u.mean 0.02240031 
updates 26.116 % 	 eps  0.00494535 	 u.mean 0.02103127 
updates 27.116 % 	 eps  0.004402828 	 u.mean 0.01924707 
updates 28.116 % 	 eps  0.004089518 	 u.mean 0.0181939 
updates 29.116 % 	 eps  0.003770077 	 u.mean 0.01710086 
updates 30.116 % 	 eps  0.003530236 	 u.mean 0.01624785 
updates 31.116 % 	 eps  0.003363105 	 u.mean 0.01565833 
updates 32.116 % 	 eps  0.003158066 	 u.mean 0.01492572 
updates 33.116 % 	 eps  0.00296313 	 u.mean 0.01421892 
updates 34.116 % 	 eps  0.00278336 	 u.mean 0.01355747 
updates 35.116 % 	 eps  0.002627464 	 u.mean 0.01297576 
updates 36.116 % 	 eps  0.002502055 	 u.mean 0.01250195 
updates 37.116 % 	 eps  0.002390509 	 u.mean 0.01207584 
updates 38.116 % 	 eps  0.002316072 	 u.mean 0.0117889 
updates 39.116 % 	 eps  0.00214523 	 u.mean 0.01112197 
updates 40.116 % 	 eps  0.002014016 	 u.mean 0.01060125 
updates 41.116 % 	 eps  0.001943911 	 u.mean 0.01031978 
updates 42.116 % 	 eps  0.001851166 	 u.mean 0.009943706 
updates 43.116 % 	 eps  0.00178569 	 u.mean 0.009675528 
updates 44.116 % 	 eps  0.001683753 	 u.mean 0.009253323 
updates 45.116 % 	 eps  0.001640024 	 u.mean 0.009070367 
updates 46.116 % 	 eps  0.001563517 	 u.mean 0.008747459 
updates 47.116 % 	 eps  0.00149572 	 u.mean 0.00845817 
updates 48.116 % 	 eps  0.001400719 	 u.mean 0.008043002 
updates 49.116 % 	 eps  0.001354564 	 u.mean 0.007836591 
updates 50.116 % 	 eps  0.001292448 	 u.mean 0.007555903 
updates 51.116 % 	 eps  0.00125988 	 u.mean 0.007407349 
updates 52.116 % 	 eps  0.001210084 	 u.mean 0.007178264 
updates 53.116 % 	 eps  0.001148624 	 u.mean 0.006892103 
updates 54.116 % 	 eps  0.001116225 	 u.mean 0.00673964 
updates 55.116 % 	 eps  0.001066205 	 u.mean 0.006501955 
updates 56.116 % 	 eps  0.001042723 	 u.mean 0.006389367 
updates 57.116 % 	 eps  0.001024718 	 u.mean 0.00630258 
updates 58.116 % 	 eps  0.001009535 	 u.mean 0.006229085 
updates 59.116 % 	 eps  0.0009556034 	 u.mean 0.005965598 
updates 60.116 % 	 eps  0.0009307495 	 u.mean 0.005842846 
updates 61.116 % 	 eps  0.0009170527 	 u.mean 0.005774824 
updates 62.116 % 	 eps  0.0009040365 	 u.mean 0.00570993 
updates 63.116 % 	 eps  0.000901846 	 u.mean 0.005698984 
updates 64.116 % 	 eps  0.0008773785 	 u.mean 0.005576231 
updates 65.116 % 	 eps  0.0008560227 	 u.mean 0.005468335 
updates 66.116 % 	 eps  0.0008487818 	 u.mean 0.005431587 
updates 67.116 % 	 eps  0.0008119168 	 u.mean 0.005243159 
updates 68.116 % 	 eps  0.0008061448 	 u.mean 0.005213448 
updates 69.116 % 	 eps  0.0007961465 	 u.mean 0.005161845 
updates 70.116 % 	 eps  0.0007876898 	 u.mean 0.005118061 
updates 71.116 % 	 eps  0.0007816643 	 u.mean 0.005086787 
updates 72.116 % 	 eps  0.0007497936 	 u.mean 0.00492025 
updates 73.116 % 	 eps  0.0007456312 	 u.mean 0.004898358 
updates 74.116 % 	 eps  0.000729636 	 u.mean 0.004813917 
updates 75.116 % 	 eps  0.0007222633 	 u.mean 0.004774824 
updates 76.116 % 	 eps  0.0007036299 	 u.mean 0.004675528 
updates 77.116 % 	 eps  0.0006938542 	 u.mean 0.004623143 
updates 78.116 % 	 eps  0.000688908 	 u.mean 0.00459656 
updates 79.116 % 	 eps  0.000675718 	 u.mean 0.00452541 
updates 80.116 % 	 eps  0.0006748509 	 u.mean 0.004520719 
updates 81.116 % 	 eps  0.0006637498 	 u.mean 0.004460516 
updates 82.116 % 	 eps  0.0006603002 	 u.mean 0.004441751 
updates 83.116 % 	 eps  0.0006422729 	 u.mean 0.004343237 
updates 84.116 % 	 eps  0.0006313253 	 u.mean 0.004283034 
updates 85.116 % 	 eps  0.0006255177 	 u.mean 0.004250977 
updates 86.116 % 	 eps  0.0006207132 	 u.mean 0.004224394 
updates 87.116 % 	 eps  0.0005865431 	 u.mean 0.00403362 
updates 88.116 % 	 eps  0.0005803016 	 u.mean 0.003998436 
updates 89.116 % 	 eps  0.0005731128 	 u.mean 0.00395778 
updates 90.116 % 	 eps  0.0005666373 	 u.mean 0.003921032 
updates 91.116 % 	 eps  0.000560183 	 u.mean 0.003884285 
updates 92.116 % 	 eps  0.000557169 	 u.mean 0.003867084 
updates 93.116 % 	 eps  0.0005462488 	 u.mean 0.003804535 
updates 94.116 % 	 eps  0.0005404049 	 u.mean 0.003770915 
updates 95.116 % 	 eps  0.000528502 	 u.mean 0.003702111 
updates 96.116 % 	 eps  0.0005229826 	 u.mean 0.003670055 
updates 97.116 % 	 eps  0.0005205648 	 u.mean 0.003655981 
updates 98.116 % 	 eps  0.0005093246 	 u.mean 0.003590305 
updates 99.116 % 	 eps  0.0004935241 	 u.mean 0.003497263 
updates 100.116 % 	 eps  0.0004867972 	 u.mean 0.003457389 

EasyABC documentation built on May 2, 2019, 2:40 p.m.