Title: | PolyaGamma Sampling |
---|---|
Description: | Tools for sampling from the PolyaGamma distribution based on Polson, Scott, and Windle (2013) <doi:10.1080/01621459.2013.829001>. Useful for logistic regression. |
Authors: | Nicholas G. Polson [aut, cph], James G. Scott [aut, cph], Jesse Windle [aut, cre, cph], Jari Oksanen [ctb], James Balamuta [ctb] |
Maintainer: | Jesse Windle <[email protected]> |
License: | GPL (>=3) |
Version: | 2.1 |
Built: | 2024-11-06 03:25:12 UTC |
Source: | https://github.com/jwindle/bayeslogit |
Generate random variates from the Polya-Gamma distribution.
rpg(num=1, h=1, z=0.0) rpg.gamma(num=1, h=1, z=0.0, trunc=200) rpg.devroye(num=1, h=1, z=0.0) rpg.sp(num=1, h=1, z=0.0) rpg.gamma.R(num=1, h=1, z=0.0, trunc=200) rpg.devroye.R(num=1, h=1, z=0.0)
rpg(num=1, h=1, z=0.0) rpg.gamma(num=1, h=1, z=0.0, trunc=200) rpg.devroye(num=1, h=1, z=0.0) rpg.sp(num=1, h=1, z=0.0) rpg.gamma.R(num=1, h=1, z=0.0, trunc=200) rpg.devroye.R(num=1, h=1, z=0.0)
num |
The number of random variates to simulate. |
h |
Shape parameter. |
z |
Parameter associated with tilting. |
trunc |
The number of elements used in sum of gammas approximation. |
A random variable X with distribution PG(h,z) is distributed like
The density for X may be derived by exponentially tilting the PG(h,0) density:
Different methods for generating this random variable are
implemented, each of which is useful for certain parameters. The
parameters supplied by the user automatically determine which method
is used. One may manually call each routine using
rpg.METHOD
. Functions ending in ".R" are pure R
implementations.
You may call rpg when n and z are vectors.
This function returns num
Polya-Gamma samples.
Nicholas G. Polson, James G. Scott, and Jesse Windle. Bayesian inference for logistic models using Polya-Gamma latent variables. http://arxiv.org/abs/1205.0310
h = c(1, 2, 3); z = c(4, 5, 6); ## Devroye-like method -- only use if h contains integers, preferably small integers. X = rpg.devroye(100, h, z); h = c(1.2, 2.3, 3.2); z = c(4, 5, 6); ## Sum of gammas method -- this is slow. X = rpg.gamma(100, h, z); h = c(1, 4, 2.3); z = c(4, 5, 6); ## Hybrid method -- automatically chooses best procedure. X = rpg(100, h, z);
h = c(1, 2, 3); z = c(4, 5, 6); ## Devroye-like method -- only use if h contains integers, preferably small integers. X = rpg.devroye(100, h, z); h = c(1.2, 2.3, 3.2); z = c(4, 5, 6); ## Sum of gammas method -- this is slow. X = rpg.gamma(100, h, z); h = c(1, 4, 2.3); z = c(4, 5, 6); ## Hybrid method -- automatically chooses best procedure. X = rpg(100, h, z);