Introduction
I am working in R and I am getting confused how to compute confidence interval of normal distributions and tail probabilities of unobserved points. I have looked at other posts on here that does not help me answer these questions properly.
Question Summary:
I have two questions.
- How to compute the confidence interval of a normal distribution on R knowing the mean, the standard-deviation and the number of samples?
- How to compute the tail probability of a new point?
Toy Example:
Here is a toy example to illustrate my issue:
Imagine I have some variable X
that is taken from a normal distribution. I have 50 samples from which I have estimated the mean to be equal to 10 and standard deviation to 2.
n = 50
X.mean <- 10
X.SD <- 2
By reading the wikipedia page on confidence intervals (link) I found that I shoud construct it with this equation:
$$\textrm{CI} = \left[\mu + \frac{c_{\alpha}\ast SD}{\sqrt{n}}, \mu - \frac{c_{\alpha}\ast SD}{\sqrt{n}}\right]$$
With $\mu$ = mean, $SD$ = standard deviation and $c_{\alpha}$ = as the $\alpha$ percentile of the distribution.
So if I want to have the 95% confidence interval I would write:
# value of the 95% quantile
c_95 <- qt(p = 0.95, df = n-1)
# CI margin
error <- (c_95 * X.SD / sqrt(n))
# CI values:
ci_interval <- c(X.mean - error, X.mean + error)
which gives me ci_interval
= $[9.5258, 10.4742]$.
(Aleady, I feel that it is smaller than I expected)
Then, I have other issues with the computation of the tail probability with the pnorm()
function.
On wikipedia, I can read that "The confidence interval can be expressed in terms of statistical significance, e.g.: "The 95% confidence interval represents values that are not statistically significantly different from the point estimate at the .05 level"."
So if I compute the tail probabily at the upper confidence interval, I should get 0.025.
But if I do this:
pnorm(q = ci_interval[2], mean = X.mean, sd = X.SD, lower.tail = T)
I get $0.4062896$ and not the expected 0,0025.
What I am understanding / doing wrong?