This function computes the confidence interval of a point estimate.
Usage
ci(estimate, se, confidence = 0.95, distribution = c("normal", "t"), n)
Arguments
- estimate
sample statistic from population having distribution
distribution
- se
standard error (standard deviation of
estimate
)- confidence
the desired confidence level
- distribution
sampling distribution of the estimate. Use
normal
if the population has unknown mean and known variance (or ifn
is large),t
if population has unknown mean and variance- n
sample size, used to compute the degrees of freedom if
distribution = "t"
Value
A named numeric vector with 2 elements, low
and up
,
the lower and upper bounds of the confidence interval
for the point estimate.
Details
The confidence interval provides additional information about the variability of a point estimate and it is generally defined as
$$CI = estimate \pm \textit{margin of error} = estimate \pm \textit{critical value} \times \textit{standard error}$$
where \(\textit{estimate}\) is the sample statistic estimating the population parameter of interest; \(\textit{critical value}\) is a value based on the sampling distribution of the estimate and the desired confidence level; \(\textit{standard error}\) is the standard deviation of the point estimate.
Since estimates from different samples from the same population can be different, the estimate can be seen as a random variable with its own distribution. Given that we are not interested in the estimate for a specific sample but we rather want to draw conclusions about the population, the confidence interval can be used to obtain information about the population parameter.
Beware about the interpretation. The CI is not telling us if the population parameter is inside its range. In fact, as generally we don't know the population parameter, we don't know if the interval contains it. However, we know that a certain number of intervals (our confidence level, e.g. 95\ formed in this way will contain the parameter.