psytest.sadftest module#
psytest.sadftest#
This module contains the functions related to the Sup ADF test and the Backward Sup ADF test. The functions allow us to calculate both the test statistic and the asymptotic distribution of the test statistic
See psytest.adfstat
for the basic Augmented Dickey-Fuller test.
- psytest.sadftest.bsadf_stat(y: ndarray[tuple[int, ...], dtype[float64]], r0: float, r2: float, kmax: int) float [source]#
Calculates the Backward Sup ADF test statistic.
- Parameters:
- Returns:
teststat – BSADF statistic.
- Return type:
Notes
The Backward Sup ADF statistic is calculated as: .. math:
\text{BSADF}(r_2) = \max_{r_1 \in [0, r_2 - r_0]} \text{ADF}(y_{r_1:r_2})
where \(\text{ADF}(y_{r_1:r_2})\) is the Augmented Dickey-Fuller test statistic for the series \(y_{r_1:r_2}\) (see
psytest.adfstat.rolling_adfuller_stat()
).
- psytest.sadftest.bsadf_stat_all_series(y: ndarray[tuple[int, ...], dtype[float64]], r0: float, rstep: float, kmax: int) ndarray[tuple[int, ...], dtype[float64]] [source]#
Calculates BSADF statistics over all possible (r1, r2) combinations.
- psytest.sadftest.r2_index(r2: float, r0: float, rstep: float) int [source]#
Get the index of
r2
in the grid fromr0
to 1 with step sizerstep
- psytest.sadftest.make_r2_grid(r0: float, rstep: float) ndarray[tuple[int, ...], dtype[float64]] [source]#
Creates the grid of all possible r2 values.
- psytest.sadftest.make_r1_grid(r2: float, r0: float, rstep: float) ndarray[tuple[int, ...], dtype[float64]] [source]#
Creates the grid of all possible r1 values given r2.
- psytest.sadftest.make_r1r2_combinations(r0: float, rstep: float) ndarray[tuple[int, ...], dtype[float64]] [source]#
Creates a grid of all (r1, r2) index pairs to evaluate BSADF.
- Parameters:
- Returns:
Grid of (r1, r2) pairs.
- Return type:
[float64]
Notes
The grid is defined as: .. math:
\text{grid} = \{(r_1, r_2) : r_0 \leq r_2 \leq 1, \quad r_0 \leq r_1 \leq r_2 - r_0, \\ \quad rstep = (r_2 - r_0)/n, \\ \quad n = \lfloor (1 - r_0)/rstep \rfloor + 1\}
with \(r_0\) being the minimum index, \(r_2\) being the end index, and \(r_1\) being the start index. The values of \(r_1\) and \(r_2\) are created from a grid with increments of
rstep
.
- psytest.sadftest.bsadfuller_critval(r0: float, rstep: float, nreps: int, nobs: int, alpha: Iterable | float, kmax: int) ndarray[tuple[int, ...], dtype[float64]] [source]#
Calculates critical values of BSADF statistics from Monte Carlo simulations.
- Parameters:
- Returns:
critval – Critical values matrix.
- Return type:
NDArray[float64]
Notes
The critical values are calculated as: .. math:
\text{CV}_{i,\alpha} = \text{Quantile}_{1 - \alpha}(\text{BSADF}_i)
where \(\text{BSADF}_i\) is the \(i\)-th simulated BSADF statistic (see
psytest.adfstat.bsadf_stat()
) and \(\text{Quantile}_{1 - \alpha}\) is the quantile function for the distribution of the BSADF statistic.