gp_fit: Fit a GP model

View source: R/gp_fit.R

gp_fitR Documentation

Fit a GP model

Description

Function gp_fit fits a GP model with the current hyperparameters. Notice that this function does not optimize the hyperparameters in any way, but only finds the analytical posterior approximation (depending on chosen approx) for the latent values with the current hyperparameters. For optimizing the hyperparameter values, see gp_optim.

Usage

gp_fit(gp, x, y, trials = NULL, offset = NULL, jitter = NULL, ...)

Arguments

gp

The gp model object to be fitted.

x

n-by-d matrix of input values (n is the number of observations and d the input dimension). Can also be a vector of length n if the model has only a single input.

y

Vector of n output (target) values.

trials

Vector of length n giving the number of trials for each observation in binomial (and beta binomial) model.

offset

Vector of constant values added to the latent values f_i (i = 1,...,n). For Poisson models, this is the logarithm of the exposure time in each observation.

jitter

Magnitude of diagonal jitter for covariance matrices for numerical stability. Default is 1e-6.

...

Currently ignored

Value

An updated GP model object.

References

Rasmussen, C. E. and Williams, C. K. I. (2006). Gaussian processes for machine learning. MIT Press.

Examples


# Generate some toy data
set.seed(32004)
n <- 150
sigma <- 0.1
x <- rnorm(n)
ycont <- sin(3 * x) * exp(-abs(x)) + rnorm(n) * sigma
y <- rep(0, n)
y[ycont > 0] <- 1
trials <- rep(1, n)

# Fit the model using Laplace approximation (with the specified hyperparameters)
cf <- cf_sexp(lscale = 0.3, magn = 3)
gp <- gp_init(cf, lik_binomial())
gp <- gp_fit(gp, x, y, trials = trials)



gplite documentation built on Aug. 24, 2022, 9:07 a.m.