title: Why does the CI() function in R return different results than qnorm for a 95% confidence interval?
body: <p>When calculating the 95% CI for the sample mean in R, I get different results when using the CI function <code>CI(mydata)</code> and when I use <code>qnorm(.975, mean = mean(mydata), sd = sd(mydata))</code> for the upper bound and <code>qnorm(.025, mean = mean(mydata), sd = sd(mydata))</code> for the lower bound.</p>
  <p>Why would there be a difference? The qnorm function provides results that make sense when looking at the plot of the probability distribution for my data.</p>
  <p>Here is the code that I am using to generate 500 normal random variables, calculate the mean(xbar), standard deviation(s) and 95% CI:</p>
  <pre><code>mydata &lt;- rnorm(500)
  xbar &lt;- mean(mydata)
  xbar
  </code></pre>
  <p>[1] -0.0376074</p>
  <pre class="lang-s prettyprint-override"><code>s
  </code></pre>
  <p>[1] 1.004922</p>
  <p><code>CI(mydata)</code></p>
  <pre><code> upper        mean       lower 
  </code></pre>
  <p>0.05069041 -0.03760740 -0.12590521</p>
  <p>Then using qnorm I get the following:</p>
  <p><code>qnorm(.975, mean=xbar, sd=s)</code></p>
  <p>[1] 1.932003</p>
  <p><code>qnorm(.025, mean=xbar, sd=s)</code></p>
  <p>[1] -2.007218</p>