How do I calculate confidence intervals for a non-normal distribution? I have 383 samples that have a heavy bias for some common values, how would I calculate the 95% CI for the mean?  The CI that I calculated seems way off, which I assume is because my data does not look like a curve when I make a histogram.  So I think I have to use something like bootstrapping, which I don't understand very well.
 A: You can just use a standard confidence interval for the mean: Bear in mind that when we calculate confidence intervals for the mean, we can appeal to the central limit theorem and use the standard interval (using the critical points of the T-distribution), even if the underlying data is non-normal.  In fact, so long as the data is IID (Independent and Identically Distributed) and the distribution of the data has finite variance, the distribution of the sample mean with $n=383$ observations should be virtually indistinguishable from a normal distribution.  This will be the case even if the underlying distribution of the data is extremely different to a normal distribution.
A: For log-normal data, Olsson (2005) suggests a 'modified Cox method'
If $X$ is log-normally distributed and $\rm{E}(X) = \theta$, the a confidence interval for $ \log(\theta)$ is:
$$
\bar{Y} = \frac{S^2}{2} \pm t_{df}\sqrt{\frac{S^2}{n} + \frac{S^4}{2(n-1)} }
$$
Where $ Y = \log(X)$, the sample mean of $Y$ is $\bar{Y}$ and the sample variance of $Y$ is $S^2$.  For df, use n-1.
An R function is below:
ModifiedCox <- function(x){
  n <- length(x)
  y <- log(x)
  y.m <- mean(y)
  y.var <- var(y)

  my.t <- qt(0.975, df = n-1)

  my.mean <- mean(x)
  upper <- y.m + y.var/2 + my.t*sqrt(y.var/n + y.var^2/(2*(n - 1)))
  lower <- y.m + y.var/2 - my.t*sqrt(y.var/n + y.var^2/(2*(n - 1)))

 return(list(upper = exp(upper), mean = my.mean, lower = exp(lower)))

}

Repeating the example from Olsson's paper
CO.level <- c(12.5, 20, 4, 20, 25, 170, 15, 20, 15)

ModifiedCox(CO.level)
$upper
[1] 78.72254

$mean
[1] 33.5

$lower
[1] 12.30929

A: Yes, bootstrap is an alternative for obtaining confidence intervals for the mean (and you have to make a bit of effort if you want to understand the method).
The idea is as follows:


*

*Resample with replacement B times.

*For each of these samples calculate the sample mean.

*Calculate an appropriate bootstrap confidence interval.


Concerning the last step, there are several types of bootstrap confidence interval (BCI). The following references present a discussion on the properties of different types of BCI:
http://staff.ustc.edu.cn/~zwp/teach/Stat-Comp/Efron_Bootstrap_CIs.pdf
http://www.tau.ac.il/~saharon/Boot/10.1.1.133.8405.pdf
It is a good practice to calculate several BCI and try to understand possible discrepancies between them.
In R, you can easily implement this idea using the R package 'boot' as follows:
rm(list=ls())
# Simulated data
set.seed(123)
data0 = rgamma(383,5,3)
mean(data0) # Sample mean

hist(data0) # Histogram of the data

library(boot) 

# function to obtain the mean
Bmean <- function(data, indices) {
  d <- data[indices] # allows boot to select sample 
    return(mean(d))
} 

# bootstrapping with 1000 replications 
results <- boot(data=data0, statistic=Bmean, R=1000)

# view results
results 
plot(results)

# get 95% confidence interval 
boot.ci(results, type=c("norm", "basic", "perc", "bca"))

A: Another standard alternative is to calculate the CI with the Wilcoxon test. In R
wilcox.test(your-data, conf.int = TRUE, conf.level = 0.95)

Unfortunately, it gives you the CI around the (pseudo)median not the mean, but then if the data is heavily non-normal maybe the median is a more informative measure.
