0
$\begingroup$

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

For example, if df = 4, and $\alpha$=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?

$\endgroup$
0

1 Answer 1

0
$\begingroup$

Given the degrees of freedom and an alpha value, qchisq essetnialy finds the point $x$ such that $F(x)=\alpha$, where $F$ is the CDF.

This is known as the $\alpha^{th}$ quantile. The q in the q* functions stands for quantile, and so this class of R functions are the quantile functions for teir respective distributions. You feed them a quantile, $q$, then return the $x$ such that $F(x)=q$.

How this is done in practice depends on what distribution you're working with. Inverting the CDF may be a fun exercise, but not one I'm interested in doing right now. You could use any number of root finding methods to solve

$$F(x)-q=0$$

for $x$ which should yield the correct quantile with sufficiently many iterations.

$\endgroup$
2
  • $\begingroup$ Ok so but how does it find that point? Does it loop over the alpha until a value is found that matches the desired density? $\endgroup$
    – notMyName
    Commented May 22, 2020 at 21:36
  • 1
    $\begingroup$ One way would be to write down the CDF and then invert it algebraically. That isn't likely possible with the chi-square density, so the other option is to use root finding methods to solve $F(x)-q=$ for $x$. Finally, you can actually see how qchisq is implemented by looking up the source code (qchisq calls the method for the quantile function for the gamma distirbution. Find the code here) $\endgroup$ Commented May 22, 2020 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.