TermBuilder.kriging()

TermBuilder.kriging()#

TermBuilder.kriging(*x, k, scale='default', inference='default', kernel_name='matern1.5', linear_trend=True, range=None, power_exponential_power=1.0, knots=None, absorb_cons=True, diagonal_penalty=True, scale_penalty=True, factor_scale=False, prefix='', name=None)[source]#

Gaussian process models with a fixed range parameter in a basis-penalty-parameterization, often referred to as Kriging.

Parameters:
  • *x (str | Var) – Name of input variables (one or more).

  • k (int) – Number of (unconstrained) bases.

  • scale (ScaleIG | Var | float | VarIGPrior | Literal['default'], default: 'default') –

    Scale parameter passed to the coefficient prior, StrctTerm.scale.

    • If "default", the scale will be initialized according to the default scale function defined for this TermBuilder instance. Please refer to the TermBuilder documentation for more information.

    • If you pass a float, this will be taken as the constant value of the scale, and the scale will not be estimated as part of the model without further action.

    • If you pass a liesel.model.Var, this will be used as the scale. Make sure to define the inference attribute of your custom scale variable (or a latent, transformed version of it).

    • If you pass a VarIGPrior, a scale variable will be set up for you using ScaleIG. This means, the scale will be \(\tau\), with an iverse Gamma prior on its square, i.e. \(\tau^2 \sim \operatorname{InverseGamma}(a, b)\), where a and b are taken from the VarIGPrior object. A fitting Gibbs kernel will be set up automatically to sample \(\tau^2\) in this case, see ScaleIG for details.

  • inference (Any | None | Literal['default'], default: 'default') – Inference specification for this term’s coefficient. Note that this inference is only used for the coefficient variables of the terms created by this builder (StrctTerm.coef), not for the scale variables (StrctTerm.scale). The default ("default") uses the TermBuilder’s default inference specification defined during initialization. Please refer to the TermBuilder documentation for more information.

  • kernel_name (Literal['spherical', 'power_exponential', 'matern1.5', 'matern2.5', 'matern3.5'], default: 'matern1.5') – Selects the kernel / covariance function to use.

  • linear_trend (bool, default: True) – Whether to include or remove a linear trend.

  • range (float | None, default: None) – Range parameter. If None, estimated as in Kamman & Wand (2003).

  • power_exponential_power (float, default: 1.0) – Power for the power exponential kernel.

  • absorb_cons (bool, default: True) – Whether the default identification constraint should be applied by reparameterization and absorbing the reparameterization matrix into the basis and penalty matrices for computational efficiency. If False, the basis is unconstrained, if True it receives a sum to zero constrained. Also see Basis.constrain().

  • diagonal_penalty (bool, default: True) – Whether the penalty matrix associated with this term should be reparameterized into a diagonal matrix. In this case, the basis matrix is reparameterized accordingly. This can be beneficial for posterior geometry, which is why it is the default. Also see Basis.diagonalize_penalty().

  • scale_penalty (bool, default: True) – Whether the penalty matrix should be scaled such that its infinity norm is one. This can improve numerical stability, which is why it is done by default. Also see Basis.scale_penalty().

  • factor_scale (bool, default: False) – Whether to factor out the scale in the prior for this term, turning it into a partially (or fully) standardized form. See StrctTerm.factor_scale() for details.

  • prefix (str, default: '') – A string prefix to be added to the returned term’s name.

  • name (str | None, default: None) – Manually defined name of the term. If a prefix is specified, the prefix will be added to this name.

See also

BasisBuilder

Initializes the basis and penalty.

Return type:

StrctTerm

Notes

This method internally calls the R package mgcv to set up the basis and penalty. The mgcv documentation provides further details.

References

Examples

>>> import liesel_gam as gam
>>> df = gam.demo_data(100)
>>> tb = gam.TermBuilder.from_df(df)
>>> tb.kriging("x_nonlin", k=20)
StrctTerm(name="kriging(x_nonlin)")