get_prior {BKP} | R Documentation |
Construct Prior Parameters for the BKP Model
Description
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
|
r0 |
Positive scalar indicating the global precision parameter. Used
when |
p0 |
Prior mean for the success probability (in (0,1)). Used only when
|
y |
Numeric vector of observed successes, of length |
m |
Numeric vector of total binomial trials, of length |
K |
A precomputed kernel matrix of size |
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 proportionsy/m
, and precisionr0
is distributed accordingly.
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
.
See Also
get_prior_dkp
, fit.BKP
,
predict.BKP
, kernel_matrix
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)