Obtain 5 bootstrapped samples and compute their corresponding medians, please don’t use the sample function.
Do in R or whatever is most comfortable.
#R Codes
#Given Vector
x <- c(28, 32, 28, 39)
#Initiating empty boot vector and median vector
boot_vector <- c()
median_vec <- c()
#Bootstraping sample creation and median calculation for each
sample
for (i in 1:5) {
boot <- sample(x, 5, replace = TRUE)
median_val <- median(boot)
boot_vector <- c(boot_vector, boot)
median_vec <- c(median_vec, median_val)
}
#Bootstarping matrix calculation
boot_mat <- matrix(boot_vector, nrow = 5, byrow = TRUE)
#dataframe creation
library(dplyr)
boot_df <- data.frame(bootstrap_sample_no = 1:5, boot_mat)
boot_df$median <- median_vec
**If the answer does not match or any kind of confusion you have please comment
Get Answers For Free
Most questions answered within 1 hours.