Bootstrap confidence intervals

Julia Fukuyama

Simulation-Based Inference · Lecture 19

Today

  • Review the parametric bootstrap and the definition of a sampling distribution.
  • Define confidence intervals.
    • Why didn’t I talk about them before?
  • Examples where sampling variability alone does not give a valid confidence interval
    • (From before): estimated distribution is incorrect.
    • Estimating the maximum of a uniform distribution.
    • A constant or strongly regularized estimator.
  • How to get a confidence interval from the bootstrap
    • Invert a pivot
    • Bootstrap \(t\) (inverting an approximate pivot)

Recall: Sampling distribution

  • An estimator is a procedure/function \(h\) applied to data \(X\): \(\hat\theta = h(X)\).
  • The sampling distribution of \(\hat\theta\) is the distribution of \[ \hat\theta = h(X) \qquad \text{when} \qquad X\sim P_{\theta_0}. \]
  • Thought experiment: if we could collect new datasets from the same process, with the same design and sample size, what estimates would we get?

Recall: Parametric bootstrap

We cannot simulate from \(P_{\theta_0}\) because we don’t know \(\theta_0\). The parametric bootstrap uses \(P_{\hat\theta}\) as a stand-in:

  1. Fit the observed data: \(\hat\theta = h(X_{\mathrm{obs}})\).
  2. For \(b=1,\ldots,B\), simulate a dataset with the same design and sample size from the fitted model: \(X^{*(b)}\sim P_{\hat\theta}\).
  3. Refit the same estimator: \(\hat\theta^{*(b)} = h\left(X^{*(b)}\right)\).
  4. Use \(\hat\theta^{*(1)},\ldots,\hat\theta^{*(B)}\) to approximate the sampling distribution of \(\hat\theta\).

The percentile interval runs from the 2.5th to the 97.5th percentile of the bootstrap estimates.

New definition: Confidence intervals

A confidence interval procedure turns a dataset into an interval \([L(X), U(X)]\).

It is a 95% confidence interval procedure if, for every possible value of \(\theta_0\), \[ P\big(L(X)\le\theta_0\le U(X)\big) = 0.95 \qquad \text{when} \qquad X\sim P_{\theta_0}. \]

  • The interval is random, because it is computed from random data. \(\theta_0\) is fixed.
  • The probability is a statement about the procedure across repeated datasets: 95% of the intervals it produces contain \(\theta_0\).
  • The proportion of intervals containing \(\theta_0\) is called the coverage.
  • For one observed dataset, the interval either contains \(\theta_0\) or it doesn’t.

Note!

  • Quantiles of the sampling distribution are not the same as a confidence interval for the parameter.
  • Sometimes you can use them that way, but the definitions are not the same and you have to check.

General strategy

We want to work backward from an observed estimate to possible values of the target. Our strategy is roughly:

  1. Use simulation to learn how the estimator relates to its target.
  2. Use that relationship to construct an interval for the target.
  3. Check how often the resulting intervals contain the target across repeated datasets.

Taking percentiles of the simulated estimates sometimes works, but only in particular situations.

Two classes of problems

  • Our estimated sampling distribution does not match the true sampling distribution.

    • We may have too little data to estimate it accurately.
    • Our assumed model class may not describe the data-generating process.
  • Our interval construction does not correctly account for the relationship between the estimator and the target.

Example 1: Normal distribution with incorrect variance

Our model: \(X_i \sim \operatorname{Normal}(\mu, 2^2)\), \(i = 1,\ldots,n\).

True data-generating process: \(X_i \sim \operatorname{Normal}(\mu, 5^2)\), \(i = 1,\ldots,n\).

Note that our model is incorrect about the variance.

We want to estimate \(\mu\).

To keep it simple, we will use a simple estimator: \[ \hat\mu = \frac{1}{n}\sum_{i=1}^n X_i. \]

Step 1: Use data to get \(\hat\mu\)

\(X_1, \ldots, X_5 = (10.9,\ 17.6,\ 7.3,\ 13.8,\ 13.6)\)

\(\hat\mu = (10.9 + 17.6 + 7.3 + 13.8 + 13.6)/5 = 12.64\)

(Here the true \(\mu = 10\).)

Step 2: Simulate new data and re-estimate

