sample.GDS: Collect draws from the target posterior distribution

Description Usage Arguments Value References

Description

Runs the accept-reject phase of the Braun and Damien (2015) algorithm for scalable rejection sampling.

Usage

1
2
3
sample.GDS(n.draws, log.phi, post.mode, fn.dens.post, fn.dens.prop,
  fn.draw.prop, prop.params, ..., max.tries = 1e+06, report.freq = 1,
  announce = FALSE, thread.id = 1, seed = .Random.seed)

Arguments

n.draws

number of draws to take from the target posterior density.

log.phi

Vector of log.phi, as computed from the proposal draws.

post.mode

Mode of the target posterior density (numeric vector).

fn.dens.post

Function that returns the log posterior density. Function should take the parameter vector as the first argument. Additional arguments are passed as ...

fn.dens.prop

Function that returns the log density of the proposal distribution. The first argument of the function should take either a vector or a matrix. If the argument is a matrix, each row is considered a sample. Additional parameters are passed as a list, prop.params.

fn.draw.prop

Function that returns random samples from the proposal density. This function should return a matrix, with each row being a sample. Additional parameters are passed as a list, prop.params.

prop.params

Object (list or vector) to be passed to both fn.dens.prop and fn.draw.prop.Contains parameters for the proposal distribution. See details.

...

Additional parameters to be passed to fn.dens.post.

max.tries

Maximum number of proposal draws to try, without a success. This prevents the routine from being stuck in an endless loop.

report.freq

The frequency that the function will report the current iteration. For example, if report.freq=5, the function will display a message after every fifth iteration.

announce

If TRUE, will print a message when a proposal is accepted as a sample from the target posterior distribution.

thread.id

An identifier used in the announce function. This is useful if running sample.GDS on multiple processors, to collect multiple batches of samples. Defaults to 1.

seed

Sets a random seed within the call to sample.GDS. Useful for assigning different seeds to calls to sample.GDS that are running on different threads or processors. Defaults to .Random.seed.

Value

a list with the following elements:

draws

A matrix with each draw in a row, and each parameter in a column

counts

The number of attempts that it took to get an accepted draw. The accepted draw counts, so the count will always be at least 1.

gt.1

A vector that indicates if the phi for that draw was greater than 1. Available as a diagnostic. Normally, these should all be FALSE. Any values of TRUE suggest that a change in proposal density might be warranted.

log.post.dens

A numeric vector. Log posterior density for each draw.

log.prop.dens

A numeric vector. Log of the proposal density for each draw.

log.thresholds

Vector of threshold draws (log u) from the accept-reject algorithm. Sorted in ascending order.

log.phi

A numeric vector. Value of log.phi for the accepted draws.

References

Braun, Michael and Paul Damien (2015). Scalable Rejection Sampling for Bayesian Hierarchical Models. Marketing Science. Articles in Advance. http://doi.org/10.1287/mksc.2014.0901


braunm/bayesGDS documentation built on May 13, 2019, 2:31 a.m.