dgp | R Documentation |
This function builds and trains a DGP emulator.
dgp(
X,
Y,
depth = 2,
node = ncol(X),
name = "sexp",
lengthscale = 1,
bounds = NULL,
prior = "ga",
share = TRUE,
nugget_est = FALSE,
nugget = NULL,
scale_est = TRUE,
scale = 1,
connect = TRUE,
likelihood = NULL,
training = TRUE,
verb = TRUE,
check_rep = TRUE,
vecchia = FALSE,
M = 25,
ord = NULL,
N = ifelse(vecchia, 200, 500),
cores = 1,
blocked_gibbs = TRUE,
ess_burn = 10,
burnin = NULL,
B = 10,
internal_input_idx = NULL,
linked_idx = NULL,
id = NULL
)
See further examples and tutorials at https://mingdeyu.github.io/dgpsi-R/.
An S3 class named dgp
that contains five slots:
id
: A number or character string assigned through the id
argument.
data
: a list that contains two elements: X
and Y
which are the training input and output data respectively.
specs
: a list that contains
L (i.e., the number of layers in the DGP hierarchy) sub-lists named layer1, layer2,..., layerL
. Each sub-list contains D
(i.e., the number of GP/likelihood nodes in the corresponding layer) sub-lists named node1, node2,..., nodeD
. If a sub-list
corresponds to a likelihood node, it contains one element called type
that gives the name (Hetero
, Poisson
, NegBin
, or Categorical
) of the likelihood node.
If a sub-list corresponds to a GP node, it contains four elements:
kernel
: the type of the kernel function used for the GP node.
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 of X
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 of X
that correspond to global inputs to the linked system of emulators. It is shown
as FALSE
if internal_input_idx = NULL
. The slot will be removed in the next release.
linked_idx
: the value passed to argument linked_idx
. It is shown as FALSE
if the argument linked_idx
is NULL
.
The slot will be removed in the next release.
seed
: the random seed generated to produce imputations. This information is stored for reproducibility when the DGP emulator (that was saved by write()
with the light option light = TRUE
) is loaded back to R by read()
.
B
: the number of imputations used to generate the emulator.
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 DGP emulator training. M
is generated only when vecchia = TRUE
.
constructor_obj
: a 'python' object that stores the information of the constructed DGP 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 DGP emulator.
The returned dgp
object can be used by
predict()
for DGP predictions.
continue()
for additional DGP training iterations.
validate()
for LOO and OOS validations.
plot()
for validation plots.
lgp()
for linked (D)GP emulator constructions.
window()
for model parameter trimming.
summary()
to summarize the trained DGP emulator.
write()
to save the DGP emulator to a .pkl
file.
set_imp()
to change the number of imputations.
design()
for sequential design.
update()
to update the DGP emulator with new inputs and outputs.
alm()
, mice()
, and vigf()
to locate next design points.
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.
## 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)
# set a random seed
set_seed(999)
# training a DGP emulator
m <- dgp(X, Y)
# continue for further training iterations
m <- continue(m)
# summarizing
summary(m)
# trace plot
trace_plot(m)
# trim the traces of model parameters
m <- window(m, 800)
# 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_dgp')
m <- read('step_dgp')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.