Skip to contents

Computes the prior Beta distribution parameters alpha0 and beta0 at each input location, based on the chosen prior specification. Supports noninformative, fixed, and data-adaptive prior strategies.

Usage

get_prior(
  prior = c("noninformative", "fixed", "adaptive"),
  r0 = 2,
  p0 = 0.5,
  y = NULL,
  m = NULL,
  K = NULL
)

Arguments

prior

Character string specifying the type of prior to use. One of "noninformative", "fixed", or "adaptive".

r0

Positive scalar indicating the global precision parameter. Used when prior is "fixed" or "adaptive".

p0

Prior mean for the success probability (in (0,1)). Used only when prior = "fixed".

y

Numeric vector of observed successes, of length n.

m

Numeric vector of total binomial trials, of length n.

K

A precomputed kernel matrix of size n × n, typically obtained from kernel_matrix.

Value

A list with two numeric vectors:

alpha0

Prior alpha parameters of the Beta distribution, length n.

beta0

Prior beta parameters of the Beta distribution, length n.

Details

  • For prior = "noninformative", all prior parameters are set to 1 (noninformative prior).

  • For prior = "fixed", all locations share the same Beta prior: Beta(r0 * p0, r0 * (1 - p0)).

  • For prior = "adaptive", the prior mean at each location is computed by kernel smoothing the observed proportions y/m, and precision r0 is distributed accordingly.

Examples

# Simulated data
set.seed(123)
n <- 10
X <- matrix(runif(n * 2), ncol = 2)
y <- rbinom(n, size = 5, prob = 0.6)
m <- rep(5, n)

# Example kernel matrix (Gaussian)
K <- kernel_matrix(X)

# Construct adaptive prior
prior <- get_prior(prior = "adaptive", r0 = 2, y = y, m = m, K = K)