Created
September 9, 2025 15:26
-
-
Save carlislerainey/edb70a6f0da2d27f1116cc2b7606330d to your computer and use it in GitHub Desktop.
Code for parametric bootstrap for the toothpaste cap problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pi_hat <- 8/150 # ml estimate from observed data | |
| n_bs <- 2000 | |
| bs_est <- numeric(n_bs) # a container for the estimates | |
| for (i in 1:n_bs) { | |
| bs_y <- rbinom(150, size = 1, prob = 8/150) | |
| bs_est[i] <- mean(bs_y) | |
| } | |
| print(sd(bs_est), digits = 2) # se estimate | |
| print(quantile(bs_est, probs = c(0.05, 0.95)), digits = 2) # 90% ci |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment