# How to calculate confidence interval when data is nominal?

My data set only consists of the values -1, 0, and 1. Suppose my data set looks something like this: {0, 0, 0, 1, 0, 1, 0, -1, -1, 1}. So sample size n = 10, mean = 1/10, and sd = 0.738. Now if I wanted to calculate 95% CI from the normal distribution I would've calculated (in R)

> error <- qnorm(0.975,df=n-1)*s/sqrt(n)
> left <- mean-error
> right <- mean+error


Where left and right are the lower and upper bounds, respectively. However, since my data is not normally distributed...how do I go about calculating a 95% CI?

• Do you want the confidence interval for the mean? Or some other parameter?
– user75138
Apr 5, 2016 at 6:35
• 1. Are you sure this is nominal (rather than say ordinal)? 2. What population quantity are you finding a CI for with your nominal sample? Note that if it's nominal there isn't a mean. Apr 5, 2016 at 6:35
• Using the normal distribution seems to be not appropriate for your data since it is nominal (ordinal?) only. You might want to look at the median or mode. Please note that calculating an arithmetic mean makes no sense for qualitative variables (nominal or ordinal like e.g. school grades). Apr 5, 2016 at 6:56

The sample size is so small that creating a 95% (or 99%, for what matters) confidence interval is practically almost irrelevant, so you could easily disregard what follows, if you want really to inform people (who would apply your findings if stemming only from 10 cases?).

However, the simplest and possibly most robust approach I would recommend would be to use percentile bootstrap, maybe with 10,000 bootstrap samples, using for inference the median, 2.5th percentile, and 97.5th percentile.

In my experience and in keeping with established sources, bootstrap is almost always the best choice when simple and reliable parametric approaches are lacking. I really recommend for instance the seminal book by Efron and Tibshirani, despite being somewhat old.

A possible way in R to get inferential estimates for both mean and median could be the following:

data <- c(0, 0, 0, 1, 0, 1, 0, -1, -1, 1)
resamples <- lapply(1:10000, function(i)
sample(data, replace = T))

r.mean <- sapply(resamples, mean)
quantile(r.mean, c(.005, .025, .5, .975, .995)) # results for the mean

r.median <- sapply(resamples, median)
quantile(r.median, c(.005, .025, .5, .975, .995)) # results for the median

• Efron and Tibshirani may be old but still I consider it one of two greatest books on this topic available. Second one is by Davison and Hinkley: stats.stackexchange.com/questions/128839/…
– Tim
Apr 5, 2016 at 7:54
• (+1) E. and T. are really fantastic... and I find that old books are often written in better prose as well! Apr 5, 2016 at 8:16
• The word "clinically" here reflects an unconscious assumption that the OP is in your field. We can all translate to "practically". Apr 5, 2016 at 8:18
• Sorry... being a clinician I always think in medical terms. I have edited the entry. Apr 5, 2016 at 11:02
• Small comment: While the bootstrap relies on less assumptions than parametric procedures, the justification of the bootstrap are asymptotic. There is no theoretical justification to support bootstrapping in small samples. See here for example. This does not mean that this is bad advice, it is simply very difficult to learn much from such small samples. Apr 5, 2016 at 12:48