Question: erform the test in problem S 2 using a bootstrap analysis. ( a ) Would we want to use a one - sample or two

erform the test in problem S2 using a bootstrap analysis.
(a) Would we want to use a one-sample or two-sample bootstrap test? Explain your choice.
(b) The code below runs the bootstrap procedure on the differences between the shoot and root
data. However, there are some problems with the code.
The code only runs the bootstrap procedure 50 times, which is not enough to make an
accurate approximation of the null distribution.
The code takes a resample without replacement.
Fix the code so that the bootstrap procedure runs 5000 times and samples with
replacement.
Shoot <- c(4.42,5.81,4.65,4.77,5.25,4.75)
Root <- c(3.76,5.40,3.91,4.29,4.69,3.93)
diff <- Shoot - Root
# Calculate summary statistics
x_bar <- mean(diff)
n <- length(diff)
B <-50
# Create a vector to store t_hat values
t_hat <- numeric(B)
set.seed(371)
# Bootstrap loop
for(i in 1:B){
# 2. Draw a SRS of size n from data
x_star <- sample(diff, size = n, replace = F)
# 3. Calculate resampled mean and sd
x_bar_star <- mean(x_star)
s_star <- sd(x_star)
6
# 4. Calculate t_hat, and store it in vector
t_hat[i]<-(x_bar_star - x_bar)/(s_star/sqrt(n))
}
(c) Calculate a two-sided bootstrap p-value.
(d) Explain why the bootstrap test result is similar to the T test result from S2.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!