sample.GDS: Collect draws from the target posterior distribution

Description Usage Arguments Value References

View source: R/sample.R


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


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



number of draws to take from the target posterior density.


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


Mode of the target posterior density (numeric vector).

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


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.


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.


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


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


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.


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

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.


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.


a list with the following elements:


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


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.


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.

A numeric vector. Log posterior density for each draw.


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


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


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


Braun, Michael and Paul Damien (2015). Scalable Rejection Sampling for Bayesian Hierarchical Models. Marketing Science. Articles in Advance.

bayesGDS documentation built on May 29, 2017, 11:26 p.m.