4
$\begingroup$

I am attempting to use the chi-square test as a goodness-of-fitness test in R, but I keep getting a p-value = 1. I expect a high p-value, but less than one. Can anyone point out what error I might be making that would result in such a high p-value?

My null-hypothesis is that my observational distribution follows a binomial distribution listed below.

My expected distribution has a binominal distribution with: z = dbinom(seq(0,256), 256, 1/2).

I have a vector of size 257 representing the frequency distribution of my data (in 257 bins). This distribution has been normalized by the sum of the frequencies.

I am performing the chi-squared test as follows:

> chisq.test(x=hw_hist_v_norm, y=NULL, p=z)

Chi-squared test for given probabilities

data:  hw_hist_v_norm
X-squared = 0, df = 256, p-value = 1

Warning message:
In chisq.test(x = hw_hist_v_norm, y = NULL, p = z) :
  Chi-squared approximation may be incorrect

I also tried the original distribution non-normalized as follows:

> chisq.test(x=hw_hists$hw_hist_v, y=NULL, p=z)

Chi-squared test for given probabilities

data:  hw_hists$hw_hist_v
X-squared = 144.9933, df = 256, p-value = 1

Warning message:
In chisq.test(x = hw_hists$hw_hist_v, y = NULL, p = z) :
  Chi-squared approximation may be incorrect
$\endgroup$
1
$\begingroup$

Without seeing your hw_hists data, or knowing anything about how they were generated, it is hard to say. However, it appears your data match the binomial distribution incredibly well. One could say that your data match the binomial distribution implausibly well, in fact.

$\endgroup$
  • $\begingroup$ The frequency data in hw_hists is the result of accumlative data for trillions of samples. Is it possible that the p-value has become asymptotic to 1 because too many samples are being used? $\endgroup$ – bender Jan 19 '15 at 20:13
  • 1
    $\begingroup$ Actually, it works the other way around, @bender. With more & more data, even the most trivial deviations from the binomial would cause the p-value to be 0. $\endgroup$ – gung - Reinstate Monica Jan 19 '15 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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