Skip to contents

This function calculates a posterior probability for hypotheses about population densities, of the form \(H:\mu = 0\), given the data at a single iteration. This function is to be used in a sequential framework, and called on the sequential test stbp_simple.

Usage

stbp_posterior_simple(
  data,
  density_func,
  overdispersion = NA,
  prior,
  upper_bnd = Inf
)

Arguments

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).

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 "negative binomial" or "beta-binomial" as kernel densities. See details.

prior

Single number with initial prior. Must be in the interval \([0,1]\).

upper_bnd

Single number indicating the greatest possible value for \(\mu\). For count data, is often Inf (default), but it must be \(\leq 1\) for binomial data.

Value

A single probability

Details

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.

References

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>

Examples

# Counts collected in a single sampling bout
counts <- c(0, 0, 0)

# Calculate posterior probability from a naive 0.5 prior for H:mu=0
# (a species being absent in an area) with a poisson kernel.

stbp_posterior_simple(data = counts,
                       density_func = "poisson",
                       prior = 0.5,
                       upper_bnd = Inf) # returns 0.75
#> [1] 0.75
## End (Not run)