wbinpost | R Documentation |
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.
wbinpost(n, prior, ds_bin)
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
|
For prior$prior == "bin_beta"
the posterior for p
is a beta distribution so rbeta
is used to
sample from the posterior.
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 |
set_bin_prior
for setting a prior distribution
for the binomial probability p
.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.