The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
The BKP package provides scalable Bayesian modeling tools for binomial and multinomial response data via the Beta Kernel Process (BKP) and its generalization, the Dirichlet Kernel Process (DKP).
Both models leverage kernel-based weighting and conjugate priors to enable efficient posterior inference, probabilistic prediction, and uncertainty quantification.
Install the development version of the BKP package from GitHub:
# install.packages("pak")
::pak("Jiangyan-Zhao/BKP") pak
library(BKP)
# Simulate data
set.seed(123)
<- 30
n <- matrix(c(-2, 2), nrow = 1)
Xbounds <- matrix(seq(-2, 2, length.out = n), ncol = 1)
x <- (1 + exp(-x^2) * cos(10 * (1 - exp(-x)) / (1 + exp(-x)))) / 2
true_pi <- sample(50:100, n, replace = TRUE)
m <- rbinom(n, size = m, prob = true_pi)
y
# Fit BKP model
<- fit.BKP(x, y, m, Xbounds = Xbounds)
model
# Predict on new data
<- matrix(seq(-2, 2, length.out = 100), ncol = 1)
Xnew <- predict(model, Xnew)
pred
# Plot results
plot(model)
DKP generalizes BKP to multi-class settings using a Dirichlet-multinomial model.
# Simulate 3-class data
set.seed(123)
<- 30
n <- matrix(c(-2, 2), nrow = 1)
Xbounds <- matrix(seq(-2, 2, length.out = n), ncol = 1)
x <- (1 + exp(-x^2) * cos(10 * (1 - exp(-x)) / (1 + exp(-x)))) / 2
pi1 <- cbind(pi1/2, pi1/2, 1 - pi1)
pi_true
<- sample(50:100, n, replace = TRUE)
m <- t(sapply(1:n, function(i) rmultinom(1, size = m[i], prob = pi_true[i, ])))
Y
# Fit DKP model
<- fit.DKP(x, Y, Xbounds = Xbounds)
model_dkp
# Predict on new input
<- matrix(seq(-2, 2, length.out = 10), ncol = 1)
Xnew <- predict(model_dkp, Xnew)
pred_dkp
# Plot results
plot(model_dkp)
You can simulate posterior samples using:
# BKP posterior draws
simulate(model, Xnew, n_sim = 5)
# DKP posterior draws
simulate(model_dkp, Xnew, n_sim = 5)
If you use this package in your work, please cite the accompanying methodology papers or package documentation.
The BKP package is under active development. Contributions and suggestions are welcome via GitHub issues or pull requests.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.