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
termusing the provided basis. The penalty matrix is taken frombasis.penaltyand a coefficient variable with an appropriate multivariate-normal prior is created. The returned term evaluates tobasis @ 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 likef(x)when the basis input is namedx. (default:'f')scale (
Var|Any|float) – Scale parameter passed to the coefficient prior. Defaults to1000.0for a weakly-informative prior. (default:1000.0)inference (
Any) – Inference specification forwarded to the coefficient variable creation, aliesel.goose.MCMCSpec. (default:None)noncentered (
bool) – IfTrue, the term is reparameterized to the non-centered form viareparam_noncentered()before being returned. (default:False)
- Return type:
- Returns:
A
terminstance 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
ScaleWeibullA 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)