func_size_bayes: Bayesian Functional Size (Beta-Binomial Model)

View source: R/func_size_bayes.R

func_size_bayesR Documentation

Bayesian Functional Size (Beta-Binomial Model)

Description

Computes a Bayesian posterior distribution for the functional size of a lineup using a Beta-Binomial conjugate model for the suspect-selection rate.

Usage

func_size_bayes(
  lineup_vec,
  target_pos,
  alpha = 0.5,
  S = 10000,
  credible_mass = 0.95,
  threshold = NULL
)

Arguments

lineup_vec

A numeric vector of lineup choices.

target_pos

A scalar; the position of the suspect in the lineup.

alpha

Dirichlet concentration (prior strength). A positive scalar. Named shortcuts: "jeffreys" (0.5, default), "uniform" (1), "weak" (0.1).

S

Number of posterior draws. Default 10000.

credible_mass

Width of the equal-tailed credible interval. Default 0.95.

threshold

Optional numeric. If supplied, reports P(F < t) and P(F > t \mid \mathbf{n}).

Details

Functional size F = N / n_s is the reciprocal of the suspect-selection rate p = n_s / N. The Beta-Binomial conjugate model gives:

p \mid \mathbf{n} \sim \mathrm{Beta}(n_s + \alpha,\; N - n_s + \alpha)

Posterior draws of p^{(s)} are transformed via F^{(s)} = 1/p^{(s)}. The default Jeffreys prior (\alpha = 0.5) is recommended. The posterior gives direct probability statements such as P(F < k \mid \mathbf{n}), where k is the nominal lineup size.

The posterior mean of a reciprocal is computed exactly, not from the draws: with a = n_s + \alpha and b = N - n_s + \alpha, E[F \mid \mathbf{n}] = (a + b - 1)/(a - 1) when a > 1. When a \le 1 (for example, no suspect choices under the Jeffreys prior) the mean is infinite, and the Monte Carlo average of the draws would not settle on any value as S grew. Report the median and interval instead.

Value

An object of class "func_size_bayes" containing:

F_draws

Numeric vector of length S: posterior draws of functional size.

posterior_mean, posterior_median

Posterior point estimates. The mean is exact, and is Inf when it does not exist (see Details).

credible_interval

Named two-element vector (lower, upper).

prior_alpha, n, n_suspect, S, credible_mass

Input metadata.

threshold, threshold_probs

Threshold and probabilities (or NULL).

References

Tredoux, C. G. (1998). Statistical inference on measures of lineup fairness. Law and Human Behavior, 22(2), 217-237.

See Also

func_size, esize_T_bayes

Examples

set.seed(1)
lineup_vec <- round(runif(100, 1, 6))
res <- func_size_bayes(lineup_vec, target_pos = 3)
print(res)
plot(res)

# Threshold: P(F < 6 | data)
res_t <- func_size_bayes(lineup_vec, target_pos = 3, threshold = 6)
print(res_t)


r4lineups documentation built on Nov. 10, 2026, 1:08 a.m.