Statistics API¶
asrquant.statistics ¶
Regression, time-series tests, bootstrap inference, and factor analysis.
RegressionResult
dataclass
¶
Aligned regression outputs with compact plotting helpers.
Source code in src/asrquant/statistics.py
ols ¶
ols(y: Series, x: Series | DataFrame, add_constant: bool = True, covariance: str = 'HAC', maxlags: int | None = None) -> RegressionResult
OLS with classical, HC, or Newey-West/HAC covariance.
Source code in src/asrquant/statistics.py
rolling_regression ¶
rolling_regression(y: Series, x: Series | DataFrame, window: int = 63, add_constant: bool = True) -> pd.DataFrame
Rolling least-squares coefficients.
Source code in src/asrquant/statistics.py
stationarity_tests ¶
ADF and KPSS tests reported together to reduce one-test overinterpretation.
Source code in src/asrquant/statistics.py
block_bootstrap ¶
block_bootstrap(series: Series, statistic: Callable[[Series], float] = np.mean, n_boot: int = 1000, block_size: int | None = None, confidence: float = 0.95, random_state: int | None = 0) -> pd.Series
Moving-block bootstrap confidence interval for dependent data.
Source code in src/asrquant/statistics.py
permutation_test ¶
permutation_test(x: Series, y: Series, statistic: Callable[[ndarray, ndarray], float] | None = None, n_permutations: int = 5000, random_state: int | None = 0) -> pd.Series
Two-sided permutation test for a difference in means by default.
Source code in src/asrquant/statistics.py
benjamini_hochberg ¶
Benjamini-Hochberg false-discovery-rate correction.
Source code in src/asrquant/statistics.py
quantile_regression ¶
quantile_regression(y: Series, x: Series | DataFrame, quantile: float = 0.5, add_constant: bool = True) -> RegressionResult
Linear quantile regression for conditional-tail relationships.
Source code in src/asrquant/statistics.py
polynomial_regression ¶
polynomial_regression(y: Series, x: Series | DataFrame, degree: int = 2, covariance: str = 'HAC', maxlags: int | None = None) -> RegressionResult
Polynomial least-squares regression with named transformed features.
Source code in src/asrquant/statistics.py
regularized_regression ¶
regularized_regression(y: Series, x: Series | DataFrame, method: str = 'ridge', alpha: float = 1.0, l1_ratio: float = 0.5, standardize: bool = True)
Fit Ridge, Lasso, or Elastic Net in a scikit-learn pipeline.
Source code in src/asrquant/statistics.py
logistic_regression ¶
logistic_regression(y: Series, x: Series | DataFrame, add_constant: bool = True, covariance: str = 'HC1') -> RegressionResult
Binary logistic regression with robust covariance support.
Source code in src/asrquant/statistics.py
factor_regression ¶
factor_regression(asset_returns: Series, factors: DataFrame, risk_free: float | Series = 0.0, covariance: str = 'HAC', maxlags: int | None = None) -> RegressionResult
Run a CAPM or multi-factor time-series regression on excess returns.
Source code in src/asrquant/statistics.py
cointegration_test ¶
Engle-Granger two-step cointegration test.
Source code in src/asrquant/statistics.py
granger_causality ¶
Report Granger-predictive F-test p-values; this is not structural causality.
Source code in src/asrquant/statistics.py
arima_fit ¶
Fit an ARIMA model and return the statsmodels result object.
Source code in src/asrquant/statistics.py
var_fit ¶
Fit a vector autoregression to a multivariate stationary panel.
Source code in src/asrquant/statistics.py
autoregression_fit ¶
autoregression_fit(series: Series, lags: int | list[int] = 1, trend: str = 'c', *, old_names: bool = False)
Fit an explicit AR(p) model with statsmodels AutoReg.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
series
|
Series
|
Univariate time series. |
required |
lags
|
int | list[int]
|
Maximum lag order or an explicit list of included lags. |
1
|
trend
|
str
|
Deterministic terms: |
'c'
|