quantile.NBKP: Posterior Quantiles from a Fitted NBKP Model

View source: R/quantile_NBKP.R

quantile.NBKPR Documentation

Posterior Quantiles from a Fitted NBKP Model

Description

Compute posterior quantiles from a fitted NBKP model. This returns posterior quantiles of the latent mean count from the Gamma posterior distribution.

Usage

## S3 method for class 'NBKP'
quantile(x, probs = c(0.025, 0.5, 0.975), ...)

Arguments

x

An object of class NBKP, typically the result of a call to fit_NBKP.

probs

Numeric vector of probabilities specifying which posterior quantiles to return. Defaults to c(0.025, 0.5, 0.975).

...

Additional arguments (currently unused).

Details

For a NBKP model, posterior quantiles are computed from the Gamma Kernel Process posterior distribution.

Value

A numeric vector (if length(probs) = 1) or numeric matrix (if length(probs) > 1) of posterior quantiles. Rows correspond to observations, and columns correspond to the requested probabilities.

References

Zhao J, Qing K, Xu J (2025). BKP: An R Package for Beta Kernel Process Modeling. arXiv. https://doi.org/10.48550/arxiv.2508.10447.

See Also

fit_NBKP for model fitting.

Examples


set.seed(123)

# Define true mean function
true_mu_fun <- function(x) {
  exp(sin(x) + 0.5)
}

n <- 30
Xbounds <- matrix(c(-2, 2), nrow = 1)
X <- tgp::lhs(n = n, rect = Xbounds)
true_mu <- true_mu_fun(X)
y <- rnbinom(n, size = 1, mu = true_mu)

# Fit NBKP model
model <- fit_NBKP(X, y, Xbounds = Xbounds)

# Extract posterior quantiles
quantile(model)



NBKP documentation built on June 18, 2026, 1:06 a.m.