terms.Model

terms.Model(*terms, response=None)

Model terms and response.

Parameters

terms : Term = ()

This object can be instantiated with one or many terms.

response : Response = None

The response term. Defaults to None which means there is no response.

Attributes

Name Description
common_components Components in common terms in the model.
terms Terms in the model.
var_names Get the name of the variables in the model.

Methods

Name Description
add_response Add response term to model description.
add_term Add term to model description.
eval Evaluates terms in the model.
set_types Set the type of the terms in the model.

add_response

terms.Model.add_response(term)

Add response term to model description.

This method is called when something like "y ~ x + z" appears in a model formula.

This method is called via special methods such as Response.__add__.

Returns

self : Model

The same model object but now with a response term.

add_term

terms.Model.add_term(term)

Add term to model description.

The term added can be of class Intercept, Term, or GroupSpecificTerm. It appends the new term object to the list of common terms or group specific terms as appropriate.

This method is called via special methods such as add.

Returns

self : Model

The same model object but now containing the new term.

eval

terms.Model.eval(data, env)

Evaluates terms in the model.

Parameters

data : pd.DataFrame

The data frame where variables are taken from

env : Environment

The environment where values and functions are taken from.

set_types

terms.Model.set_types(data, env)

Set the type of the terms in the model.

Calls .set_type() method on term in the model.

Parameters

data : pd.DataFrame

The data frame where variables are taken from

env : Environment

The environment where values and functions are taken from.