Binary Individual Adaptation (BIA)¶
Implementation of the binary-state Individual Adaptation sampler of Griffin, et al. [43] which adjusts a general proposal to the data. The sampler simulates autocorrelated draws from a distribution that can be specified up to a constant of proportionality.
Model-Based Constructor¶
-
BIA
(params::ElementOrVector{Symbol}; args...)¶ Construct a
Sampler
object for BIA sampling. Parameters are assumed to have binary numerical values (0 or 1).Arguments
params
: stochastic node(s) to be updated with the sampler.args...
: additional keyword arguments to be passed to theBIAVariate
constructor.
Value
Returns aSampler{BIATune}
type object.Example
Stand-Alone Function¶
-
sample!
(v::BIAVariate)¶ Draw one sample from a target distribution using the BIA sampler. Parameters are assumed to have binary numerical values (0 or 1).
Arguments
v
: current state of parameters to be simulated.
Value
Returnsv
updated with simulated values and associated tuning parameters.Example
################################################################################ ## Linear Regression ## y ~ MvNormal(X * (beta0 .* gamma), 1) ## gamma ~ DiscreteUniform(0, 1) ################################################################################ using Mamba ## Data n, p = 25, 10 X = randn(n, p) beta0 = randn(p) gamma0 = rand(0:1, p) y = X * (beta0 .* gamma0) + randn(n) ## Log-transformed Posterior(gamma) + Constant logf = function(gamma::DenseVector) logpdf(MvNormal(X * (beta0 .* gamma), 1.0), y) end ## MCMC Simulation with Binary Individual Adaptation Sampler t = 10000 sim = Chains(t, p, names = map(i -> "gamma[$i]", 1:p)) gamma = BIAVariate(zeros(p), logf) for i in 1:t sample!(gamma) sim[i, :, 1] = gamma end describe(sim)
BIAVariate Type¶
Declaration¶
typealias BIAVariate SamplerVariate{BIATune}
Fields¶
value::Vector{Float64}
: simulated values.tune::BIATune
: tuning parameters for the sampling algorithm.
Constructor¶
-
BIAVariate
(x::AbstractVector{T<:Real}, logf::Function; A::Vector{Float64} = ones(x) / length(x), D::Vector{Float64} = ones(x) / length(x), epsilon::Real = 0.01 / length(x), decay::Real = 0.55, target::Real = 0.45)¶ Construct a
BIAVariate
object that stores simulated values and tuning parameters for BIA sampling.Arguments
x
: initial values.logf
: function that takes a singleDenseVector
argument of parameter values at which to compute the log-transformed density (up to a normalizing constant).A
: vector of probabilities to switch the elements ofx
from 0 to 1 (i.e. added).D
: vector of probabilities to switch elements from 1 to 0 (i.e. deleted).epsilon
: range(epsilon, 1 - epsilon)
for the elements ofA
andD
, where0 < epsilon < 0.5
.decay
: rate of decay of the adaptation, where0.5 < decay <= 1.0
.target
: target mutation rate, where0.0 < target < 1.0
.
Value
Returns aBIAVariate
type object with fields set to the suppliedx
and tuning parameter values.
BIATune Type¶
Declaration¶
type BIATune <: SamplerTune
Fields¶
logf::Nullable{Function}
: function supplied to the constructor to compute the log-transformed density, or null if not supplied.A::Vector{Float64}
: vector of probabilities to switch from 0 to 1.D::Vector{Float64}
: vector of probabilities to switch from 1 to 0.epsilon::Float64
: range(epsilon, 1 - epsilon)
for the elements ofA
andD
.decay::Float64
: rate of decay of the adaptation.target::Float64
: target mutation rate.iter::Int
: iteration number for adaptive updating.