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_orderto 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’sMF_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:¶
- Returns:¶
NaN if no order could be fitted. Otherwise:
minaic: the lowest AIC across orders 1 tomax_orderaicopt: the order with the lowest AICminlossfn: the lowest loss function across orderslossfnopt: the order with the lowest loss functionmeandiffaic: the mean change in AIC when the order increases by onemaxdiffaic: the largest increase in AIC when the order increases by onemindiffaic: the largest decrease (most negative change) in AIC when the order increases by onendownaic: 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, wheredis 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;lossfnoptis the first order attaining the lowest floored loss.