stbp_posterior_composite | R Documentation |
This function calculates a posterior probability for hypotheses about
population densities of the form H:\mu > \psi
or H:\mu < \psi
,
given the data at a single iteration. This function is to be used in a
sequential framework, and called on the sequential test stbp_composite
.
stbp_posterior_composite(
data,
greater_than,
hypothesis,
density_func,
overdispersion = NA,
prior,
lower_bnd = 0,
upper_bnd = Inf
)
data |
For count data, a numeric vector with for a single sampling bout (NAs allowed). For binomial data, a matrix with observations in col 1 and samples in col 2 (NAs not allowed). |
greater_than |
logical; if TRUE, the tested hypothesis is of
the form |
hypothesis |
Single non-negative value with the hypothesized value
of |
density_func |
Kernel probability density function for the data. See details. |
overdispersion |
A character string (if a function) or a number
specifying the overdispersion parameter. Only required when using
|
prior |
Single number with initial prior. Must be on the interval |
lower_bnd |
Single number indicating the lower bound of the parameter
space for |
upper_bnd |
Single number indicating the upper bound of the parameter
space for |
The density_func
argument should be specified as character string.
Acceptable options are "poisson"
, "negative binomial"
, "binomial"
and "beta-binomial"
. The overdispersion parameter for "negative binomial"
and "beta-binomial"
can be either a constant or a function of the mean.
If a function, it should be specified as a character string with the name of
an existing function. For options of empirical functions to describe
overdispersion as a function of the mean see Binns et al. (2000). The most
common approach for the negative binomial family is Taylor's Power Law.
A single probability
Binns, M.R., Nyrop, J.P. & Werf, W.v.d. (2000) Sampling and monitoring in crop protection: the theoretical basis for developing practical decision guides. CABI Pub., Wallingford, Oxon, UK; New York, N.Y.
Rincon, D.F., McCabe, I. & Crowder, D.W. (2025) Sequential testing of complementary hypotheses about population density. Methods in Ecology and Evolution. <https://doi.org/10.1111/2041-210X.70053>
# Counts collected in a single sampling bout
counts <- c(1, 2, 3)
# Calculate posterior probability from a naive 0.5 prior for H1:mu>2
# (a population being >2 individuals per sampling unit) with
# a poisson kernel
stbp_posterior_composite(data = counts,
greater_than = TRUE,
hypothesis = 2,
density_func = "poisson",
prior = 0.5,
lower_bnd = 0,
upper_bnd = Inf) # returns 0.60630278
# Same analysis but with a negative binomial kernel.
# Note that 'overdispersion' can either be a positive number or a function.
stbp_posterior_composite(data = counts,
greater_than = TRUE,
hypothesis = 2,
density_func = "negative binomial",
overdispersion = 2,
prior = 0.5,
lower_bnd = 0,
upper_bnd = Inf) # returns 0.72558593
## End (Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.