| fit_NBKP | R Documentation |
Fits a Negative Binomial Kernel Process (NBKP) model to count response data using local kernel smoothing. The method constructs a flexible latent mean surface by updating Gamma priors with kernel-weighted observations.
fit_NBKP(
X,
y,
Xbounds = NULL,
prior = c("noninformative", "fixed", "adaptive"),
r0 = 0.1,
mu0 = mean(y),
kernel = c("gaussian", "matern52", "matern32"),
loss = c("mse", "nll"),
n_multi_start = NULL,
theta = NULL
)
X |
A numeric input matrix of size |
y |
A numeric vector of observed counts (length |
Xbounds |
Optional |
prior |
Global prior type: |
r0 |
Global prior precision (used when |
mu0 |
Global prior mean (used when |
kernel |
Kernel function for local weighting: |
loss |
Loss function for kernel hyperparameter tuning: |
n_multi_start |
Number of random initializations for multi-start
optimization. Default is |
theta |
Optional. A positive scalar or numeric vector of length |
A list of class "NBKP" containing the fitted NBKP model,
including:
theta_opt |
Optimized kernel hyperparameters (lengthscales). |
kernel |
Kernel function used, as a string. |
loss |
Loss function used for hyperparameter tuning. |
loss_min |
Minimum loss achieved during optimization, or
|
X |
Original input matrix ( |
Xnorm |
Normalized input matrix scaled to |
Xbounds |
Normalization bounds for each input dimension ( |
y |
Observed counts. |
phi |
Estimated negative binomial dispersion parameter. |
prior |
Type of prior used. |
r0 |
Prior precision parameter. |
mu0 |
Prior mean (for fixed priors). |
alpha0 |
Prior Gamma shape parameter |
beta0 |
Prior Gamma rate parameter |
alpha_n |
Posterior shape parameter |
beta_n |
Posterior rate parameter |
Xueqin Li
Zhao J, Qing K, Xu J (2025). BKP: An R Package for Beta Kernel Process Modeling.
predict.NBKP, plot.NBKP, summary.NBKP
# -------------------------- 1D Example --------------------------
set.seed(123)
true_mu_fun <- function(x) {
exp(sin(x) + 0.5)
}
n <- 30
Xbounds <- matrix(c(-2, 2), nrow=1)
X <- matrix(seq(-2, 2, length.out = n))
true_mu <- true_mu_fun(X)
y <- rnbinom(n, size = 1, mu = true_mu)
model1 <- fit_NBKP(X, y, Xbounds=Xbounds)
print(model1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.