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 givenkmaxandr0as 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
r2parameter. The remaining columns give, for eachr2the 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
r2inr2_evalfrom the tabulated values in thepsytest.critval.datadirectory.- 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_evalis not a float or an iterable; ifalphais not a float; ifkmaxis not an integer; ifr0is not a float.ValueError – If
r2_evalis not between 0 and 1; ifalphais not between 0 and 1; ifkmaxis negative; ifr0is not between 0 and 1; if the critical value for the givenalphais not found in the table.