How to calculate Chi-Square density value only known P-value?

49 Views Asked by At

Everywhere online there is how to calculate the Chi-Square density value given a confidence level: α/p value; but I can not find how one calculates the inverse? How to calculate the density value knowing only the α/p-value?

For example, if df = 4, and α=0.95, then how does one calculate the $\chi^2_4$?

In R this would be qchisq(0.95, 4)= 9.4877. What is the math behind this?

1

There are 1 best solutions below

2
On BEST ANSWER

The $\chi_4^2$ PDF is $\frac14xe^{-x/2}$ for $x\ge0$, so the CDF is $F(x)=\int_0^x\frac14te^{-t/2}dt=1-\frac12(x+2)e^{-x/2}$. Solving $\alpha=F(x)$ for $x$ requires the Lambert $W$ function, viz.$$-\tfrac1e(1-\alpha)=(-x/2-1)e^{-x/2-1}\implies x=-2(1+W(-\tfrac1e(1-\alpha))).$$