psytest.critval.critval module#
psytest.critval.critval#
Module to handle the tables in the psytest.critval.data
directory. The main function is psytest.critval.critval_tabulated()
, which calculates the critical values for a given set of parameters. Given the parameters, the function gets the best table to use, based on the precision of the simulations used for each table (see psytest.critval.critval.find_best_table()
for more info). The values in the best match are then interpolated to return the critical values for every input value of psytest.critval.critval_tabulated.r2_eval
.
- psytest.critval.critval.make_colname_from_alpha(alpha: float) str [source]#
Create a column name from the alpha value.
- psytest.critval.critval.find_best_table(kmax: int, r0: float) str [source]#
Finds the table with the best match for the given parameters. It sorts tables by their
nreps
(ascending),nobs
(ascending), andrstep
(descending). It then returns the one with the best value of these that satisfies the condition of having the givenkmax
andr0
as low as given.
- psytest.critval.critval.load_critval(kmax: int, r0: float) DataFrame [source]#
Loads the critical values from the CSV file in the data directory.
- Parameters:
- Returns:
critval_table – A DataFrame containing the critical values. The first column correspond to the
r2
parameter. The remaining columns give, for eachr2
the critical values with significance levels as the column names.- Return type:
DataFrame
- psytest.critval.critval.critval_tabulated(r2_eval: float, kmax: int, r0: float, alpha: float = 0.05) float [source]#
- psytest.critval.critval.critval_tabulated(r2_eval: Iterable[float], kmax: int, r0: float, alpha: float = 0.05) ndarray[tuple[int, ...], dtype[float64]]
Returns the critical values for all
r2
inr2_eval
from the tabulated values in thepsytest.critval.data
directory.- Parameters:
- Returns:
critval_table – The critical values for the given
r2_eval
(if single) or an array of critical values.- Return type:
NDArray[float64] | float
- Raises:
TypeError – If
r2_eval
is not a float or an iterable; ifalpha
is not a float; ifkmax
is not an integer; ifr0
is not a float.ValueError – If
r2_eval
is not between 0 and 1; ifalpha
is not between 0 and 1; ifkmax
is negative; ifr0
is not between 0 and 1; if the critical value for the givenalpha
is not found in the table.