R How to generate a vector of probabilities normally distributed to be used at chisq.test
<p>I have a vector of 30 samples I want to test the hypothesis of the sample being from a population which is normally distributed.</p>

<pre><code>&gt; 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
</code></pre>

<p>I made a frequency vector using <code>hist</code></p>

<pre><code>&gt; N.hist &lt;- hist(N.concentration, breaks=10)
&gt; N.freq &lt;- N.hist$count
  [1] 3 5 4 4 5 4 2 2 1
</code></pre>

<p>I'm using <code>chisq.test</code> to check the fitness of <code>N.freq</code> to a normal distribution, however, the function requires an argument <em>p = a vector of probabilities of the same length of x</em>, 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</p>

<pre><code>&gt; d &lt;- length(N.freq$count)%/%2
&gt; p &lt;- dnorm(c(-d:d))
&gt; p
  [1] 0.0001338302 0.0044318484 0.0539909665 0.2419707245 0.3989422804
  [6] 0.2419707245 0.0539909665 0.0044318484 0.0001338302
&gt; chisq.test(N.freq, p = p)
   Error in chisq.test(p1$count, p = p) : 
   probabilities must sum to 1.
</code></pre>

<p>I thought about using <code>rescale.p=TRUE</code> but I'm not sure if this will produce a valid test.</p>

<hr>

<p>EDIT: If I use rescale.p, I got a warning message</p>

<pre><code>&gt; 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 &lt; 2.2e-16

Warning message:
In chisq.test(N.freq, p = p, rescale.p = TRUE) :
Chi-squared approximation may be incorrect
</code></pre>