เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Sample proportion value effects on bootstrap CIs

One additional element that changes the width of the confidence interval is the sample parameter value, \(\hat{p}\).

Generally, when the true parameter is close to 0.5, the standard error of \(\hat{p}\) is larger than when the true parameter is closer to 0 or 1. When calculating a bootstrap t-confidence interval, the standard error controls the width of the CI, and here (given a true parameter of 0.8) the sample proportion is higher than in previous exercises, so the width of the confidence interval will be narrower.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Foundations of Inference in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • calc_p_hat() is shown in the script to calculate the sample proportions. calc_t_conf_int() from the previous exercise has been updated to now use any value of p_hat as an argument. Read their definitions and try to understand them.
  • Run the code to calculate the bootstrap t-confidence interval for the original population.
  • Consider a new population where the true parameter is 0.8, one_poll_0.8. Calculate \(\hat{p}\) of this new sample, using the same technique as with the original dataset. Call it p_hat_0.8.
  • Find the bootstrap t-confidence interval using the new bootstrapped data, one_poll_boot_0.8, and the new \(\hat{p}\). Notice that it is narrower than previously calculated.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

calc_p_hat <- function(dataset) {
  dataset %>%
    summarize(stat = mean(vote == "yes")) %>%
    pull()
}
calc_t_conf_int <- function(resampled_dataset, p_hat) {
  resampled_dataset %>%
    summarize(
      lower = p_hat - 2 * sd(stat),
      upper = p_hat + 2 * sd(stat)
    )
}

# Find proportion of yes votes from original population
p_hat <- calc_p_hat(one_poll)

# Review the value
p_hat  

# Calculate bootstrap t-confidence interval (original 0.6 param)
calc_t_conf_int(one_poll_boot, p_hat)

# Find proportion of yes votes from new population
p_hat_0.8 <- ___
  
# Review the value
p_hat_0.8  
  
# Calculate the bootstrap t-confidence interval (new 0.8 param)
___
แก้ไขและรันโค้ด