Solved – Difference between p-value of chi-squared calculation, and p-value in “critical value” lookup table

chi-squared-testscipy

I am learning about chi-squared. It has two steps; a) chi-squared calculation b) critical value

When I calculate chi-squared, the output includes a) chi-squared statistic (220.5) and b) a p-value (1.315…e-48):

chisquare_result = stats.chisquare(df['observed'], df['expected'])
chisquare_result
# Output : Power_divergenceResult(statistic=220.5, pvalue=1.3153258948574585e-48)

When I lookup the critical value, my course materials describe my inputs as a) degrees of freedom, and b) a concept described as a p-value (where we used typical threshold 0.05).

# Desired p-value is 0.05, and (1-0.05) = 0.95
p_value =  0.05
critical_value = stats.chi2.ppf(q=(1-p_value), df=2)
# Output: 5.991464547107979

My questions:

  1. Are the bolded "p-values" I mention above; are they both truly p-values?

    a) If they are both p-values, what's the difference between them, why don't they each have the same value?

    b) If they are not both p-values; what's the difference between them?

  2. If I can get a p-value as output when calculating chi-squared, why do I need to calculate a critical value?

    a) In other words; why isn't the p-value from chi-squared sufficient to reject/fail-to-reject Null Hypothesis?

Best Answer

5.99 is the critical value for 2 degrees of freedom and p = 0.05. So any value of $\chi^2$ greater than 5.99 is significant at the 0.05 level.

220.5 is the critical value for 2 degrees of freedom and p = $1.315 \times 10^{-48}$ so any value greater than 220.5 is significant at that level.

The difference is that in one case you are specifying the level first (0.05) and asking what value of $\chi^2$ is significant beyond that level and in the other case you are starting from your obtained value of $\chi^2$ and asking what the critical value would have been.