term.f()

Contents

term.f()#

classmethod term.f(basis, fname='f', scale=1000.0, inference=None, noncentered=False)[source]#

Construct a smooth term from a Basis.

This convenience constructor builds a named term using the provided basis. The penalty matrix is taken from basis.penalty and a coefficient variable with an appropriate multivariate-normal prior is created. The returned term evaluates to basis @ coef.

Parameters:
  • basis (Basis) – Basis object that provides the design matrix and penalty for the smooth term. The basis must have an associated input variable with a meaningful name (used to compose the term name).

  • fname (str) – Function-name prefix used when constructing the term name. Default is 'f' which results in names like f(x) when the basis input is named x. (default: 'f')

  • scale (Var | Any | float) – Scale parameter passed to the coefficient prior. Defaults to 1000.0 for a weakly-informative prior. (default: 1000.0)

  • inference (Any) – Inference specification forwarded to the coefficient variable creation, a liesel.goose.MCMCSpec. (default: None)

  • noncentered (bool) – If True, the term is reparameterized to the non-centered form via reparam_noncentered() before being returned. (default: False)

Return type:

term

Returns:

A term instance configured with the given basis and prior settings.

Notes

The default coefficient name is a LaTeX-like string "$\beta_{f(x)}$" to improve readability in printed summaries.

See also

ScaleWeibull

A scale parameter derived from a variance parameter with Weibull prior.

Examples

Create a P-spline basis and wrap it into a term, using a Weibull prior for the variance parameter:

import liesel.goose as gs
import tensorflow_probability.substrates.jax.bijectors as tfb

# assume x to be a 1d array.
b = ps(x, nbases=10)
scale = ScaleWeibull(
    1.0,
    scale=0.5,
    inference=gs.MCMCSpec(gs.NUTSKernel),
    bijector=tfb.Exp(),
    name="fx_scale"
)
t = term.f(basis=b, scale=scale)