Description Details Public fields Methods
This provides a parent class for all mean function classes for gpmss.
"A Gaussian process is completely specified by its mean function and covariance function" (Rasmussen and Williams 2006, 13). The mean function gives the prior mean for function output given input values.
We implement the following mean functions:
A zero mean; for any set of inputs, the GP's prior mean is zero.
A linear mean; the GP's prior mean is a vector of coefficients multiplied by the predictors, plus (optionally) an intercept.
Users may also define their own mean functions for use with gpmss
functions. A mean function class must provide a mean()
method,
a parameter_derivative()
method, and a input_derivative()
method. It must have data members hypers
and name
.
The mean()
method is used to actually call the mean function.
The first argument should be X
, the first set of inputs.
The second argument should be hypers
, a numeric vector giving all the
hyperparameters of the mean function; its default value should be
NULL
, in which case, the data member hypers
is utilized.
(We allow passing different hypers for convenience in hyperparameter
optimization).
The parameter_derivative()
method is used to obtain the partial
derivatives of the mean function with respect to each of its
hyperparameters. (This is useful for optimization). Its arguments should be
the same as the mean()
method, with one additional argument,
param
, giving the index of hypers
of the parameter with
respect to which the derivative should be taken.
The input_derivative()
method is used to obtain the partial
derivatives of the mean function with respect to its inputs.
(This is useful for obtaining marginal effects). Its arguments should be
the same as the mean()
method, with an additional argument:
dimension
, an integer vector of length one giving the dimension of X
with respect to which the derivative is being taken.
Its constructor should take at least one argument, hypers
,
which will be stored as the data member hypers
.
This should have a sane default, as many users may pass the class generator
to the constructor for a GPModel
without explicitly
specifying hyperparameters. This should not cause much difficulty if the
user optimizes the hyperparameters, but a sane default should be provided
nonetheless.
The data member hypers
should be a public member so that it can be
accessed and modified directly.
The data member name
should be hard-coded within the class definition;
it is used for printing purposes (potentially in other functions). It should
be a public member so that it can be accessed directly.
name
A character vector of length one giving the mean function's name
hypers
A numeric vector giving the mean function's hyperparameters
mean()
Compute function prior mean
MeanFunction$mean(X, hypers = NULL)
X
The input values (should be a numeric matrix)
hypers
A numeric vector giving hyperparameters for the mean function. If NULL (the default), the hypers data member is used.
parameter_derivative()
Compute partial derivatives of mean function with respect to its hyperparameters
MeanFunction$parameter_derivative(X, hypers = NULL, param = 1)
X
The input values (should be a numeric matrix)
hypers
A numeric vector giving hyperparameters for the mean function. If NULL (the default), the hypers data member is used.
param
An integer vector of length one; which element of
hypers
should the derivative be taken with respect to?
The default is 1
input_derivative()
Compute partial derivatives of mean function with respect to its inputs
MeanFunction$input_derivative(X, hypers = NULL, dimension = 1)
X
The input values (should be a numeric matrix)
hypers
A numeric vector giving hyperparameters for the mean function. If NULL (the default), the hypers data member is used.
dimension
an integer vector of length one giving the dimension of X with respect to which the derivative is being taken; the default is 1
new()
Create a new MeanFunction object
MeanFunction$new(hypers = numeric())
hypers
A numeric vector giving hyperparameters for the mean function.
clone()
The objects of this class are cloneable with this method.
MeanFunction$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.