StabilityAssessment#

class cultivars.diagnostics.stability.StabilityAssessment(eigenvalues, max_modulus, is_stable, n_unit_roots, n_explosive, tol)[source]#

The outcome of a stability (or invertibility) assessment.

A deterministic reading of a coefficient array or a transition matrix: the companion eigenvalues, their largest modulus, a count of the roots on and beyond the unit circle, and the verdict under the criterion the caller asked for. There is no null hypothesis and no sampling variation in it. Instances are built by the class methods, not by the constructor, which performs no validation and does not check that the fields agree with one another.

The record does not store which criterion produced is_stable. The counts are criterion-free, so the other verdict can always be recovered: the permissive one is n_explosive == 0 and the strict one is max_modulus < 1 - tol.

The dataclass is frozen, so fields cannot be rebound, but eigenvalues is an ordinary writeable array and is not copied on access. Because that field is an array, the generated __eq__ raises ValueError when two records with more than one eigenvalue are compared and __hash__ raises TypeError; compare fields, not records.

Variables:
  • eigenvalues (NDArray[cdouble]) – The companion eigenvalues (complex), shape (k * p,) in the order NumPy returns them, which is not sorted by modulus. Empty when there are no lags.

  • max_modulus (float) – The largest eigenvalue modulus; 0.0 when there are no eigenvalues (p == 0).

  • is_stable (bool) – Whether the requested stability criterion is satisfied. With allow_unit_roots=False this means all moduli are strictly below 1 - tol; with allow_unit_roots=True it means no modulus exceeds 1 + tol.

  • n_unit_roots (int) – Number of eigenvalues whose modulus is within tol of 1.

  • n_explosive (int) – Number of eigenvalues with modulus above 1 + tol.

  • tol (float) – The modulus tolerance used for classification. Recorded as 0.0 on the trivial record that assess_stability() returns for empty coefficients, whatever tolerance was passed.

See also

Example

>>> res = _StabilityAssessment.assess_stability([0.5, -0.3])
>>> res.is_stable, res.n_unit_roots, res.n_explosive
(True, 0, 0)
>>> round(res.max_modulus, 4)
0.5477
>>> walk = _StabilityAssessment.assess_stability([1.0])
>>> walk.is_stable, walk.n_unit_roots, walk.n_explosive
(False, 1, 0)

Attributes#

eigenvalues

Companion eigenvalues, shape (k * p,); empty when there are no lags.

max_modulus

the largest eigenvalue modulus.

is_stable

Verdict under the criterion the producer was asked for.

n_unit_roots

Number of eigenvalues with \(\bigl|\, |\lambda| - 1 \,\bigr| \le \mathrm{tol}\).

n_explosive

Number of eigenvalues with modulus above 1 + tol.

tol

Half-width of the unit-root band around modulus one used to classify.

Methods#

assess_stability(ar_coeffs, *[, tol, ...])

Assess stationarity of an AR/VAR from its autoregressive coefficients.

assess_stability_from_companion(companion, *)

Assess stability directly from a companion (or state-transition) matrix.

is_invertible(ma_coeffs, *[, tol])

Is an MA/ARMA invertible? (companion of the MA polynomial, roots inside).

is_stationary(ar_coeffs, *[, tol])

Convenience predicate: is the AR/VAR strictly stationary?