# Why is the probability of my chi square statistic equal to 0

Binary logistic regression in R

I have derived the chi square statistic and degrees of freedom for my model (200.7839, 8, respectively) however, when I attempt to determine the probability associated with the chi square statistic, I get a value of 0 with no decimal places - just "0". I was expecting a probability <0.05 so I can reject the null hypotheses. Please see my code below. Does anyone have any suggestions as to why R would return a value of 0 with no decimal places? or is the value simply 0.00000 etc and therefore significant? Cheers!

modelChi<-Model1.0$null.deviance - Model1.0$deviance
modelChi
chidf<-Model1.0$df.null - Model1.0$df.residual
chidf
chisq.prob<- 1 - c(modelChi, chidf)
chisq.prob

• Your code above doesn't appear to do the required calculation. Did you try running the code you put here? Note that the correct calculation would involve a call to pchisq. However, you should not obtain the upper tail area by subtraction, since that can leads catastrophic cancellation. Try pchisq(200.7839,8,lower.tail=FALSE) (which doesn't quite give 0) – Glen_b Feb 5 '16 at 6:40

That Chi-squared statistic is gigantic. With 8 degrees of freedom, the a chi-squared statistic of 21.96 is associated with a p-value of 0.005. So a very large statistic like 200, with 8 degrees of freedom has a p-value so small that R returns zero, (i.e. close to zero). It is certainly less than .05, the level you are trying to test at, which is achieved with a chi-squared test statistic of only 2.73.

• Thank you very much for your feedback. I was unsure of how to use a chi square distribution table and you have just cleared that up. The initial null deviance was large and the pseudo R squared tests that I have performed have indicated that my model only explains around 20% of the variation (although I am aware of the limitations of these). I believe this is why the chi squared statistic is so big. My model does reduce the deviance by quite a lot as well and is obviously significant based on the p value. Thanks again for your help – Courtney Feb 5 '16 at 2:46

It is customary for software packages to have cut out values. For instance, in many MATLAB tests anything below 0.005 is returned as 0, but usually with some kind of a warning

• Apparently not R. For example 1-pchisq(90,8,lower.tail=TRUE) gives 4.440892e-16 though this has started to have precision issues and it would be better to use pchisq(90,8,lower.tail=FALSE) giving 4.650448e-16 – Henry Feb 5 '16 at 8:35