[Math] Probability from chi square distribution

probability distributionsstatistics

How do I find a probability for a chi square distribution?

I have a continous random variable from which I've got the chi square with the formula:

$$\sum \frac{(o-e)^2}{e}$$ where $o$ is the observed value and $e$ the expected value (the mean).

with that value plus the degrees of freedom (the size of my sample – 1), I would like to get result in percentage. Which step should I take? find the z score and the standard normal distribution and then try to get the CDF?

probably off-topic (for mathematics @ stackexchange):

There is any R function to calculate it? Like giving a chi square + degrees of freedom it gives me a %?

Best Answer

Since you're probably performing a chi-squared test, then test-statistic $$ X^2=\sum_{i=1}^n \frac{(O_i-E_i)^2}{E_i} $$ follows a $\chi^2(p)$ distribution with $p=n-1$ degrees of freedom. Since large values are critical, the corresponding $p$-value is given by $$ P(\chi^2(p)\geq X^2)=1-F_{\chi^2(p)}(X^2), $$ i.e. the probability of a $\chi^2(p)$-variable being larger than what we have observed. Here $F_{\chi^2(p)}$ is the distribution function of a $\chi^2(p)$ distribution.

This is easily calculated in R with the command 1-pchisq(x,p), where x denotes the test-statistic $X^2$ and p is the number of degrees of freedom.