RankLags
- class tsbootstrap.ranklags.RankLags(X: ndarray, model_type: Literal['ar', 'arima', 'sarima', 'var', 'arch'], max_lag: Integral = 10, y=None, save_models: bool = False)[source]
A class that uses several metrics to rank lags for time series models.
- rank_lags_by_aic_bic()[source]
Rank lags based on Akaike information criterion (AIC) and Bayesian information criterion (BIC).
- rank_lags_by_pacf()[source]
Rank lags based on Partial Autocorrelation Function (PACF) values.
- estimate_conservative_lag()[source]
Estimate a conservative lag value by considering various metrics.
- get_model(order)[source]
Retrieve a previously fitted model given an order.
Examples
>>> from tsbootstrap import RankLags >>> import numpy as np >>> X = np.random.normal(size=(100, 1)) >>> rank_obj = RankLags(X, model_type='ar') >>> rank_obj.estimate_conservative_lag() 2 >>> rank_obj.rank_lags_by_aic_bic() (array([2, 1]), array([2, 1])) >>> rank_obj.rank_lags_by_pacf() array([1, 2])
- property X: ndarray
The input data.
- Returns:
The input data.
- Return type:
np.ndarray
- estimate_conservative_lag() int [source]
Estimate a conservative lag value by considering various metrics.
- Returns:
A conservative lag value.
- Return type:
int
- get_model(order: int)[source]
Retrieve a previously fitted model given an order.
- Parameters:
order (int) – Order of the model to retrieve.
- Returns:
The fitted model.
- Return type:
Union[AutoRegResultsWrapper, ARIMAResultsWrapper, SARIMAXResultsWrapper, VARResultsWrapper, ARCHModelResult]
- property max_lag: Integral
Maximum lag to consider.
- Returns:
Maximum lag to consider.
- Return type:
int
- property model_type: Literal['ar', 'arima', 'sarima', 'var', 'arch']
The type of model to fit.
- Returns:
The type of model to fit.
- Return type:
str
- rank_lags_by_aic_bic()[source]
Rank lags based on Akaike information criterion (AIC) and Bayesian information criterion (BIC).
- Returns:
aic_ranked_lags: Lags ranked by AIC. bic_ranked_lags: Lags ranked by BIC.
- Return type:
Tuple[np.ndarray, np.ndarray]
- rank_lags_by_pacf() ndarray [source]
Rank lags based on Partial Autocorrelation Function (PACF) values.
- Returns:
Lags ranked by PACF values.
- Return type:
np.ndarray
- property y: ndarray
Exogenous variables to include in the model.
- Returns:
Exogenous variables to include in the model.
- Return type:
np.ndarray