Bootstrap estimate of bias 본문
#Motivation : small sample로 population parameter를 추정하고 싶다 - bootstrap
2. Consider patch data in “patch.csv” file. The data contains measurements of a certain hormone in the bloodstream of eight subjects after wearing a medical patch. The parameter of interest is
θ= (E(new)−E(old)) / (E(old) − E(placebo))
If |θ| ≤ 0.20, this indicates bioequivalence of the old and new patches. The statistic is Y ̄/Z ̄. Compute a bootstrap estimate of bias and three 95% confidence intervals in the bioequivalence ratio statistic.
#Directory 설정
getwd()
setwd("/Users/kimtaestu/Downloads")
#data 불러오기
dat <- read.csv("patch.csv", stringsAsFactors = T);dat
#내가 가진샘플이 8개 밖에 없음 - small sample
theta.hat <- mean(dat$y)/mean(dat$z)
theta.hat
B <- 20000 #replicate
n <- nrow(dat);n #bootsamp
theta.hat_star <- numeric(B) #empty vector
for(b in 1:B){
i <- sample(1:n, size = n, replace = T) #1부터 n까지 n개 복원해서 뽑겠다
y_star <- dat$y[i]
z_star <- dat$z[i]
theta.hat_star[b] <- mean(y_star)/mean(z_star)
}
bias_hat <- mean(theta.hat_star) - theta.hat
bias_hat
sd(theta.hat_star)
sqrt(sum((mean(theta.hat_star) - theta.hat_star)^2)/(B-1))
'Applied > Statistical Computing' 카테고리의 다른 글
Chapter 14 - 1 ) Quasi-Newton Algorithm (0) | 2022.11.18 |
---|---|
Chapter 14 - 0 ) Optimization Introduction (0) | 2022.11.17 |
Empirical Distribution (0) | 2022.11.12 |
Chapter 13- 2,3) Gaussian Quadrature and Laplace Approximation (0) | 2022.11.10 |
Chapter 13 - 1) Numerical Methods - Newton (0) | 2022.11.10 |
Comments