predict: Predict posterior mean and variance/covariance

predictR Documentation

Predict posterior mean and variance/covariance

Description

Acts on a bhetgp, bhetgp_vec, bhomgp or, bhomgp_vec object. Calculates posterior mean and variance/covariance over specified input locations. Optionally utilizes SNOW parallelization.

Usage

## S3 method for class 'bhetgp'
predict(
  object,
  x_new,
  lite = TRUE,
  return_all = FALSE,
  interval = c("pi", "ci", "both"),
  lam_ub = TRUE,
  cores = 1,
  samples = TRUE,
  ...
)

## S3 method for class 'bhetgp_vec'
predict(
  object,
  x_new,
  lite = TRUE,
  return_all = FALSE,
  interval = c("pi", "ci", "both"),
  lam_ub = TRUE,
  vecchia = FALSE,
  m = object$m,
  ordering_new = NULL,
  cores = 1,
  omp_cores = 2,
  samples = TRUE,
  ...
)

## S3 method for class 'bhomgp'
predict(
  object,
  x_new,
  lite = TRUE,
  return_all = FALSE,
  interval = c("pi", "ci", "both"),
  cores = 1,
  samples = TRUE,
  ...
)

## S3 method for class 'bhomgp_vec'
predict(
  object,
  x_new,
  lite = TRUE,
  return_all = FALSE,
  interval = c("pi", "ci", "both"),
  vecchia = FALSE,
  m = object$m,
  ordering_new = NULL,
  cores = 1,
  omp_cores = 2,
  samples = TRUE,
  ...
)

Arguments

object

object from bhetGP or bhomGP, with burn-in already removed

x_new

matrix of predictive input locations

lite

logical indicating whether to calculate only point-wise variances (lite = TRUE) or full covariance (lite = FALSE)

return_all

logical indicating whether to return mean and point-wise variance prediction for ALL samples (only available for lite = TRUE)

interval

returns predictive variances by default interval = "pi". interval = "ci" returns variances for only mean process and interval = "both" returns both variances.

lam_ub

logical uses upper 95 quantile for latent noise to obtain predictive variances for the response. If lam_ub = FALSE, the mean latent noise is used for inference.

cores

number of cores to utilize for SNOW parallelization

samples

logical indicating if you want all posterior samples returned including latent layer.

...

N/A

vecchia

logical uses vecchia approximation for prediction if vecchia = TRUE.

m

size of Vecchia conditioning sets (only for fits with vecchia = TRUE), defaults to the m used for MCMC

ordering_new

optional ordering for Vecchia approximation, must correspond to rows of x_new, defaults to random, is applied to all layers in deeper models.

omp_cores

sets cores used for OpenMP if vechhia = TRUE and lite = FALSE.

Details

All iterations in the object are used for prediction, so samples should be burned-in. Thinning the samples using trim will speed up computation. Posterior moments are calculated using conditional expectation and variance. As a default, only point-wise variance is calculated. Full covariance may be calculated using lite = FALSE.

The posterior predictive variances are returned by default. The variance for the mean process may be obtained by specifying interval = "ci". interval = "both" will return both variances.

SNOW parallelization reduces computation time but requires more memory storage.

Value

object of the same class with the following additional elements:

  • x_new: copy of predictive input locations

  • m_pred: size of predictive conditioning set if vecchia = TRUE

  • mean_y: predicted posterior mean, indices correspond to x_new locations

  • s2_y: predicted point-wise variances, indices correspond to x_new locations (only returned when lite = TRUE & interval = c("pi", "both"))

  • s2_y_ci: predicted point-wise variances for the mean process, indices correspond to x_new locations (only returned when lite = TRUE & interval = c("ci", "both"))

  • mean_all: predicted posterior mean for each sample (column indices), only returned when return_all = TRUE

  • s2_all predicted point-wise variances each sample (column indices), only returned when return-all = TRUE & interval = c("pi", "both")

  • s2_all_ci predicted point-wise variances for each sample (column indices), only returned when return-all = TRUE & interval = c("ci", "both")

  • Sigma: predicted posterior covariance, indices correspond to x_new locations (only returned when lite = FALSE & interval = c("pi", "both"))

  • Sigma_ci: predicted posterior covariance for mean process, indices correspond to x_new locations (only returned when lite = FALSE & interval = c("ci", "both"))

Additionally, if object belongs to class bhetGP or bhetGP_vec, the log-noise process is also predicted for new locations x_new. The following are returned:

  • mean_lnugs: predicted posterior mean for log noise process, indices correspond to x_new locations

  • s2_lnugs: predicted point-wise variances for log noise process, indices correspond to x_new locations (only returned when lite = TRUE & interval = c("pi", "both"))

  • s2_lnugs_ci: predicted point-wise variances for the log noise process, indices correspond to x_new locations (only returned when lite = TRUE & interval = c("ci", "both"))

  • mean_lnugs_all: predicted posterior mean for each sample for log noise process (column indices), only returned when return_all = TRUE

  • s2_lnugs_all predicted point-wise variances each sample (column indices) for log noise process, only returned when return-all = TRUE & interval = c("pi", "both")

  • s2_lnugs_all_ci predicted point-wise variances for each sample (column indices) for log noise process, only returned when return-all = TRUE & interval = c("ci", "both")

  • Sigma_lnugs: predicted posterior covariance for log noise process, indices correspond to x_new locations (only returned when lite = FALSE & interval = c("pi", "both"))

  • Sigma_lnugs_ci: predicted posterior covariance for log noise process, indices correspond to x_new locations (only returned when lite = FALSE & interval = c("ci", "both"))

Computation time is added to the computation time of the existing object.


bhetGP documentation built on Aug. 8, 2025, 6:34 p.m.