pred_magma {MagmaClustR} | R Documentation |
Magma prediction
Description
Compute the posterior predictive distribution in Magma. Providing data of any new individual/task, its trained hyper-parameters and a previously trained Magma model, the predictive distribution is evaluated on any arbitrary inputs that are specified through the 'grid_inputs' argument.
Usage
pred_magma(
data = NULL,
trained_model = NULL,
grid_inputs = NULL,
hp = NULL,
kern = "SE",
hyperpost = NULL,
get_hyperpost = FALSE,
get_full_cov = FALSE,
plot = TRUE,
pen_diag = 1e-10
)
Arguments
data |
A tibble or data frame. Required columns: 'Input',
'Output'. Additional columns for covariates can be specified.
The 'Input' column should define the variable that is used as
reference for the observations (e.g. time for longitudinal data). The
'Output' column specifies the observed values (the response
variable). The data frame can also provide as many covariates as desired,
with no constraints on the column names. These covariates are additional
inputs (explanatory variables) of the models that are also observed at
each reference 'Input'. If NULL, the mean process from
|
trained_model |
A list, containing the information coming from a
Magma model, previously trained using the |
grid_inputs |
The grid of inputs (reference Input and covariates) values
on which the GP should be evaluated. Ideally, this argument should be a
tibble or a data frame, providing the same columns as |
hp |
A named vector, tibble or data frame of hyper-parameters
associated with |
kern |
A kernel function, defining the covariance structure of the GP. Several popular kernels (see The Kernel Cookbook) are already implemented and can be selected within the following list:
|
hyperpost |
A list, containing the elements 'mean' and 'cov', the
parameters of the hyper-posterior distribution of the mean process.
Typically, this argument should come from a previous learning using
|
get_hyperpost |
A logical value, indicating whether the hyper-posterior distribution of the mean process should be returned. This can be useful when planning to perform several predictions on the same grid of inputs, since recomputation of the hyper-posterior can be prohibitive for high dimensional grids. |
get_full_cov |
A logical value, indicating whether the full posterior covariance matrix should be returned. |
plot |
A logical value, indicating whether a plot of the results is automatically displayed. |
pen_diag |
A number. A jitter term, added on the diagonal to prevent numerical issues when inverting nearly singular matrices. |
Value
A tibble, representing Magma predictions as two column 'Mean' and
'Var', evaluated on the grid_inputs
. The column 'Input' and
additional covariates columns are associated to each predicted values.
If the get_full_cov
or get_hyperpost
arguments are TRUE,
the function returns a list, in which the tibble described above is
defined as 'pred_gp' and the full posterior covariance matrix is
defined as 'cov', and the hyper-posterior distribution of the mean process
is defined as 'hyperpost'.
Examples
TRUE