sample_pois_reg | R Documentation |
Sample a Poisson regression rate
sample_pois_reg(
L,
k,
mean,
precision,
method = c("slice", "normal", "uniform", "gamma", "mv gamma", "quadratic taylor",
"mv quadratic taylor", "mv ind quadratic taylor", "mv truncated exponential"),
...,
width = 1,
nexpand = 10,
ncontract = 100,
truncate = NULL,
acceptance = c("MH", "LL only", "regardless")
)
L |
the previous iteration of the log-rate |
k |
the realized value from the Poisson distribution |
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 |
truncate |
Either |
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 L
conditional on k
, mean
, and precision
,
where k ~ Pois(exp(L))
and L ~ N(mean, precision)
.
In the case that k
is NA
(akin to sample_binom_reg
in the case n == k == 0
),
sampling is ignored in favor of a normal draw.
In the special case when an entire (multivariate) row of k
is NA
, the entire row
is simultaneously drawn (in R); when only some elements are NA
, they're drawn univariately (in C++).
Note that only the latter is used when proposal
indicates multivariate MH.
This is vectorized over L
, k
, and mean
. If precision
is a matrix,
L
is assumed to be multivariately distributed, and a different function is 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.