| post_sample | R Documentation |
Acts on a gp, gpvec, dgp2, dgp2vec,
dgp3, or dgp3vec object. Generates joint samples from the
posterior distribution at the provided locations.
post_sample(object, x_new, nper = 1, ...)
## S3 method for class 'gp'
post_sample(object, x_new, nper = 1, grad = FALSE, cores = 1, ...)
## S3 method for class 'gpvec'
post_sample(
object,
x_new,
nper = 1,
m = NULL,
ord_new = NULL,
grad = FALSE,
cores = 1,
...
)
## S3 method for class 'dgp2'
post_sample(
object,
x_new,
nper = 1,
grad = FALSE,
mean_map = TRUE,
cores = 1,
...
)
## S3 method for class 'dgp2vec'
post_sample(
object,
x_new,
nper = 1,
m = NULL,
ord_new = NULL,
grad = FALSE,
mean_map = TRUE,
cores = 1,
...
)
## S3 method for class 'dgp3'
post_sample(object, x_new, nper = 1, mean_map = TRUE, cores = 1, ...)
## S3 method for class 'dgp3vec'
post_sample(
object,
x_new,
nper = 1,
m = NULL,
ord_new = NULL,
mean_map = TRUE,
cores = 1,
...
)
object |
object from |
x_new |
vector or matrix of predictive input locations |
nper |
the number of samples to generate from each MCMC iteration. The
total number of samples will equal |
... |
N/A |
grad |
logical indicating whether to additionally calculate/return samples of the gradient (one and two layer models only) |
cores |
number of cores to use for SNOW parallelization |
m |
size of Vecchia conditioning sets (only for fits with
|
ord_new |
optional ordering for Vecchia approximation with |
mean_map |
logical indicating whether to map hidden layers using
conditional mean ( |
By default, one sample is generated per each MCMC iteration. This
may be increased with the nper argument.
SNOW parallelization reduces computation time but requires more memory storage.
If grad = FALSE, returns matrix of samples. Rows correspond to
x_new locations. If grad = TRUE, returns a list with
y and dydx containing the respective samples.
Sauer, A. (2023). Deep Gaussian process surrogates for computer experiments.
*Ph.D. Dissertation, Department of Statistics, Virginia Polytechnic Institute and State University.*
# Simple step function
f <- function(x) {
return(pnorm((x - 0.5) / 0.065))
}
# Training data
x <- seq(0, 1, length = 5)
y <- f(x)
# Testing data
xx <- seq(0, 1, length = 100)
yy <- f(xx)
plot(xx, yy, type = "l")
points(x, y, col = 2)
# Conduct MCMC
fit <- fit_two_layer(x, y, nmcmc = 2000, true_g = 1e-6, cov = "exp2")
plot(fit, hidden = TRUE)
fit <- trim(fit, 1000, 2)
# Generate posterior samples, including gradients
samples <- post_sample(fit, xx, grad = TRUE, cores = 1)
# Plot samples
par(mfrow = c(1, 2))
matplot(xx, t(samples$y), type = "l")
points(x, y, pch = 20)
matplot(xx, t(samples$dy), type = "l")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.