| print.NBKP | R Documentation |
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.
## S3 method for class 'NBKP'
print(x, ...)
## S3 method for class 'predict_NBKP'
print(x, ...)
x |
An object of class |
... |
Additional arguments passed to the generic |
Invisibly returns the input object. Called for the side effect of printing human-readable summaries to the console.
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.
fit_NBKP for model fitting;
predict.NBKP for posterior prediction.
# -------------------------- 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.