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 "noninformative", "fixed", or "adaptive".

r0

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

p0

Numeric vector specifying the global prior mean for each class (must sum to 1). Only used when prior = "fixed". Should be of length equal to the number of classes.

Y

Numeric matrix of observed class counts of size n × q, where n is the number of observations and q the number of classes.

K

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

Details

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)


[Package BKP version 0.1.0 Index]