gp {dgpsi} | R Documentation |
Gaussian process emulator construction
Description
This function builds and trains a GP emulator.
Usage
gp(
X,
Y,
name = "sexp",
lengthscale = rep(0.1, ncol(X)),
bounds = NULL,
prior = "ref",
nugget_est = FALSE,
nugget = ifelse(nugget_est, 0.01, 1e-08),
scale_est = TRUE,
scale = 1,
training = TRUE,
verb = TRUE,
vecchia = FALSE,
M = 25,
ord = NULL,
internal_input_idx = NULL,
linked_idx = NULL,
id = NULL
)
Arguments
X |
a matrix where each row is an input data point and each column is an input dimension. |
Y |
a matrix with only one column and each row being an output data point. |
name |
kernel function to be used. Either |
lengthscale |
initial values of lengthscales in the kernel function. It can be a single numeric value or a vector of length
Defaults to a vector of |
bounds |
the lower and upper bounds of lengthscales in the kernel function. It is a vector of length two where the first element is
the lower bound and the second element is the upper bound. The bounds will be applied to all lengthscales in the kernel function. Defaults
to |
prior |
prior to be used for Maximum a Posterior for lengthscales and nugget of the GP: gamma prior ( |
nugget_est |
a bool indicating if the nugget term is to be estimated:
Defaults to |
nugget |
the initial nugget value. If |
scale_est |
a bool indicating if the variance is to be estimated:
Defaults to |
scale |
the initial variance value. If |
training |
a bool indicating if the initialized GP emulator will be trained.
When set to |
verb |
a bool indicating if the trace information on GP emulator construction and training will be printed during function execution.
Defaults to |
vecchia |
|
M |
|
ord |
If |
internal_input_idx |
The argument will be removed in the next release. To set up connections of emulators for linked emulations, please use the updated |
linked_idx |
Set The argument will be removed in the next release. To set up connections of emulators for linked emulations, please use the updated |
id |
an ID to be assigned to the GP emulator. If an ID is not provided (i.e., |
Details
See further examples and tutorials at https://mingdeyu.github.io/dgpsi-R/.
Value
An S3 class named gp
that contains five slots:
-
id
: A number or character string assigned through theid
argument. -
data
: a list that contains two elements:X
andY
which are the training input and output data respectively. -
specs
: a list that contains seven elements:-
kernel
: the type of the kernel function used. Either"sexp"
for squared exponential kernel or"matern2.5"
for Matérn-2.5 kernel. -
lengthscales
: a vector of lengthscales in the kernel function. -
scale
: the variance value in the kernel function. -
nugget
: the nugget value in the kernel function. -
internal_dims
: the column indices ofX
that correspond to the linked emulators in the preceding layers of a linked system. The slot will be removed in the next release. -
external_dims
: the column indices ofX
that correspond to global inputs to the linked system of emulators. It is shown asFALSE
ifinternal_input_idx = NULL
. The slot will be removed in the next release. -
linked_idx
: the value passed to argumentlinked_idx
. It is shown asFALSE
if the argumentlinked_idx
isNULL
. The slot will be removed in the next release. -
vecchia
: whether the Vecchia approximation is used for the GP emulator training. -
M
: the size of the conditioning set for the Vecchia approximation in the GP emulator training.
-
-
constructor_obj
: a 'python' object that stores the information of the constructed GP emulator. -
container_obj
: a 'python' object that stores the information for the linked emulation. -
emulator_obj
: a 'python' object that stores the information for the predictions from the GP emulator.
The returned gp
object can be used by
-
predict()
for GP predictions. -
validate()
for LOO and OOS validations. -
plot()
for validation plots. -
lgp()
for linked (D)GP emulator constructions. -
summary()
to summarize the trained GP emulator. -
write()
to save the GP emulator to a.pkl
file. -
design()
for sequential designs. -
update()
to update the GP emulator with new inputs and outputs.
Note
Any R vector detected in X
and Y
will be treated as a column vector and automatically converted into a single-column
R matrix. Thus, if X
is a single data point with multiple dimensions, it must be given as a matrix.
References
Gu, M. (2019). Jointly robust prior for Gaussian stochastic process in emulation, calibration and variable selection. Bayesian Analysis, 14(3), 857-885.
Katzfuss, M., Guinness, J., & Lawrence, E. (2022). Scaled Vecchia approximation for fast computer-model emulation. SIAM/ASA Journal on Uncertainty Quantification, 10(2), 537-554.
Examples
## Not run:
# load the package and the Python env
library(dgpsi)
# construct a step function
f <- function(x) {
if (x < 0.5) return(-1)
if (x >= 0.5) return(1)
}
# generate training data
X <- seq(0, 1, length = 10)
Y <- sapply(X, f)
# training
m <- gp(X, Y)
# summarizing
summary(m)
# LOO cross validation
m <- validate(m)
plot(m)
# prediction
test_x <- seq(0, 1, length = 200)
m <- predict(m, x = test_x)
# OOS validation
validate_x <- sample(test_x, 10)
validate_y <- sapply(validate_x, f)
plot(m, validate_x, validate_y)
# write and read the constructed emulator
write(m, 'step_gp')
m <- read('step_gp')
## End(Not run)