Simulate from our model with \(\hat\mu\) plugged in: \(\operatorname{Normal}(12.64, 2^2)\). Gray: original data. Black: bootstrap replicate.

\(X^{*1}_1, \ldots, X^{*1}_5 = (13.5,\ 11.4,\ 9.2,\ 15.7,\ 14.4)\)

\(\hat\mu^{*1} = 12.84\)

\(X^{*2}_1, \ldots, X^{*2}_5 = (9.8,\ 9.9,\ 12.0,\ 9.8,\ 15.4)\)

\(\hat\mu^{*2} = 11.38\)

Notice that the bootstrap data are less spread out than the original data.

Bootstrap distribution

Quantiles of the bootstrap distribution

  • They describe the sampling distribution if the true model were \(\operatorname{Normal}(\hat\mu, 2^2)\).
  • They don’t cover the true \(\mu\) often enough.
    • The bootstrap distribution has standard deviation \(2/\sqrt{5} \approx 0.89\); the true sampling distribution has standard deviation \(5/\sqrt{5} \approx 2.24\).
    • Here the 95% percentile interval is \([11.0,\ 14.4]\), which misses \(\mu = 10\).
    • Across datasets, the 95% percentile interval contains \(\mu\) only about 57% of the time.

Example 2: A uniform distribution

Model: \[ X_i \sim \operatorname{Uniform}[0, \theta], \qquad i = 1,\ldots,n. \]

We want to estimate \(\theta\).

We have seen complicated ways to do this, but again, to keep it simple, we will just use \[ \hat\theta = \max(X_1,\ldots,X_n). \]

Step 1: Use data to get \(\hat\theta\)

\(X_1, X_2, \ldots, X_5 = (1.6,\ 5.2,\ 1.7,\ 8.3,\ 0.7)\)

\(\hat\theta = \max(1.6,\ 5.2,\ 1.7,\ 8.3,\ 0.7) = 8.3\)

(Here the true \(\theta = 10\).)

Step 2: Simulate new data and re-estimate

Simulate from \(\operatorname{Uniform}[0, \hat\theta] = \operatorname{Uniform}[0, 8.3]\). Gray: original data. Black: bootstrap replicate.

\(X^{*1}_1, \ldots, X^{*1}_5 = (5.9,\ 3.1,\ 7.7,\ 5.8,\ 0.5)\)

\(\hat\theta^{*1} = \max(5.9,\ 3.1,\ 7.7,\ 5.8,\ 0.5) = 7.7\)

\(X^{*2}_1, \ldots, X^{*2}_5 = (5.8,\ 1.8,\ 7.8,\ 5.0,\ 6.4)\)

\(\hat\theta^{*2} = \max(5.8,\ 1.8,\ 7.8,\ 5.0,\ 6.4) = 7.8\)

Bootstrap distribution

Quantiles of the bootstrap distribution

  • They describe the sampling distribution if the true model were \(\operatorname{Uniform}[0, \hat\theta]\).
  • They never cover the true \(\theta\): every \(\hat\theta^{*} \le \hat\theta \le \theta\), and so the bootstrap percentile intervals always have a coverage of 0%.

What if we could simulate from the true \(\theta\)?

Could we use simulation to learn how our estimate relates to the target, and then work backward?

Let \(\theta_0\) denote the true value of \(\theta\). Simulate many datasets of size \(n=5\) from \(\operatorname{Uniform}[0,\theta_0]\) and compute their maxima.

This is just to show what we are aiming for; in practice we cannot do this.

One option: learn the distribution of the difference

For each simulated dataset \(X^{(m)}\sim P_{\theta_0}\), record \[ D^{(m)}=\hat\theta(X^{(m)})-\theta_0. \]

Let \(a_{\theta_0}\) and \(b_{\theta_0}\) be the 2.5th and 97.5th percentiles of the difference distribution.

Then \[ P_{\theta_0}\left( a_{\theta_0}\le\hat\theta(X)-\theta_0\le b_{\theta_0} \right)=0.95. \]

Simulation lets us estimate these quantiles.

Use the difference to work backward

For observed data \(x\), keep candidate values \(t\) satisfying \[ a_{\theta_0}\le\hat\theta(x)-t\le b_{\theta_0}. \]

