4. Confidence Intervals

Math 115 - Examples for Topic 4

Author

Yurk

These worked examples demonstrate the process of constructing and interpreting bootstrap confidence intervals for a single proportion. Each example walks through all steps from collecting data to interpreting the interval in context.


Example 1: Reading Confidence Intervals from a Bootstrap Distribution

Scenario: A conservation biologist wants to estimate the proportion of transplanted tree seedlings that survive after one year. She plants 40 native oak seedlings in a restoration area and monitors them. After one year, she finds that 32 of the seedlings survived.

Question: Construct a 95% confidence interval for the true proportion of transplanted seedlings that survive one year in this restoration area.

Given: Below is a bootstrap distribution showing 1000 bootstrap proportions based on resampling from the original sample with replacement.

Task: Use the bootstrap distribution above to construct a 95% confidence interval.

Step 1: Identify the parameter

Let \(p\) = the true proportion of transplanted seedlings that survive one year in this restoration area.

Step 2: Calculate the sample statistic

From the monitored seedlings:

\[\hat{p} = \frac{32}{40} = 0.8\]

This is our point estimate for the survival rate.

Step 3: Understand the bootstrap distribution

The histogram shows 1000 bootstrap proportions. Each bootstrap sample:

  1. Randomly selects 40 seedlings from the original sample with replacement
  2. Calculates the proportion of survivors in that bootstrap sample
  3. The red dashed line shows our observed proportion (0.8)
  4. The distribution is centered near 0.8 (not at a null hypothesis value)

Key difference from hypothesis testing: We’re resampling from our actual data, not simulating from a theoretical population.

Step 4: Find the percentiles for the 95% CI

For a 95% confidence interval, we need the middle 95% of the bootstrap distribution:

  • Lower bound: 2.5th percentile (cuts off bottom 2.5%)
  • Upper bound: 97.5th percentile (cuts off top 2.5%)

Your task: Looking at the histogram, estimate where the 2.5th and 97.5th percentiles fall. Remember:

  • 2.5% of the bootstrap proportions should be below the lower bound
  • 2.5% of the bootstrap proportions should be above the upper bound
  • The middle 95% should fall between these two values

Helpful calculation: With 1000 bootstrap samples:

  • 2.5% of 1000 = 25 samples
  • So the lower bound (2.5th percentile) is where you’ve counted 25 observations from the left edge. Add up the bar counts from left to right until you reach 25. Keep in mind that you may reach 25 within a bar
  • And the upper bound (97.5th percentile) is where you’ve counted 25 observations from the right edge (or 975 from the left)

Look at the histogram and estimate which \(\hat{p}\) values correspond to these cutoff points.

Reading from the distribution:

  • 2.5th percentile ≈ 0.675
  • 97.5th percentile ≈ 0.925

95% Confidence Interval: (0.675, 0.925)

Check: here is the same distribution with the actual percentile bounds drawn — the count-based estimate should land within about one bar of these lines:

Step 5: Interpret the confidence interval

Interpretation: We are 95% confident that the true proportion of transplanted seedlings that survive one year in this restoration area is between 0.675 and 0.925.

What this means:

  • Values inside the interval (0.675 to 0.925) are plausible for \(p\)
  • Values outside this range are implausible for \(p\)
  • If we repeated this process many times (collecting new samples and constructing CIs), about 95% of those intervals would contain the true proportion \(p\)

Step 6: Address the “95% confident” interpretation

ImportantCommon Misinterpretation

❌ WRONG: “There is a 95% probability that \(p\) is in this interval”

✅ CORRECT: “We are 95% confident that this interval contains \(p\)”

Why the distinction?

  • The parameter \(p\) is fixed (but unknown) - it either is or isn’t in our interval
  • The 95% refers to our confidence in the method, not probability about this specific interval
  • If we repeated this entire process, including selecting a new sample, many times, about 95% of the resulting intervals would contain \(p\)

Example 2: Using Jamovi Output

Scenario: A political campaign wants to estimate the proportion of likely voters who support their candidate. They survey a random sample of 200 likely voters and find that 116 support their candidate.

Question: Construct a 95% confidence interval for the true proportion of likely voters who support the candidate.

Task: Use Jamovi’s Randomize Module to construct a bootstrap confidence interval.


Jamovi Setup

To construct a bootstrap confidence interval in Jamovi using the Randomize module:

Step 1: Prepare the data

Enter the data with a binary variable called support with values yes (supports candidate) and no (does not support). You should have 200 observations: 116 with yes and 84 with no.

Step 2: Access the Randomize Module

  1. Click on the Randomize icon in the Analyses tab
  2. Select Single Proportion - Confidence Interval from the list

Step 3: Configure the analysis

In the interface, set the following options:

  • Variable: Drag support into the Variable box
  • Confidence level: Enter 95 (for a 95% confidence interval)
  • Type: Select bootstrap percentile
  • Number of bootstraps: Start with 100 to visualize the distribution
  • Plot type: Select Dot plot (for 100 samples)
  • Seed the random number generator: (Optional) Check this box and use seed 8675309 for reproducible results

Step 4: Understanding the bootstrap process

