sample_binom_reg | R Documentation |
Sample a binomial regression rate
sample_binom_reg(
p,
k,
n,
mean,
precision,
method = c("slice", "normal", "uniform", "quadratic taylor", "mv quadratic taylor",
"mv ind quadratic taylor", "mv beta", "mv truncated exponential"),
...,
width = 1,
nexpand = 10,
ncontract = 100,
acceptance = c("MH", "LL only", "regardless")
)
p |
the previous iteration of the logit-probability |
k |
the realized value from the binomial distribution |
n |
the number of trials |
mean |
the prior mean. If this is negative infinity, |
precision |
the prior precision |
method |
The method to use to propose new values.
Note that |
... |
Other arguments (not used) |
width |
For |
nexpand |
The maximum number of expansions (to the right and left each) |
ncontract |
The maximum number of contractions. If this is exceeded, the original value is returned |
acceptance |
What should be the criteria for acceptance? "MH" indicates the usual Metropolis-Hastings update. "LL only" ignores the proposal densities but considers the log-likelihoods. "regardless" accepts no matter what. This is useful for testing, or for when the method is a gamma, beta, or quadratic approximation, which can be hard to accept if the initial starting point is low-density. |
This function samples p
conditional on k
, n
, mean
, and precision
,
where k ~ Binom(n, expit(p))
and p ~ N(mean, precision)
.
In the case that n
is zero, sampling is ignored in favor of a normal draw.
In the special case when an entire (multivariate) row of n
is zero, the entire row
is simultaneously drawn (in R); when only some elements are zero, they're drawn univariately (in C++).
Note that only the latter is used when proposal
indicates multivariate MH.
This is vectorized over p
, k
, n
, and mean
. If precision
is a matrix,
p
is assumed to be multivariately distributed, and different internals are used.
The internals are defined in C++.
https://en.wikipedia.org/wiki/Slice_sampling, https://en.wikipedia.org/wiki/Metropolis–Hastings_algorithm, https://arxiv.org/pdf/1308.0657.pdf
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.