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
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?
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?