pub enum Term {
Intercept,
Numeric(String),
Factor {
name: String,
reference: Option<String>,
},
Interaction {
a: String,
b: String,
},
Poly {
name: String,
degree: usize,
},
Hinges {
name: String,
knots: Vec<f64>,
},
Steps {
name: String,
knots: Vec<f64>,
},
Bins {
name: String,
cuts: Vec<f64>,
reference: Option<usize>,
},
Log {
name: String,
base: f64,
},
Ordinal {
name: String,
levels: Vec<String>,
},
OrthogonalPoly {
name: String,
degree: usize,
},
NaturalSpline {
name: String,
knots: Vec<f64>,
boundary: Option<(f64, f64)>,
},
}Expand description
One term of a model formula.
Variants§
Intercept
A column of ones.
Numeric(String)
A numeric column, as is.
Factor
A categorical column in treatment coding: one indicator column per level except the reference. The reference is the given level, or the first in sorted order (R’s and statsmodels’ default).
Interaction
The product of two columns, each numeric as is or a factor in
treatment coding with its first level as reference: a:b, a[x]:b
or a[x]:b[y], R’s a:b beside main effects.
Poly
Raw powers x, x², …, x^degree of a numeric column, named x,
x^2, ….
Hinges
Hinge functions max(0, x − k) at each knot, named hinge(x,k).
Steps
Steps 1[x ≥ k] at each knot, named step(x,k).
Bins
A numeric column cut into bins (−∞, c₁], (c₁, c₂], …, (c_k, ∞) and
coded as a factor (named as R’s cut, x[(30,45]]), the bin with
index reference (default 0, the lowest) as reference.
Log
ln(x / base), named log(x/base): a log transform centred so a
coefficient’s base value is base (CAS Monograph 5, section 5.6.2).
Ordinal
An ordered factor in cumulative coding: for each level after the
first in levels’ order, 1[level ≥ it], named x[>=level]. Each
coefficient is the step from the level below.
OrthogonalPoly
Orthogonal polynomials of degree 1 to degree on the training
values, as R’s poly(x, degree), named poly(x)1, poly(x)2, ….
The recurrence learned in training rebuilds them on new data.
NaturalSpline
A natural cubic spline with interior knots, linear beyond the
boundary knots (the training range unless given): knots.len() + 1
columns named spline(x)1, …. The basis is the restricted cubic
(truncated power) one, which spans the same functions as R’s
splines::ns(x, knots): fitted values agree, coefficients differ.
Trait Implementations§
impl StructuralPartialEq for Term
Auto Trait Implementations§
impl Freeze for Term
impl RefUnwindSafe for Term
impl Send for Term
impl Sync for Term
impl Unpin for Term
impl UnsafeUnpin for Term
impl UnwindSafe for Term
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more