StrctTerm.f()

Contents

StrctTerm.f()#

classmethod StrctTerm.f(basis, fname='f', scale=None, inference=None, coef_name=None, factor_scale=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, default: 'f') – 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.

  • scale (ScaleIG | VarIGPrior | Var | Array | ndarray | bool | number | bool | int | float | complex | None, default: None) – Scale parameter passed to the coefficient prior.

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

  • factor_scale (bool, default: False) – If True, the term is reparameterized by factoring out the scale form via factor_scale() before being returned.

  • coef_name (str | None, default: None) – Coefficient name. The default coefficient name is a LaTeX-like string "$\beta_{f(x)}$" to improve readability in printed summaries.

Return type:

Self

Returns:

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

Examples

>>> x = jnp.linspace(0.0, 1.0, 4)
>>> basis = Basis(jnp.column_stack([jnp.ones_like(x), x]), xname="x")
>>> term = StrctTerm.f(basis, scale=1.0)
>>> term.name, term.coef.value.shape
('f(x)', (2,))