wbinpost {revdbayes} | R Documentation |
Random sampling from a binomial posterior distribution, using weights
Description
Samples from the posterior distribution of the probability p
of a binomial distribution. User-supplied weights are applied to each
observation when constructing the log-likelihood.
Usage
wbinpost(n, prior, ds_bin)
Arguments
n |
A numeric scalar. The size of posterior sample required. |
prior |
A function to evaluate the prior, created by
|
ds_bin |
A numeric list. Sufficient statistics for inference
about the binomial probability
|
Details
For prior$prior == "bin_beta"
the posterior for p
is a beta distribution so rbeta
is used to
sample from the posterior.
Value
An object (list) of class "binpost"
with components
bin_sim_vals: |
An |
bin_logf: |
A function returning the log-posterior for
|
bin_logf_args: |
A list of arguments to |
See Also
set_bin_prior
for setting a prior distribution
for the binomial probability p
.
Examples
u <- quantile(gom, probs = 0.65)
ds_bin <- list(sf = gom > u, w = rep(1, length(gom)))
bp <- set_bin_prior(prior = "jeffreys")
temp <- wbinpost(n = 1000, prior = bp, ds_bin = ds_bin)
graphics::hist(temp$bin_sim_vals, prob = TRUE)