ns_sdn.summary#

The reporting surface: the records every fitted result renders itself through.

summary() on a result does not format anything; it returns a SummaryTable, a record that renders on demand as fixed-width text (print, str, the bare repr), as HTML in a notebook (_repr_html_) or as a pandas.DataFrame (to_pandas). InformationCriteria is the record behind every information_criteria property, the triple

\[\mathrm{AIC} = -2\ell + 2p, \qquad \mathrm{BIC} = -2\ell + p\log m, \qquad \mathrm{HQIC} = -2\ell + 2p\log\log m,\]

for a log-likelihood \(\ell\), \(p\) parameters and an effective sample of \(m\) observations. Both are defined once in _core and bound to this module so pickles, annotations, and the API reference name them here.

Holding the structure rather than the string is what lets the same summary carry its notes into every rendering: a table that says “compare against a random walk before reading these as skill” says it in the notebook, in the terminal and in the frame’s attrs alike.

Example

>>> from ns_sdn.summary import SummaryTable
>>> table = SummaryTable(title="T", metadata=(("a", "1"),), notes=("n",))
>>> table.to_text().splitlines()[-1], type(table).__module__
('n', 'ns_sdn.summary')

The criteria record is a named tuple with a constructor from the likelihood:

>>> from ns_sdn.summary import InformationCriteria
>>> crit = InformationCriteria.from_likelihood(-100.0, 200, 3)
>>> round(crit.aic, 1), round(crit.bic, 2), crit._fields
(206.0, 215.89, ('aic', 'bic', 'hqic'))

Classes#

InformationCriteria

Model-selection criteria computed from a fitted log-likelihood.

SummaryTable

A rendered-on-demand estimation summary.