pred_deepICMGP: Predict output means, variances, and within-location...

View source: R/predict.R

pred_deepICMGPR Documentation

Predict output means, variances, and within-location covariances

Description

Compute posterior predictive mean, variance and within-location output covariances at new inputs using all retained MCMC samples. Parallel computation for prediction is supported with the parallel package.

Usage

pred_deepICMGP(
  object,
  x_new,
  store_latent = FALSE,
  return_all = FALSE,
  cores = 1
)

Arguments

object

An object of class deepICMGP returned by fit_deepICMGP or trim_deepICMGP, containing at least two retained MCMC samples.

x_new

Numeric matrix with n_new = nrow(x_new) rows and the d columns, using the same column order and original units as the training inputs. For one input dimension a numeric vector is accepted. For one location in multiple dimensions, please use a one-row matrix.

store_latent

Logical. Include latent predictions and kernel quadratic terms in the returned prediction object. Default is FALSE.

return_all

Logical. Return the pointwise variance matrix for each retained sample in s2_all. Default is FALSE.

cores

Number of CPU cores for parallel prediction using the parallel package. Must be a positive integer. Default is 1.

Details

The function samples latent values at the new inputs, then combines conditional moments of outer-layer using the laws of total expectation and covariance.

C2[i, , ] describes dependence among outputs at location i. s2_all stores conditional variances for individual MCMC samples. s2 combines their average with the variation in predicted means across samples to obtain the posterior predictive variance.

Value

The supplied deepICMGP object with the following fields provided. Let nt be the number of retained samples and q the number of outputs. The number of prediction locations is n_new = nrow(x_new).

  • x_new: the n_{\mathrm{new}} \times d prediction matrix.

  • mean: n_{\mathrm{new}} \times q matrix of posterior predictive means.

  • s2: n_{\mathrm{new}} \times q matrix of posterior predictive variances.

  • C2: n_{\mathrm{new}} \times q \times q array of within-location output covariances. C2[i, , ] is the covariance matrix at row i.

  • s2_all: when return_all = TRUE, a list of nt variance matrices, each n_{\mathrm{new}} \times q.

  • w_new: when store_latent = TRUE, a list of nt sampled latent matrices, each n_{\mathrm{new}} \times D.

  • quad: when store_latent = TRUE, an n_{\mathrm{new}} \times nt matrix of outer-kernel quadratic terms used for active learning.

  • time: Total elapsed computation time in seconds, including the time stored in object and the current prediction call.

Code provenance

This implementation adapts code from the deepgp package and extends it to deep intrinsic coregionalization models. See Sauer, Gramacy, and Higdon (2023) for the underlying deep GP methodology, and https://CRAN.R-project.org/package=deepgp for the source package.

References

Chang, C.-Y. and Sung, C.-L. (2026). Deep Intrinsic Coregionalization Multi-Output Gaussian Process Surrogate with Active Learning. International Journal for Uncertainty Quantification, 16(4), 29–52. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1615/Int.J.UncertaintyQuantification.2026062570")}.

Sauer, A., Gramacy, R. B., and Higdon, D. (2023). Active Learning for Deep Gaussian Process Surrogates. Technometrics, 65(1), 4–18. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/00401706.2021.2008505")}.

See Also

fit_deepICMGP, trim_deepICMGP, ALC_deepICMGP

Examples

library(lhs)

# Forrester Function: 1d input with 2 outputs
f1 <- function(x) {
  (6 * x - 2)^2 * sin(12 * x - 4)
}
f2 <- function(x) {
  0.5 * f1(x) + 10 * (x - 0.5) + 5
}
response <- function(x) cbind(f1(x), f2(x))
set.seed(2025)
X <- maximinLHS(9, 1)
Y <- response(X)

Xtest <- maximinLHS(50, 1)
Ytrue <- response(Xtest)

# Fit a deepICMGP model with 2000 MCMC samples and set nugget to 1e-8
# for deterministic case.
fit <- fit_deepICMGP(X, Y, nmcmc = 2000, true_g = 1e-8)

# Trim a fitted deepICMGP model by removing first 1500 MCMC samples and
# retaining every second sample.
trim <- trim_deepICMGP(fit, burn = 1500, thin = 2)

# Predict a trimmed deepICMGP model on Xtest.
pred <- pred_deepICMGP(trim, x_new = Xtest)

# Calculate RMSE for each output.
RMSE <- numeric(ncol(Y))
for (j in seq_len(ncol(Y))) {
  RMSE[j] <- sqrt(mean((pred$mean[, j] - Ytrue[, j])^2))
}
RMSE


# Branin Function: 2d input with 3 outputs
f1 <- function(x) {
  x1 <- x[, 1] * 15 - 5
  x2 <- x[, 2] * 15
  10 * sqrt(
    (-1.275 * (1.2 * x1 + 0.4)^2 / pi^2 +
       5 * (1.2 * x1 + 0.4) / pi + (1.2 * x2 + 0.4) - 6)^2 +
      (10 - 5 / (4 * pi)) * cos(1.2 * x1 + 0.4) + 10
  ) + 2 * (1.2 * x1 + 1.9) - 3 * (3 * (1.2 * x2 + 2.4) - 1) -
    1 - 3 * x2 + 1
}
f2 <- function(x) {
  x1 <- x[, 1] * 15 - 5
  x2 <- x[, 2] * 15
  10 * sqrt(
    (-1.275 * (x1 + 2)^2 / pi^2 + 5 * (x1 + 2) / pi + (x2 + 2) - 6)^2 +
      (10 - 5 / (4 * pi)) * cos(x1 + 2) + 10
  ) + 2 * (x1 - 0.5) - 3 * (3 * x2 - 1) - 1
}
f3 <- function(x) {
  x1 <- x[, 1] * 15 - 5
  x2 <- x[, 2] * 15
  (-1.275 * x1^2 / pi^2 + 5 * x1 / pi + x2 - 6)^2 +
    (10 - 5 / (4 * pi)) * cos(x1) + 10
}
response <- function(x) cbind(f1(x), f2(x), f3(x))
set.seed(2025)
X <- maximinLHS(30, 2)
Y <- response(X)

Xtest <- maximinLHS(100, 2)

# Fit a deepICMGP model with 5000 MCMC samples and set nugget to 1e-8
# for deterministic case.
fit <- fit_deepICMGP(X, Y, nmcmc = 5000, true_g = 1e-8)

# Predict a fitted deepICMGP model on Xtest and return sampled latent values.
pred <- pred_deepICMGP(fit, Xtest, store_latent = TRUE)
length(pred$w_new)

# For parallel prediction:
pred <- pred_deepICMGP(fit, Xtest, cores = 2)


deepICMGP documentation built on Nov. 3, 2026, 5:08 p.m.