get_prior_dkp {BKP} | R Documentation |
Construct Prior Parameters for the DKP Model
Description
Computes prior Dirichlet distribution parameters alpha0
at each input location for the Dirichlet Kernel Process model, based on the
specified prior type: noninformative, fixed, or adaptive.
Usage
get_prior_dkp(
prior = c("noninformative", "fixed", "adaptive"),
r0 = 2,
p0 = NULL,
Y = 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 |
Numeric vector specifying the global prior mean for each class
(must sum to 1). Only used when |
Y |
Numeric matrix of observed class counts of size |
K |
A precomputed kernel matrix of size |
Details
When
prior = "noninformative"
, all entries inalpha0
are set to 1 (flat Dirichlet).When
prior = "fixed"
, all rows ofalpha0
are set tor0 * p0
.When
prior = "adaptive"
, each row ofalpha0
is computed by kernel-weighted smoothing of the observed relative frequencies inY
, scaled byr0
.
Value
A list containing:
alpha0
A numeric matrix of prior Dirichlet parameters at each input location; dimension
n × q
.
See Also
get_prior
, fit.DKP
,
predict.DKP
, kernel_matrix
Examples
# Simulated multi-class data
set.seed(123)
n <- 15 # number of training points
q <- 3 # number of classes
X <- matrix(runif(n * 2), ncol = 2)
# Simulate class probabilities and draw multinomial counts
true_pi <- t(apply(X, 1, function(x) {
raw <- c(
exp(-sum((x - 0.2)^2)),
exp(-sum((x - 0.5)^2)),
exp(-sum((x - 0.8)^2))
)
raw / sum(raw)
}))
m <- sample(10:20, n, replace = TRUE)
Y <- t(sapply(1:n, function(i) rmultinom(1, size = m[i], prob = true_pi[i, ])))
# Compute kernel matrix (Gaussian)
K <- kernel_matrix(X, theta = rep(0.2, 2), kernel = "gaussian")
# Construct adaptive prior
prior_dkp <- get_prior_dkp(prior = "adaptive", r0 = 2, Y = Y, K = K)