Skip to main content
3 of 8
edited body
BruceET
  • 57.6k
  • 2
  • 36
  • 94

Fictitious data. Suppose you have a sample x of size $n = 50$ from a population with an unknown mean and distribution. Then in R we have:

x
 [1]   7.1  26.9  41.1  22.8  18.2  19.5  37.7  39.1  17.5   3.3
[11]   6.1   2.3  12.5  11.7  29.1   9.5   6.5  26.1  33.0   9.5
[21]   6.5   0.5   8.0  24.1  79.4   4.3  39.8   0.3  36.8   2.2
[31]   2.1   3.0   9.9   5.0   9.4 181.3   0.7   4.3  14.8   0.4
[41]   3.1   7.3   4.7   1.6  26.5   6.9   2.7   3.6  10.1   0.4

summary(x)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  0.300   3.375   8.700  17.584  23.775 181.300 

stripchart(x, pch="|")

enter image description here

Questionable t CI. Obviously, the observations are strongly right-skewed. But we believe, somewhat too naively and strongly, in the legendary robustness of t methods against departure from normality. So we try a 95% t confidence interval, which is $(9.57, 25.59).$ In R, this is part of the t.test procedure.

t.test(x)$conf.int
[1]  9.574129 25.593871
attr(,"conf.level")
[1] 0.95

Nonparametric bootstrap CI. Not knowing the family of distributions from which this sample was randomly chosen, we might try a 95% nonparametric confidence interval for the population mean $\mu$ (which we assume exists). To get an idea how variable the sample mean $\bar X$ is as an estimate of $\mu,$ we re-sample many samples of size $50$ from x with replacement. For each re-sample, we find the the distance between the observed mean $\bar X = 17.584$ and the mean of the re-sample. The distribution of these many differences d.re can be used to find the 95% nonparametric bootstrap CI $(9.12, 23.82).$

set.seed(2021) 
# non-parametric bootstrap, re-sample from sample
d.re = replicate(3000, mean(sample(x, 50, rep=T))-a.obs)
UL = quantile(d.re,c(.975,.025))
a.obs - UL
   97.5%     2.5% 
 9.12105 23.81885 

Parametric bootstrap CI. Now suppose that we know that the population is exponentially distributed, so that $X_i \stackrel{iid}{\sim}\mathsf{EXP = \mathrm{rate}} = 1/20,$ with $\mu = 20.$ Then we can make a 95% parametric CI for $\mu$ by taking re-samples from a population with mean $1/\bar X = 1/17.584.$ [Instead of re-sampling from the sample x, we re-sample from an exponential distribution 'suggested by' the sample x.] For my fictitious data x the resulting 95% parametric bootstrap CI is $(12.44, 22.13).$ This interval is narrower than the nonparametric bootstrap CI because it is based on the additional information that the population is exponential. [I did more re-samples here because parametric bootstrap CIs with larger numbers of resamples may be noticably more accurate.]

set.seed(2021)
# parametric bootstrap, sample 50 from EXP(rate=1/a)
d.re = replicate(10000, mean(rexp(50,1/obs.a))-a.obs)
UL = quantile(d.re,c(.975,.025))
a.obs - UL
   97.5%     2.5% 
12.44381 22.13479 

Parametric CI, treating the mean as a scale parameter. For some right-skewed distributions, the mean $\mu$ is more accurately viewed as a scale parameter than a location parameter. If we take this point of view, it makes more sense to look at ratios of re-sampled means to observed means $\bar X^*/\bar X_{obs}$ rather than differences $\bar X^* - \bar X_{obs},$ for each re-sample. This style of parametric bootstrap gives the reault $(13.66, 23.77).$

set.seed(2021)
# parametric bootstrap of ratios, sample 50 from EXP(rate=1/a)
r.re = replicate(3000, mean(rexp(50,1/obs.a))/a.obs)
UL = quantile(r.re,c(.975,.025))
a.obs / UL
   97.5%     2.5% 
13.66134 23.76732 

If you know it: Exact CI. However, if the population is known to be exponential, then we know that $\frac{\bar X}{\mu} \sim\mathsf{Gamma}(\mathrm{shape}=1/n, \mathrm{rate}=1/n).$ We can 'pivot' this relationship to make an exact 95% CI for $\mu$ of the form $\left(\frac{\bar X}{U}, \frac{\bar X}{L}\right),$ where $L$ and $U$ cut probability $0.025$ from the lower and upper tails of $\mathsf{Gamma}(1/50, 1/50).$ This exact 95% CI for $\mu$ is $(13.57, 23.69).$

mean(x)/qgamma(c(.975,.025), 50, 50)
[1] 13.57196 23.69111

Of course, this is the best 95% CI of the four on this page because is strictly based on statistical theory. Sometimes one may not know (or remember) that an exact CI is available.

Note: The following R code was used to sample the fictitious data used in this illustration:

set.seed(1203)
x = round(rexp(50,1/20),1)
BruceET
  • 57.6k
  • 2
  • 36
  • 94