pythonscipystatisticsscipy.stats

Is there critical F-Value look up with scipy or other library?


Scipy Stats comes with an ANOVA test f_oneway() that returns a p-value and a F-score. The p-score easily tells you if your test passes or fails simply by comparing it to your alpha threshold, which can be chosen arbitrarily small to make the test stricter. If the p-value falls below your chosen alpha, good to go.

However, it seems like the F-Value is rather meaningless unless you have a critical value to compare it to. Looking at Wikipedia, it seems like this critical value is computed based on alpha, degrees of freedom, etc. As a stats moron (but getting better!), I don't really want to try my hand at making my own function, but I can't find one in the stats library. Am I missing something?

Reason for question: I want to make a bar graph of F-scores next to their critical values. p-values seem to be really small, so not so good for graphing.


Solution

  • You can use ppf method of scipy.stats.f which stands for percent point function (inverse of cdf).

    Usage is:

    from scipy.stats import f
    lower_tail_prob = 0.05
    dof_num = 5
    dof_den = 12
    f_critical = f.ppf(lower_tail_prob, dof_num, dof_den)
    

    The lower_tail_prob argument might be your alpha if one-tailed test, or alpha / 2 if two-tailed.