View source: R/simulate_NBKP.R
| simulate.NBKP | R Documentation |
Generates random draws from the posterior predictive distribution
of a fitted NBKP model at specified input locations.
For NBKP models, posterior samples are generated from Gamma distributions characterizing latent mean count values for negative‑binomial observations.
## S3 method for class 'NBKP'
simulate(object, nsim = 1, seed = NULL, Xnew = NULL, ...)
object |
An object of class |
nsim |
Number of posterior samples to generate (default |
seed |
Optional integer seed for reproducibility. |
Xnew |
A numeric matrix or vector of new input locations at which simulations are generated. |
... |
Additional arguments (currently unused). |
A list with the following components:
samplesA numeric matrix of size nrow(Xnew) × nsim,
where each column corresponds to one posterior draw of latent mean counts.
meanA numeric vector of posterior mean count values
at each Xnew.
XThe training input matrix used to fit the NBKP model.
XnewThe new input locations at which simulations are generated.
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.
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)
# Simulate 5 posterior draws of latent mean counts
Xnew <- matrix(seq(-2, 2, length.out = 5), ncol = 1)
simulate(model, Xnew = Xnew, nsim = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.