Skip to contents

Regression trends \(m(x) = h(x)^\top \beta\), the mean of universal kriging, with fixed, estimated, or marginalized coefficients.

Usage

linear_mean(coefficients = estimate_coefficients())

polynomial_mean(
  degree = 2L,
  coefficients = estimate_coefficients(),
  center = NULL,
  scale = NULL
)

basis_mean(basis, coefficients = estimate_coefficients())

Arguments

coefficients

estimate_coefficients() (the default), coefficient_prior(), or a numeric vector that fixes the coefficients, in the order of the basis columns.

degree

Non-negative integer polynomial degree.

center, scale

Optional centring and scaling of the inputs for polynomial_mean(): one value, recycled, or one per input column. If NULL, they are set from the training inputs when a model is fitted.

basis

A function of the input matrix that returns a numeric matrix with one row per input and one column per coefficient.

Value

An object of class gaussianprocesses_mean.

Details

The bases are:

linear_mean()

\(h(x) = (1, x_1, \ldots, x_D)\), on the raw inputs, so the coefficients are an intercept and slopes. Coefficients are named intercept, x1, ..., xD.

polynomial_mean()

An intercept and the powers \(z_d, z_d^2, \ldots, z_d^{k}\) of each standardized input \(z_d = (x_d - c_d) / s_d\), without interactions. Powers of raw inputs make badly conditioned bases, so by default \(c_d\) is the midpoint and \(s_d\) half the range of the training inputs, which maps them to \([-1, 1]\). A fitted model stores these values in its mean specification and uses them for prediction, and the coefficients, named intercept, x1, x1^2, ..., refer to the standardized inputs. polynomial_mean(0) is an unknown constant.

basis_mean()

The columns returned by basis, named by its column names or h1, h2, ....

mean_coefficients describes the three treatments of \(\beta\). coef() and vcov() return the coefficients of a fitted model and their covariance.

Parametric means are supported by exact models: fit_gp(), optimize_gp(), and the functions that use them. Sparse and heteroscedastic models accept them only with fixed coefficients.

Stability

Stable: from version 1.0.0 this interface changes incompatibly only in a major release, after a deprecation period. Results and options that concern an experimental model class, kernel, or argument follow that interface's tier. See gaussianprocesses-package for the policy.

Examples

x <- cbind(seq(0, 4, length.out = 30), rep(c(-1, 1), 15))
y <- 2 + 0.5 * x[, 1] - x[, 2] + sin(2 * x[, 1])

model <- fit_gp(x, y, rbf_kernel(length_scale = c(0.5, 5)),
  noise_variance = 0.01, mean = linear_mean())
coef(model)
#>  intercept         x1         x2 
#>  1.9338971  0.6160378 -0.9973937 
sqrt(diag(vcov(model)))
#> intercept        x1        x2 
#> 0.8000809 0.3197464 0.1014175 

# A quadratic trend in one input; coefficients refer to inputs scaled to
# [-1, 1].
x1 <- seq(-3, 3, length.out = 30)
quadratic <- fit_gp(x1, x1^2 + sin(3 * x1), rbf_kernel(length_scale = 0.4),
  noise_variance = 0.01, mean = polynomial_mean(2))
coef(quadratic)
#>    intercept           x1         x1^2 
#> 1.028813e-17 1.577561e-01 9.000000e+00 
quadratic$mean$scale
#> [1] 3

# Any basis, here a periodic one with fixed coefficients.
seasonal <- basis_mean(
  function(x) cbind(sin = sin(x[, 1]), cos = cos(x[, 1])),
  coefficients = c(1, 0.5)
)
evaluate_mean(seasonal, c(0, pi / 2))
#> [1] 0.5 1.0