Solving for \(t\) gives \[ c_{\theta_0}^{\mathrm{diff}}(x) = \left[\hat\theta(x)-b_{\theta_0},\; \hat\theta(x)-a_{\theta_0}\right]. \]

For our data, \(\hat\theta(x) = 8.3\), \(a_{\theta_0} = -5.22\), and \(b_{\theta_0} = -0.05\): \[ c_{\theta_0}^{\mathrm{diff}}(x) = \left[8.3 + 0.05,\; 8.3 + 5.22\right] = \left[8.35,\; 13.52\right]. \]

The true \(\theta_0\) belongs to this interval exactly when the estimation error lies between \(a_{\theta_0}\) and \(b_{\theta_0}\).

Therefore, with these oracle bounds, coverage at \(\theta_0\) is 95%.

Another option: learn the distribution of the ratio

Use the same simulated datasets, but record \[ Q^{(m)}=\frac{\hat\theta(X^{(m)})}{\theta_0}. \]

Let \(a_{\theta_0}^{\mathrm{ratio}}\) and \(b_{\theta_0}^{\mathrm{ratio}}\) be the 2.5th and 97.5th percentiles of the ratio distribution.

Then \[ P_{\theta_0}\left( a_{\theta_0}^{\mathrm{ratio}}\le\frac{\hat\theta(X)}{\theta_0}\le b_{\theta_0}^{\mathrm{ratio}} \right)=0.95. \]

Use the ratio to work backward

For observed data \(x\), keep candidate values \(t\) satisfying \[ a_{\theta_0}^{\mathrm{ratio}}\le\frac{\hat\theta(x)}{t}\le b_{\theta_0}^{\mathrm{ratio}}. \]

Solving for \(t\) gives \[ c_{\theta_0}^{\mathrm{ratio}}(x) = \left[\frac{\hat\theta(x)}{b_{\theta_0}^{\mathrm{ratio}}},\; \frac{\hat\theta(x)}{a_{\theta_0}^{\mathrm{ratio}}}\right]. \]

For our data, \(\hat\theta(x) = 8.3\), \(a_{\theta_0}^{\mathrm{ratio}} = 0.478\), and \(b_{\theta_0}^{\mathrm{ratio}} = 0.995\): \[ c_{\theta_0}^{\mathrm{ratio}}(x) = \left[\frac{8.3}{0.995},\; \frac{8.3}{0.478}\right] = \left[8.34,\; 17.36\right]. \]

Again, the true \(\theta_0\) belongs to the interval exactly when the ratio lies between its two quantiles.

With these oracle bounds, coverage at \(\theta_0\) is also 95%.

Both relationships work in the oracle experiment

For the observed maximum \(\hat\theta(x)=8.3\):

  • Oracle difference interval: approximately \([8.35,\;13.52]\).
  • Oracle ratio interval: approximately \([8.34,\;17.36]\).

Both procedures have 95% coverage at \(\theta_0=10\), even though they give different intervals.

We learned each relationship’s distribution at the actual data-generating parameter, then inverted its bounds.

The problem is that we do not know that parameter.

We have the same problem as usual, we don’t know \(\theta_0\)

Let \(r\) describe how an estimate relates to its target, for example through their difference or ratio.

We want the distribution of \[ R=r(\hat\theta(X),\theta), \qquad X\sim P_\theta. \]

Instead, the parametric bootstrap simulates \[ X^*\sim P_{\hat\theta(x)} \] and records \[ R^*=r(\hat\theta(X^*),\hat\theta(x)). \]

We can replace the relationship distribution at the true parameter with the one at the fitted parameter.

How much does this substitution change the distribution?

Does the difference distribution change?

For the uniform maximum, consider \[ r(\hat\theta(X),\theta)=\hat\theta(X)-\theta. \]

Simulate datasets of the same size at \(\theta=5,10,20\). For each dataset, record its maximum minus its generating upper bound.

The difference distribution changes with \(\theta\).

Therefore, simulating at \(\hat\theta(x)\) instead of \(\theta\) changes the distribution we use to choose our bounds.

Does the ratio distribution change?

Now record the maximum divided by its generating upper bound: \[ r(\hat\theta(X),\theta)=\frac{\hat\theta(X)}{\theta}. \]

The simulated ratio distributions overlap.

Aside: Why the ratio distribution is fixed

Write \(U_i=X_i/\theta\).

