Model Selection
ondil
employs online model selection based on information criteria (IC). We calculate the IC based on the Residual Sum of Squares (RSS), which can be tracked online.
API Reference
ondil.InformationCriterion
Calculate the information criteria.
+---------+------------------------------------+--------------------------+
| ic
| Information Criterion | Formula |
+=========+====================================+==========================+
| "aic"
| Akaike's Information Criterion | \(- 2l + 2\log(n)\) |
| "bic"
| Bayesian Information Criterion | \(- 2l + 2p\log(n)\) |
| "hqc"
| Hannan-Quinn Information Criterion | \(- 2l + 2p\log(\log(n))\) |
| "max"
| Select the largest model | |
+---------+------------------------------------+--------------------------+
Methods:
from_rss(rss) Compute the chosen criterion from residual sum of squares. from_ll(log_likelihood) Compute the chosen criterion directly from a log-likelihood value.
__init__
__init__(n_observations: Union[int, ndarray], n_parameters: Union[int, ndarray], criterion: Literal['aic', 'bic', 'hqc', 'aicc', 'max'] = 'aic')
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_observations
|
int or array - like
|
Number of observations used in the model. |
required |
n_parameters
|
int or array - like
|
Number of estimated parameters in the model. |
required |
criterion
|
{"aic","bic","hqc","aicc", "max"}, default="aic"
|
The information criterion to compute. |
'aic'
|
Raises:
Type | Description |
---|---|
ValueError
|
If the criterion is not recognized. |
from_ll
Compute the specified information criterion directly from log-likelihood.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_likelihood
|
float or array - like
|
The log-likelihood of the model. |
required |
Returns:
Name | Type | Description |
---|---|---|
ic |
float or array - like
|
The information criterion value (AIC, AICC, BIC, HQC, or Max). |
from_rss
Compute the specified information criterion from the residual sum of squares (RSS).
The Gaussian log-likelihood is estimated as
ll = -n/2 * log(rss / n) - n/2 * (1 + log(2π))
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rss
|
float or array - like
|
Residual sum of squares of the fitted model. |
required |
Returns:
Name | Type | Description |
---|---|---|
ic |
float or array - like
|
The information criterion value (AIC, AICC, BIC, HQC, or Max). |