How can I calculate the p-value given Chi Squared and the Degrees of Freedom? For example, what would be the exact p-value of a Chi Squared = 15 with df = 2?
In applied statistics, chisquared test statistics arise as sums of squared residuals, or from sums of squared effects or from log-likelihood differences. In all of these applications, the aim is to test whether some vector parameter is zero vs the alternative that it is non-zero and the chisquare statistic is related to the squared size of the observed effect. The required p-value is the right tail probability for the chisquare value, which in R for your example is:
> pchisq(15, df=2, lower.tail=FALSE)  0.0005530844
For other df or statistic values, you obviously just substitute them into the above code.
All cumulative probability functions in R compute left tail probabilities by default. However they also have a
lower.tail argument, and you can always set this
FALSE to get the right tail probability. It is good practice to do this rather than to compute $1-p$ as you might see in some elementary textbooks.
qchisq does the reverse calculation, finding the value ("q" is for quantile) of the chisquare statistic corresponding to any given tail probability.
For example, the chisquare statistic corresponding to a p-value of 0.05 is given by
> qchisq(0.05, df=2, lower.tail=FALSE)  5.991465
Yes, it is possible to calculate the chi-square value for a given p-value (p) and degrees of freedom (df). Below is how to go about it:
For the sake of verification, I first calculate p for a given chi-square value = 1.1 and df=1:
pchisq(1.1, df=1, lower.tail=FALSE)# the answer is p=0.2942661
Now, to go backward by using p and df to calculate chi-square value, I used the p=0.2942661 I obtained from above and df=1 above:
qchisq(0.2942661, 1, lower.tail=FALSE) # the answer is 1.1 as in the first solution.
So using your example of Chi Squared = 15 with df = 2, the solutions are below:
Solution: calculate p-value
pchisq(15, df=2, lower.tail=FALSE)# answer: p= 0.0005530844
use the p= 0.0005530844 and df=2 to get back the chi-square value
qchisq(0.0005530844, 2, lower.tail=FALSE)# answer: chi-square = 15
Hope this helps!!!