# 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)