# Confidence interval for observational study

I recorded hand hygiene type for 500 nurses following 500 episodes of care. I now have a probability for each type of hygiene method: Alcohol gel, Soap, Gloves, None.

But how do I calculate a confidence internal for these? Is that the best way to report the findings? Any help would be much appreciated.

• Please give a little more details: What are your objectives - compare them, simply describe them? How were the nurses and episodes selected? Randomly? Do you have access to any statistical software (including Excel) or are you doing everything by hand? Jan 29, 2015 at 18:15
• When posting a new question, you should reference your earlier related question: stats.stackexchange.com/questions/135536/… What did you not understand of my response there? Jan 29, 2015 at 18:56
• @kjetilbhalvorsen i really appreciate your reply to my other question. Here i would like to know how to calculate confidence intervals for the probabilities of different types of hygiene... I apologise for mixing up the two questions
– HCAI
Jan 29, 2015 at 19:00
• @robin.datadrivers Hmmm the observations were not random because i had a set amount of time to watch the nurses so i tried to observe evry episode of care... I have excel but also matlab and r. What do you have in mind?
– HCAI
Jan 29, 2015 at 19:02
• So you have a census of all episodes during a set time period. You will have to make some assumptions about the generalizability of that time period on that day to all time periods on all days. And those nurses to all nurses, if they are on different set schedules. Remember classical statistical tests assume simple random samples, and departure from that can call into question your conclusions. Jan 30, 2015 at 4:30

Let's assume that all nurses and episodes are basically the same. Let $X_i$ be the choice of hygiene type for a particular episode/nurse. To estimate the probability of $X_i$ we usually use a count (which is MLE):

$$p_j=E[I(X_i=j)]$$

Where $I$ is an indicator function. The variance of an indicator function like this is just:

$$\text{Var}(I(X_i=j))=E[I(X_i=j)^2] - E[I(X_i=j)]^2 = p_j(1-p_j)$$

The sample equivalent of the count above is:

$$\hat p_j=\dfrac{1}{n}\sum_{i=1}^nI(X_i=j)$$

The CLT tells us that:

$$\sqrt{n}(\hat p_j - p_j)\xrightarrow{d}\ N\left[0,\;\text{Var}(I(X_i=j))\right].$$

by the CLT, a consistent estimator of the variance of $\hat p_j$ is then:

$$\dfrac{1}{n}\hat p_j (1-\hat p_j)$$

so the confidence interval for $\hat p_j$ can be written as: $$\hat p_j \pm z_q \sqrt{\dfrac{1}{n}\hat p_j (1-\hat p_j)}$$

where $z_q$ is the $1-q/2$ quantile of the standard normal distribution (1.96 for $q=0.05$).

This asymptotic approximation works well when $\hat p_j n>5$ and when $\hat p_j\neq 0, 1$. Otherwise you will have to use one of the alternatives here. I believe Clopper-Pearson is particularly popular. Let $c(X) = \sum_{i=1}^nI(X_i=j)$. Then the Clopper-Pearson upper bound and lower bound of the confidence interval are:

\begin{align} \text{Upper bound} &= 1-B^{-1}\left(\frac{q}{2}, n - c(X), c(X)+1\right)\\ \text{Lower bound} &= 1-B^{-1}\left(1-\frac{q}{2}, n - c(X) +1,c(X)\right) \end{align}

where $B^{-1}$ is the inverse of the Beta distribution. This confidence interval follows directly from the binomial distribution, instead of working through asymptotic normality.

If you want to calculate probabilities for each nurse, you can apply the same formulas on a nurse-by-nurse basis, subject to the same caveats. For more complicated models, each should have it's own asymptotic variance attached.

• Thank you, that's superb! Can I ask what happens to confidence interval calculations that produce negative probabilities? How would you treat these?
– HCAI
Feb 26, 2015 at 20:02
• In this case I'd consider using the Clopper-Pearson confidence interval, since the inverse beta will map to [0,1]. Otherwise you're sort of stuck. But the inverse beta should be available in whatever package you're using, so it shouldn't be that much harder to calculate than the normal approximation.
– jayk
Feb 26, 2015 at 22:29