Estimation¶
kriterion.fit
¶
ModelSummary
dataclass
¶
ModelSummary(
dof: int | float,
chi2: float,
chi2_p: float,
g2: float,
g2_p: float,
log_likelihood: float,
aic: float,
bic: float,
sse: float,
)
Goodness-of-fit statistics for a fitted model.
| ATTRIBUTE | DESCRIPTION |
|---|---|
dof |
Degrees of freedom.
TYPE:
|
chi2 |
Pearson \(\chi^2\) statistic.
TYPE:
|
chi2_p |
\(p\)-value for the \(\chi^2\) statistic.
TYPE:
|
g2 |
Likelihood-ratio \(G^2\) statistic.
TYPE:
|
g2_p |
\(p\)-value for the \(G^2\) statistic.
TYPE:
|
log_likelihood |
Log-likelihood of the fitted model.
TYPE:
|
aic |
Akaike Information Criterion.
TYPE:
|
bic |
Bayesian Information Criterion.
TYPE:
|
sse |
Sum of squared errors between observed and expected cumulative proportions.
TYPE:
|
fit
¶
fit(
model: Model,
objective: ObjectiveFunction = log_likelihood_objective,
method: str = "L-BFGS-B",
) -> ModelSummary
Fit a theoretical model to observed data.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
An instance of a model subclass, e.g. an instance of
TYPE:
|
objective
|
One of the objective functions, e.g. \(G^2\).
TYPE:
|
method
|
The type of solver to use (see
TYPE:
|
Source code in src/kriterion/fit.py
aic
¶
Akaike's Information Criterion:
This statistic is useful for model comparisons.
| PARAMETER | DESCRIPTION |
|---|---|
k
|
Number of estimated parameters in the model.
TYPE:
|
ll
|
The log of the maximised value of the likelihood function for the model.
TYPE:
|
Source code in src/kriterion/fit.py
bic
¶
Bayesian Information Criterion
This statistic is useful for model comparisons.
| PARAMETER | DESCRIPTION |
|---|---|
k
|
Number of estimated parameters in the model.
TYPE:
|
n
|
Total number of observations in the data.
TYPE:
|
ll
|
The log of the maximised value of the likelihood function for the model.
TYPE:
|
Source code in src/kriterion/fit.py
compare_nested
¶
compare_nested(
restricted: ModelSummary, full: ModelSummary
) -> tuple[float, int | float, ndarray]
Likelihood-ratio test between two nested models.
Tests whether the additional parameters of the fuller model yield a significant improvement in fit, using the difference in \(G^2\) against a \(\chi^2\) distribution with degrees of freedom equal to the difference in parameter counts.
Assumes the two models are nested: the restricted model must be obtainable by fixing one or more of the fuller model's parameters to constants. If they are not nested, the likelihood-ratio test is invalid and AIC or BIC should be used instead via \(\text{AIC}_a - \text{AIC}_b\).
| PARAMETER | DESCRIPTION |
|---|---|
restricted
|
Fit summary of the simpler (restricted) model. This model should have fewer free parameters, and therefore larger residual degrees of freedom.
TYPE:
|
full
|
Fit summary of the fuller model. This model should have more free parameters, and therefore smaller residual degrees of freedom.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[float, int | float, ndarray]
|
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |