QVARResult.pseudo_r_squared#
- QVARResult.pseudo_r_squared(quantile)[source]#
Koenker-Machado goodness of fit per equation at one level.
1 - loss / loss_location: the share of check loss the regression removes relative to the unconditional quantile,\[R^1(\tau) = 1 - \frac{\sum_t \rho_\tau(y_t - \hat Q_\tau(y_t \mid x_t))} {\sum_t \rho_\tau(y_t - \hat q_\tau)}.\]Local to its level by construction – an
R1at the median says nothing about the tails – and not comparable to a least-squaresR^2.- Parameters:
quantile (
float) – An estimated level.- Return type:
- Returns:
A mapping from equation name to its
R1.- Raises:
SpecificationError – If the level was not estimated.
Example
A persistent system explains more check loss than white noise at every level, and every
R1lies in[0, 1]:>>> import numpy as np >>> rng = np.random.default_rng(0) >>> y = np.zeros((300, 2)) >>> for t in range(1, 300): ... y[t] = 0.7 * y[t - 1] + rng.standard_normal(2) >>> res = QVAR(y, order=1).fit(quantiles=(0.1, 0.5)) >>> fit = res.pseudo_r_squared(0.5) >>> sorted(fit), bool(all(0.0 <= v <= 1.0 for v in fit.values())) (['y1', 'y2'], True) >>> noise = QVAR(rng.standard_normal((300, 2)), order=1).fit(quantiles=(0.5,)) >>> bool(fit["y1"] > noise.pseudo_r_squared(0.5)["y1"]) True