This function implements prediction from GP, DGP, or linked (D)GP emulators.
Usage
# S3 method for class 'dgp'
predict(
object,
x,
method = "mean_var",
full_layer = FALSE,
sample_size = 50,
M = 50,
cores = 1,
chunks = NULL,
...
)
# S3 method for class 'lgp'
predict(
object,
x,
method = "mean_var",
full_layer = FALSE,
sample_size = 50,
M = 50,
cores = 1,
chunks = NULL,
...
)
# S3 method for class 'gp'
predict(
object,
x,
method = "mean_var",
sample_size = 50,
M = 50,
cores = 1,
chunks = NULL,
...
)Arguments
- object
an instance of the
gp,dgp, orlgpclass.- x
the testing input data:
if
objectis an instance of thegpordgpclass,xis a matrix where each row is an input testing data point and each column is an input dimension.if
objectis an instance of thelgpclass,xmust be a matrix representing the global input, where each row corresponds to a test data point and each column represents a global input dimension. The column indices inxmust align with the indices specified in theFrom_Outputcolumn of thestrucdata frame (used inlgp()), corresponding to rows where theFrom_Emulatorcolumn is"Global".
- method
the prediction approach to use: either the mean-variance approach (
"mean_var") or the sampling approach ("sampling"). The mean-variance approach returns the means and variances of the predictive distributions, while the sampling approach generates samples from predictive distributions using the derived means and variances. Defaults to"mean_var".- full_layer
a bool indicating whether to output the predictions of all layers. Defaults to
FALSE. Only used whenobjectis a DGP or a linked (D)GP emulator.- sample_size
the number of samples to draw for each given imputation if
method = "sampling". Defaults to50.- M
the size of the conditioning set for the Vecchia approximation in the emulator prediction. Defaults to
50. This argument is only used if the emulatorobjectwas constructed under the Vecchia approximation.- cores
the number of processes to be used for prediction. If set to
NULL, the number of processes is set tomax physical cores available %/% 2. Defaults to1.- chunks
the number of chunks that the testing input matrix
xwill be divided into for multi-cores to work on. Only used whencoresis not1. If not specified (i.e.,chunks = NULL), the number of chunks is set to the value ofcores. Defaults toNULL.- ...
N/A.
Value
If
objectis an instance of thegpclass:if
method = "mean_var": an updatedobjectis returned with an additional slot calledresultsthat contains two matrices namedmeanfor the predictive means andvarfor the predictive variances. Each matrix has only one column with its rows corresponding to testing positions (i.e., rows ofx).if
method = "sampling": an updatedobjectis returned with an additional slot calledresultsthat contains a matrix whose rows correspond to testing positions and columns correspond tosample_sizenumber of samples drawn from the predictive distribution of GP.
If
objectis an instance of thedgpclass:if
method = "mean_var"andfull_layer = FALSE: an updatedobjectis returned with an additional slot calledresultsthat contains two matrices namedmeanfor the predictive means andvarfor the predictive variances respectively. Each matrix has its rows corresponding to testing positions and columns corresponding to DGP global output dimensions (i.e., the number of GP/likelihood nodes in the final layer). If the likelihood node is categorical, the matrices contain the predictive means and variances of the class probabilities, with columns corresponding to different classes.if
method = "mean_var"andfull_layer = TRUE: an updatedobjectis returned with an additional slot calledresultsthat contains two sub-lists namedmeanfor the predictive means andvarfor the predictive variances respectively. Each sub-list contains L (i.e., the number of layers) matrices namedlayer1, layer2,..., layerL. Each matrix has its rows corresponding to testing positions and columns corresponding to output dimensions (i.e., the number of GP/likelihood nodes from the associated layer). If the likelihood node is categorical, the matrices namedlayerLin bothmeanandvarcontain the predictive means and variances of the class probabilities, respectively, with columns corresponding to different classes.if
method = "sampling"andfull_layer = FALSE: an updatedobjectis returned with an additional slot calledresultsthat contains D (i.e., the number of GP/likelihood nodes in the final layer) matrices namedoutput1, output2,..., outputD. If the likelihood node in the final layer is categorical,resultscontains D matrices (where D is the number of classes) of sampled class probabilities, each named according to its corresponding class label. Each matrix inresultshas its rows corresponding to testing positions and columns corresponding to samples of size:B * sample_size, whereBis the number of imputations specified indgp().if
method = "sampling"andfull_layer = TRUE: an updatedobjectis returned with an additional slot calledresultsthat contains L (i.e., the number of layers) sub-lists namedlayer1, layer2,..., layerL. Each sub-list represents samples drawn from the GP/likelihood nodes in the corresponding layer, and contains D (i.e., the number of GP/likelihood nodes in the corresponding layer) matrices namedoutput1, output2,..., outputD. If the likelihood node in the final layer is categorical,layerLcontains D matrices (where D is the number of classes) of sampled class probabilities, each named according to its corresponding class label. Each matrix has its rows corresponding to testing positions and columns corresponding to samples of size:B * sample_size, whereBis the number of imputations specified indgp().
If
objectis an instance of thelgpclass:if
method = "mean_var"andfull_layer = FALSE: an updatedobjectis returned with an additional slot calledresultsthat contains two sub-lists namedmeanfor the predictive means andvarfor the predictive variances respectively. Each sub-list contains K (same number of emulators in the final layer of the system) matrices named using theIDs of the corresponding emulators in the final layer. Each matrix has rows corresponding to global testing positions and columns corresponding to output dimensions of the associated emulator in the final layer.if
method = "mean_var"andfull_layer = TRUE: an updatedobjectis returned with an additional slot calledresultsthat contains two sub-lists namedmeanfor the predictive means andvarfor the predictive variances respectively. Each sub-list contains L (i.e., the number of layers in the emulated system) components namedlayer1, layer2,..., layerL. Each component represents a layer and contains K (same number of emulators in the corresponding layer of the system) matrices named using theIDs of the corresponding emulators in that layer. Each matrix has its rows corresponding to global testing positions and columns corresponding to output dimensions of the associated GP/DGP emulator in the corresponding layer.if
method = "sampling"andfull_layer = FALSE: an updatedobjectis returned with an additional slot calledresultsthat contains K (same number of emulators in the final layer of the system) sub-lists named using theIDs of the corresponding emulators in the final layer. Each sub-list contains D matrices, namedoutput1, output2,..., outputD, that correspond to the output dimensions of the GP/DGP emulator. Each matrix has rows corresponding to testing positions and columns corresponding to samples of size:B * sample_size, whereBis the number of imputations specified inlgp().if
method = "sampling"andfull_layer = TRUE: an updatedobjectis returned with an additional slot calledresultsthat contains L (i.e., the number of layers of the emulated system) sub-lists namedlayer1, layer2,..., layerL. Each sub-list represents a layer and contains K (same number of emulators in the corresponding layer of the system) components named using theIDs of the corresponding emulators in that layer. Each component contains D matrices, namedoutput1, output2,..., outputD, that correspond to the output dimensions of the GP/DGP emulator. Each matrix has its rows corresponding to testing positions and columns corresponding to samples of size:B * sample_size, whereBis the number of imputations specified inlgp().
The results slot will also include:
the value of
M, which represents the size of the conditioning set for the Vecchia approximation, if used, in the emulator prediction.the value of
sample_sizeifmethod = "sampling".
Details
See further examples and tutorials at https://mingdeyu.github.io/dgpsi-R/.
