pyhctsa.operations.model_fit.state_space_comp_order

pyhctsa.operations.model_fit.state_space_comp_order(y, max_order=10)

How the fit of a state-space model improves as its order increases.

Fits state-space models (subspace identification, state_space_n4sid()) of orders 1, 2, …, max_order to the whole time series (all fits are within the sample), and returns statistics on how the goodness of fit changes across this range, measured by Akaike’s information criterion (AIC) and by the loss function (the estimated variance of the one-step prediction error), hctsa’s MF_StateSpaceCompOrder. An order at which the model cannot be fitted is left out of the summaries, and the output is NaN only if no order can be fitted.

Parameters:
y : array-like

The input time series.

max_order : int, optional

The maximum model order to consider. Default is 10.

Returns:

NaN if no order could be fitted. Otherwise:

  • minaic: the lowest AIC across orders 1 to max_order

  • aicopt: the order with the lowest AIC

  • minlossfn: the lowest loss function across orders

  • lossfnopt: the order with the lowest loss function

  • meandiffaic: the mean change in AIC when the order increases by one

  • maxdiffaic: the largest increase in AIC when the order increases by one

  • mindiffaic: the largest decrease (most negative change) in AIC when the order increases by one

  • ndownaic: the number of order increases at which the AIC decreases

If some orders cannot be fitted, these are taken over the orders that can; the change statistics use only adjacent pairs of orders that both fitted.

Return type:

dict or float

Notes

The AIC is normalized by the series length, log(max(loss, 1e-10 mean(y^2))) + 2 d/N, where d is twice the order (the number of free parameters of the model once the freedom in the choice of coordinates is removed). The floor on the loss makes orders whose loss is at the level of rounding error (an exactly predictable series) tie, so that the lowest of them is preferred; lossfnopt is the first order attaining the lowest floored loss.