nullspace_remover()

nullspace_remover()#

liesel_ptm.nullspace_remover(pen)[source]#

Constructs a reparameterization matrix fo removing the nullspace from a penalty matrix of a structured additive predictor term.

Parameters:

pen (Any) – Penalty matrix.

Return type:

Any

Examples

Example usage:

import numpy as np
import tensorflow_probability.substrates.jax.distributions as tfd
import liesel.model as lsl
import liesel_ptm as ptm

np.random.seed(2407)
x = np.random.uniform(low=-1.0, high=1.0, size=300)
nparam = 10
knots = ptm.kn(x, n_params=nparam)

K = ptm.diffpen(nparam, diff=2)
Z = ptm.nullspace_remover(K)
Kz = Z.T @ K  @ Z

def basis_fn(x):
    return ptm.bspline_basis(x, knots, 3) @ Z

tau2 = ptm.VarWeibull(10.0, scale=0.05, name="tau2")

term = ptm.StructuredAdditiveTerm(
    x=x, basis_fn=basis_fn, K=Kz, tau2=tau2, name="my_term"
)