models package

Submodules

models.regression module

quant_risk.models.regression.regress(endogenousSeries: pandas.core.series.Series, exogenousSeries: Union[pandas.core.series.Series, pandas.core.frame.DataFrame], method: str = 'OLS', **kwargs)[source]

This function implements regression for a given set of endogeneous and exogeneous variables. Note: summary() function is not available for any method except ‘OLS’

Parameters
  • endogenousSeries (pd.Series) – Endogenous series for our regression

  • exogenousSeries (Union[pd.Series, pd.DataFrame]) – Exogenous covariates for our regression

  • method (str, optional) – Type of regression to be conducted Possible inputs include: 1. OLS 2. Ridge 3. Lasso , by default ‘OLS’

Returns

Returns a fitted instance of the regression model

Return type

RegressionResults

Raises

NameError – Incase an invalid method is selected, a NameError is raised

models.time_series module

quant_risk.models.time_series.auto_arima(endogenousSeries: Union[pandas.core.series.Series, numpy.array], exogenousSeries: Union[pandas.core.frame.DataFrame, numpy.array], pRange: int = 5, dRange: int = 1, qRange: int = 5, metric: str = 'BIC', **kwargs)[source]

This function implements an auto-arima model by utilising a grid search over the parameter ranges for the autoregressive, differencing, moving average parameters for each model. Each model is then evaluated based on the specifed metric and the model with the lowest metric statistic is chosen as the best model. The order params for the best model are saved and another model is fitted with those params.

Parameters
  • endogenousSeries (Union[pd.Series, np.array]) – The endogenous variable for our ARIMA model

  • exogenousSeries (Union[pd.DataFrame, np.array]) – The exogeneous variables for our ARIMA model

  • pRange (int, optional) – The maximum value of the autogressive component till where we want to search, by default 5

  • dRange (int, optional) – The maximum value of the differencing/integrated order component till where we want to search, by default 1

  • qRange (int, optional) – The maximum value of the moving average component till where we want to search, by default 5

  • metric (str, optional) – The metric by which we want to search and choose our model, by default ‘BIC’

Returns

Returns a fitted arima model with the best chosen order of components

Return type

Fitted ARIMA Result

Raises

RuntimeWarning – If the model fails to converge on any order, a RuntimeWarning is engaged

Module contents