• If fit is for a model that marginalizes the latent signal f (i.e. is_f_sampled(fit) is FALSE), this computes the analytic conditional posterior distributions of each model component, their sum, and the conditional predictive distribution. All these are computed for each (hyper)parameter draw (defined by draws), or other parameter set (obtained by a reduction defined by reduce). Results are stored in a GaussianPrediction object which is then returned.

  • If fit is for a model that samples the latent signal f (i.e. is_f_sampled(fit) is TRUE), this will extract these function samples, compute their sum, and a version of the sum f that is transformed through the inverse link function. If x is not NULL, the function draws are extrapolated to the points specified by x using kernel regression. Results are stored in a Prediction object which is then returned.

pred(
  fit,
  x = NULL,
  reduce = function(x) base::mean(x),
  draws = NULL,
  verbose = TRUE,
  STREAM = get_stream(),
  c_hat_pred = NULL,
  force = FALSE,
  debug_kc = FALSE
)

Arguments

fit

An object of class lgpfit.

x

A data frame of points where function posterior distributions and predictions should be computed or sampled. The function new_x provides an easy way to create it. If this is NULL, the data points are used.

reduce

Reduction for parameters draws. Can be a function that is applied to reduce all parameter draws into one parameter set, or NULL (no reduction). Has no effect if draws is specified.

draws

Indices of parameter draws to use, or NULL to use all draws.

verbose

Should more information and a possible progress bar be printed?

STREAM

External pointer. By default obtained with rstan::get_stream().

c_hat_pred

This is only used if the latent signal f was sampled. This input contains the values added to the sum f before passing through inverse link function. Must be a vector with length equal to the number of prediction points. If original c_hat was constant, then c_hat_pred can be ignored, in which case this will by default use the same constant.

force

This is by default FALSE to prevent unintended large computations that might crash R or take forever. Set it to TRUE try computing no matter what.

debug_kc

If this is TRUE, this only returns a KernelComputer object that is created internally. Meant for debugging.

Value

An object of class GaussianPrediction or Prediction.

See also

Other main functions: create_model(), draw_pred(), get_draws(), lgp(), prior_pred(), sample_model()