I have a vector of 30 samples I want to test the hypothesis of the sample being from a population which is normally distributed.
> N.concentration
[1] 0.164 0.045 0.069 0.100 0.050 0.080 0.043 0.036 0.057 0.154 0.133 0.193
[13] 0.129 0.121 0.081 0.178 0.041 0.040 0.116 0.078 0.104 0.095 0.116 0.038
[25] 0.141 0.100 0.104 0.078 0.121 0.104
I made a frequency vector using hist
> N.hist <- hist(N.concentration, breaks=10)
> N.freq <- N.hist$count
[1] 3 5 4 4 5 4 2 2 1
I'm using chisq.test
to check the fitness of N.freq
to a normal distribution, however, the function requires an argument p = a vector of probabilities of the same length of x, as defined in chisq.test documentation. I'm trying to generate a vector to it but, honestly, I don't know exactly what to generate. I'm trying
> d <- length(N.freq$count)%/%2
> p <- dnorm(c(-d:d))
> p
[1] 0.0001338302 0.0044318484 0.0539909665 0.2419707245 0.3989422804
[6] 0.2419707245 0.0539909665 0.0044318484 0.0001338302
> chisq.test(N.freq, p = p)
Error in chisq.test(p1$count, p = p) :
probabilities must sum to 1.
I thought about using rescale.p=TRUE
but I'm not sure if this will produce a valid test.
EDIT: If I use rescale.p, I got a warning message
> chisq.test(N.freq, p=p, rescale.p=TRUE)
Chi-squared test for given probabilities
data: N.freq
X-squared = 2697.7, df = 8, p-value < 2.2e-16
Warning message:
In chisq.test(N.freq, p = p, rescale.p = TRUE) :
Chi-squared approximation may be incorrect