The \(U_i\) are independent \(\operatorname{Uniform}[0,1]\) random variables, and \[ \frac{\hat\theta(X)}{\theta} = \max(U_1,\ldots,U_n). \]

Its distribution is the same for every \(\theta>0\).

Consequently, using \(\hat\theta(x)\) in place of \(\theta\) does not change the ratio distribution.

A quantity whose distribution does not depend on unknown parameters is called a pivotal quantity.

Constructing confidence sets by inverting a pivot

Let \(X \sim P_\theta\) denote the random data and let \(\hat\theta(X)\) be our estimator.

Suppose \(r\) is a function of two variables that describes how the estimate relates to the target (e.g. difference, ratio).

Suppose further that the random quantity \[ R=r(\hat\theta(X),\theta) \] is pivotal, that is, it has the same distribution for every \(\theta\).

The results described below go through approximately for approximately pivotal quantities.

Procedure

  1. Fit the observed data to obtain \(\hat\theta(x)\).
  2. Simulate \(X^*\sim P_{\hat\theta(x)}\), compute \[ R^*=r(\hat\theta(X^*),\hat\theta(x)). \], repeat many times, then find \(a,b\) the 2.5th and 97.5th percentiles of these values.
  3. Compute \[ c(x)=\{t:a\le r(\hat\theta(x),t)\le b\}. \]

Why does this work?

The true parameter \(\theta\) is in the confidence set exactly when \(a \le r(\hat \theta(X), \theta)\le b\).

We chose \(a\) and \(b\) to contain 95% of the distribution of \[ r(\hat\theta(X^*),\hat\theta(x)), \qquad X^*\sim P_{\hat\theta(x)}. \]

That is, we pretended the true parameter was \(\hat\theta(x)\).

If we assume that the distribution of this relationship does not depend on the parameter, that is, we assume that \[ \underbrace{r(\hat\theta(X),\theta)}_{X\sim P_\theta} \ \overset{d}{=}\ \underbrace{r(\hat\theta(X^*),\hat\theta(x))}_{X^*\sim P_{\hat\theta(x)}}. \]

Then \[ P_\theta\big(\theta\in c(X)\big) = P_{X\sim P_\theta} \left(a \le r(\hat \theta(X), \theta)\le b\right) = P_{X^*\sim P_{\hat\theta(x)}} \left(a \le r(\hat \theta(X^*), \hat \theta(x))\le b\right) =0.95. \]

What if we cannot find an exact pivot?

We still want to estimate the relationship distribution at the true parameter using the one at the fitted parameter.

An exact pivot makes those distributions identical.

Otherwise, we look for a relationship whose distribution changes little over the parameter values relevant to our problem.

This motivates trying to remove changes in scale by standardizing the estimation error.

A general strategy: bootstrap t

Use the relationship function \[ r(X,t)=\frac{\hat\theta(X)-t}{\widehat{\mathrm{se}}(X)}, \] where \(\widehat{\mathrm{se}}(X)\) estimates the sampling standard deviation of our estimator.

Bootstrap \(t\) procedure

  1. Simulate bootstrap datasets \(X^{*(b)}\sim P_{\hat\theta(x)}\) and record \[ T^{*(b)}=r(X^{*(b)},\hat\theta(x)) =\frac{\hat\theta(X^{*(b)})-\hat\theta(x)} {\widehat{\mathrm{se}}(X^{*(b)})}, \] take \(a,b\) to be the estimated 2.5th and 97.5th percentiles of this distribution.
  2. Keep candidate values \(t\) satisfying \[ a\le r(x,t)\le b, \] or equivalently, \[ a\le \frac{\hat\theta(x)-t}{\widehat{\mathrm{se}}(x)} \le b. \]

Assuming \(\widehat{\mathrm{se}}(x)>0\), solving gives \[ \left[ \hat\theta(x)-b\widehat{\mathrm{se}}(x),\; \hat\theta(x)-a\widehat{\mathrm{se}}(x) \right]. \]

Summing up

  • If you want a confidence interval for a target parameter, you need to know something about the relationship between the estimate and the target.
  • This is quite delicate.
  • If you have a pivot, you should use it.
  • Bootstrap \(t\) is often going to be reasonable, but its suitability is something that you can and should check if you are going to use it.