print.NBKP: Print Methods for NBKP Objects

View source: R/print_NBKP.R

print.NBKPR Documentation

Print Methods for NBKP Objects

Description

Provides formatted console output for fitted NBKP model objects and their predictions. The following specialized methods are supported:

  • print.NBKP – display fitted NBKP model objects.

  • print.predict_NBKP – display posterior predictive results.

Usage

## S3 method for class 'NBKP'
print(x, ...)

## S3 method for class 'predict_NBKP'
print(x, ...)

Arguments

x

An object of class "NBKP" or "predict_NBKP".

...

Additional arguments passed to the generic print method (currently unused; included for S3 consistency).

Value

Invisibly returns the input object. Called for the side effect of printing human-readable summaries to the console.

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; predict.NBKP for posterior prediction.

Examples


# -------------------------- 1D Example --------------------------
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
model1 <- fit_NBKP(X, y, Xbounds=Xbounds)
print(model1) # fitted object

pred1 <- predict(model1)
print(pred1) # predictions

# -------------------------- 2D Example --------------------------
set.seed(123)

# Define 2D latent function and mean transformation
true_mu_fun <- function(X) {
  if(is.null(nrow(X))) X <- matrix(X, nrow=1)
  x1 <- 4*X[,1] - 2
  x2 <- 4*X[,2] - 2
  f <- sin(2*pi*x1) * cos(2*pi*x2)
  return(exp(f))
}

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

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

pred2 <- predict(model2)
print(pred2)



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