Linear Functions
Contents
Linear Functions¶
At the heart of most common discrete choice models is a linear-in-parameters utility function. Larch is written with this design specifically in mind. It is designed to integrate with Panda and NumPy and facilitate fast processing of linear models.
Note
If you want to estimate non-linear models, try Biogeme, which is more flexible in form and can be used for almost any model structure.
The basic structure of any linear-in-parameters function is that it is a summation of a sequence
of terms, where each term is the product of a parameter and some data. The data could be
a simple single named value (e.g. travel_cost
), or it could be some function of one or more other pieces of data,
but the important salient feature of data is that it can be computed without knowing the
value of any model parameter to be estimated (e.g. log(1+travel_cost)
).
- class UnicodeRef_C¶
Bases:
str
A common base class for all larch named reference types.
This class itself has no features and should not be instantiated. Instead create
ParameterRef_C
orDataRef_C
objects as needed.
Parameters¶
- class ParameterRef_C(*args)¶
Bases:
larch.model.linear.UnicodeRef_C
- as_pmath(self)¶
- set_fmt(self, unicode formatting)¶
- string(self, m)¶
The value of the parameter in a given model, as a formatted string.
- Parameters
m (Model) – The model from which to extract a parameter value.
- Returns
str
- valid(self, m)¶
Check if this ParameterRef would give a value for a given model.
- Parameters
m (Model) – The model from which to extract a parameter value.
- Returns
bool – False if the value method would raise an exception, and True otherwise.
- value(self, *args)¶
The value of the parameter in a given model.
- Parameters
m (Model) – The model from which to extract a parameter value.
- Returns
float
Data¶
- class DataRef_C¶
Bases:
larch.model.linear.UnicodeRef_C
- eval(self, namespace=None, *, globals=None, **more_namespace)¶