The bootstrap method for confidence intervals:

  1. Resamples 200 voters from the original sample with replacement
  2. Calculates \(\hat{p}\) for each bootstrap sample
  3. Repeats many times to build a bootstrap distribution
  4. Finds the 2.5th and 97.5th percentiles of this distribution

Key: We’re resampling from our actual data, NOT from a theoretical population.

Step 5: Interpret the visualization

The dot plot shows:

  • Each dot represents the sample proportion from one bootstrap sample
  • The vertical red dashed lines mark the 2.5th and 97.5th percentiles
  • These percentiles form the confidence interval
  • The distribution is centered near the observed proportion (0.58)

Step 6: Increase precision

After examining the dot plot with 100 bootstraps:

  • Change Number of bootstraps to 1000 for more precise percentile estimates
  • Change Plot type to Histogram (easier to visualize with many samples)

Step 7: Example output with 1000 bootstraps

After running with 1000 bootstraps and a histogram plot, Jamovi produces something similar to the following bootstrap distribution:

Interpretation of the histogram:

  • Each bar represents a range of bootstrap sample proportions
  • The green-shaded region shows the middle 95% (the confidence interval)
  • The green vertical lines mark the 2.5th and 97.5th percentiles
  • The red dashed line shows the observed proportion
  • The distribution is centered near 0.58

Step 8: Read the Simulation Results table

The Single Proportion - Confidence Interval analysis produces a table of simulation results similar to the following:

Warning in attr(x, "align"): 'xfun::attr()' is deprecated.
Use 'xfun::attr2()' instead.
See help("Deprecated")
Simulation Results
Bootstraps Lower Upper
1000 0.51 0.645
95% Bootstrap Percentile Confidence Interval

The table shows:

  • Bootstraps: Number of bootstrap samples generated (1000)
  • Lower: 2.5th percentile of the bootstrap distribution
  • Upper: 97.5th percentile of the bootstrap distribution

95% Confidence Interval: (0.51, 0.645)

Step 1: Identify the parameter

Let \(p\) = the true proportion of likely voters who support the candidate.

Step 2: Calculate the sample statistic

From the sample:

\[\hat{p} = \frac{116}{200} = 0.58\]

Step 3: Obtain the confidence interval from Jamovi

From the Simulation Results table produced by the Single Proportion - Confidence Interval analysis:

  • Number of bootstraps: 1000
  • Lower bound (2.5th percentile): 0.51
  • Upper bound (97.5th percentile): 0.645

95% Confidence Interval: (0.51, 0.645)

Note: Your results may vary slightly depending on the random seed, but should be close to these values.

Step 4: Interpret the confidence interval in context

Interpretation: We are 95% confident that the true proportion of likely voters who support the candidate is between 0.51 and 0.645.

In practical terms:

  • Our best single estimate is 0.58 (58%)
  • But we recognize uncertainty due to sampling variability
  • We’re confident the true support is somewhere between 51% and 64.5%
  • Any value in this range is plausible for the true proportion

Step 5: Understanding “95% confident”

The 95% confidence level means:

  • If we repeated this entire process many times (new samples of 200 voters each time)
  • And constructed a 95% CI from each sample
  • About 95% of those intervals would contain the true proportion \(p\)
  • About 5% would miss \(p\) (just by chance)

Important: The 95% is about the reliability of the method, not about this specific interval.

Step 6: Practical implications

Based on this confidence interval:

  • Is 50% plausible? No, 0.50 is below the lower bound (0.51), so majority support is likely
  • Is 60% plausible? Yes, 0.60 is within the interval, so it’s a plausible value for true support
  • Is 70% plausible? No, 0.70 is above the upper bound (0.645), so support that high is unlikely

Key Takeaways

Bootstrap Confidence Interval Process

  1. Collect sample and calculate \(\hat{p}\)
  2. Generate bootstrap samples: Resample with replacement from original sample
  3. Calculate \(\hat{p}_{boot}\) for each bootstrap sample
  4. Build bootstrap distribution from all bootstrap proportions
  5. Find percentiles: 2.5th and 97.5th for 95% CI (adjust for other levels)
  6. Interpret in context: “We are 95% confident that \(p\) is between…”

Confidence Levels and Percentiles

For different confidence levels, use different percentiles:

Confidence Level Lower Percentile Upper Percentile
90% 5th 95th
95% 2.5th 97.5th
99% 0.5th 99.5th

Trade-off: Higher confidence → Wider interval (less precise, but more confident)

Bootstrap vs. Hypothesis Testing

Aspect Hypothesis Testing Confidence Intervals
Question Is a specific value (\(p_0\)) plausible? What range of values are plausible?
Simulation From theoretical model (assumes \(H_0\)) From actual data (bootstrap)
Output P-value and decision Interval estimate
Interpretation Reject or fail to reject Range of plausible values

Connection: Values inside a 95% CI would NOT be rejected by a two-sided test at \(\alpha = 0.05\).

Common Mistakes to Avoid

Common Mistake Correct Interpretation
“There’s a 95% probability that \(p\) is in this interval” “We are 95% confident this interval contains \(p\)”
“The interval tells us the exact value of \(p\)” “The interval gives us a range of plausible values for \(p\)”
“A 95% CI means our estimate is 95% accurate” “If we repeat this process, 95% of intervals would contain \(p\)”
Back to top