TermBuilder.vc()

Contents

TermBuilder.vc()#

TermBuilder.vc(x, by, prefix='', name=None)[source]#

Varying coefficient term.

Parameters:
  • x (str | Var) – Name of input variable.

  • by (StrctTerm) – Smooth term, a StrctTerm that represents the smoothly varying coefficient of this term, for example a P-spline ps().

  • 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.

Return type:

Var

Notes

A varying coefficient term can be written as

\[x \beta(z),\]

where \(x\) is a covariate, and \(\beta(z)\) is the linear effect of this covariate, which smoothly varies as a function of another variable \(z\).

Examples

>>> import liesel_gam as gam
>>> df = gam.demo_data(100)
>>> tb = gam.TermBuilder.from_df(df)
>>> psx = tb.ps("x_nonlin", k=20)
>>> tb.vc(x="x_lin", by=psx)
Var(name="x_lin*ps(x_nonlin)")