Skip to main content

Term

Enum Term 

Source
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).

Fields

§name: String
§reference: Option<String>
§

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.

Fields

§

Poly

Raw powers x, x², …, x^degree of a numeric column, named x, x^2, ….

Fields

§name: String
§degree: usize
§

Hinges

Hinge functions max(0, x − k) at each knot, named hinge(x,k).

Fields

§name: String
§knots: Vec<f64>
§

Steps

Steps 1[x ≥ k] at each knot, named step(x,k).

Fields

§name: String
§knots: Vec<f64>
§

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.

Fields

§name: String
§cuts: Vec<f64>
§reference: Option<usize>
§

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

Fields

§name: String
§base: f64
§

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.

Fields

§name: String
§levels: Vec<String>
§

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.

Fields

§name: String
§degree: usize
§

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.

Fields

§name: String
§knots: Vec<f64>
§boundary: Option<(f64, f64)>

Trait Implementations§

Source§

impl Clone for Term

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Term

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Term

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V