BKP: Beta Kernel Process Modeling

Ask DeepWiki CRAN status Total downloads R-CMD-check Codecov test coverage

BKP implements Beta Kernel Process models for nonparametric estimation of covariate-dependent binomial probabilities. The package uses kernel-weighted conjugate updates to obtain closed-form posterior inference for binary and aggregated binomial responses, avoiding latent-variable augmentation and MCMC-based computation.

The package also implements the Dirichlet Kernel Process (DKP) for categorical and multinomial responses, as well as scalable global-local approximations through TwinBKP and TwinDKP. These twin models combine twinning-selected global subsets with local nearest-neighbour updates to improve scalability for larger datasets.

Features

Installation

Install the stable version from CRAN:

install.packages("BKP")

Install the development version from GitHub:

# install.packages("pak")
pak::pak("Jiangyan-Zhao/BKP")

Quick example

library(BKP)

set.seed(123)

true_pi_fun <- function(x) {
  (1 + exp(-x^2) * cos(10 * (1 - exp(-x)) / (1 + exp(-x)))) / 2
}

n <- 30
Xbounds <- matrix(c(-2, 2), nrow = 1)
X <- tgp::lhs(n = n, rect = Xbounds)

true_pi <- true_pi_fun(X)
m <- sample(100, n, replace = TRUE)
y <- rbinom(n, size = m, prob = true_pi)

fit <- fit_BKP(X, y, m, Xbounds = Xbounds)

summary(fit)
plot(fit)

Xnew <- matrix(seq(-2, 2, length.out = 10), ncol = 1)
pred <- predict(fit, Xnew = Xnew)
pred

For multinomial data, use fit_DKP(). For scalable global-local approximations, use fit_TwinBKP() or fit_TwinDKP().

Documentation

The statistical foundations, implementation details, and examples are described in

Citing

If you use BKP in your work, please cite both the methodology paper and the R package:

You can also obtain the citation information directly within R:

citation("BKP")

Development

The BKP package is under active development. Bug reports, feature requests, and contributions are welcome through GitHub issues or pull requests: