numeraire.core.stats#

Inference primitives for asset-pricing evaluation (pure numpy/scipy, no heavy deps).

Small, closed-form statistical tests the evaluator layer and reference-result tests build on:

  • grs_test() — Gibbons-Ross-Shanken (1989) joint zero-alpha F-test of a factor model on a set of test assets (exact small-sample F under i.i.d. normal errors).

  • sharpe_diff_test() — Jobson-Korkie (1981) paired Sharpe-ratio difference z-test with the Memmel (2003) variance correction (the convention of the 1/N-style horse races).

  • clark_west_test() — Clark-West (2007) MSPE-adjusted test for nested forecast comparisons (the companion to the Goyal-Welch OOS R²; plain Diebold-Mariano is oversized for nested models).

  • alpha_regression() — time-series alpha vs a factor benchmark with HAC (Newey-West) standard errors (the volatility-managed-portfolio-style headline regression).

  • fama_macbeth() — Fama-MacBeth (1973) two-pass cross-sectional risk-premia estimation with FM t-statistics, optional Shanken (1992) errors-in-variables and Newey-West corrections.

  • adjust_pvalues() — multiple-testing adjustments for factor-zoo sweeps (Bonferroni, Holm, Benjamini-Yekutieli), the Harvey-Liu-Zhu (2016) toolbox behind the “t > 3.0” hurdle.

  • newey_west_lrv() — the shared Bartlett-kernel long-run variance helper.

The mean-variance economic-value family (the 1/N-horse-race metrics):

  • certainty_equivalent() — DeMiguel-Garlappi-Uppal (2009) eq. 12 certainty-equivalent return of a strategy’s realized returns (mean - gamma/2 var); their headline utility metric.

  • return_loss() — DGU (2009) eq. 17 return-loss of a strategy vs a benchmark (the extra return the benchmark’s Sharpe line delivers at the strategy’s risk, net of the strategy’s mean).

  • performance_fee() — Fleming-Kirby-Ostdiek quadratic-utility performance fee: the per-period fee equating E[U(benchmark)] and E[U(candidate - fee)].

All functions take plain arrays/frames and return frozen result dataclasses (or a scalar for the economic-value metrics); evaluator classes in numeraire.core.evaluators adapt them to OOS outputs and the tidy result schema.

grs_test

Gibbons-Ross-Shanken (1989) test that all time-series alphas are jointly zero.

GRSResult

GRS joint zero-alpha test: F ~ F(n_assets, n_obs - n_assets - n_factors) under H0.

sharpe_diff_test

Jobson-Korkie (1981) z-test of equal Sharpe ratios with the Memmel (2003) correction.

SharpeDiffResult

Paired Sharpe difference: z is asymptotically standard normal under equal Sharpe.

clark_west_test

Clark-West (2007) MSPE-adjusted test for nested models.

ClarkWestResult

Clark-West MSPE-adjusted comparison of nested forecasts (one-sided: model beats bench).

alpha_regression

OLS of portfolio (excess) returns on factor returns; HAC (Bartlett) coefficient errors.

AlphaResult

Time-series alpha regression r_p = alpha + beta' F + e with HAC standard errors.

adjust_pvalues

Multiple-testing adjustment for a family of tests (Harvey-Liu-Zhu 2016 §4.4 toolbox).

MultipleTestResult

Multiple-testing adjustment over a family of p-values (original input order).

newey_west_lrv

Bartlett-kernel long-run variance of a 1-D series (lags=0 = plain variance, MLE).

certainty_equivalent

DGU (2009) eq.

return_loss

DGU (2009) eq.

performance_fee

Quadratic-utility performance fee (Fleming-Kirby-Ostdiek; Kirby-Ostdiek 2012 eq.