Professional Documents
Culture Documents
STA 202 Project Assignment 2 Q5
STA 202 Project Assignment 2 Q5
Data
beeswax <- c(14.27, 14.8, 12.28, 17.09, 15.1, 12.92, 15.56, 15.38,
mean(beeswax)
median(beeswax)
library(boot)
sd(beeswax)
IQR(beeswax)
mad(beeswax)
Bootstrap to find approximate 90% confidence intervals for the trimmed means
mean(x[index])
Bootstrap to find the approximate sampling distribution and standard error of the upper quartile
quantile(x[index], 0.75)
}
boot_quartile <- boot(beeswax, boot_upper_quart
the bootstrap samples and calculating the trimmed mean for each sample. Finally, we can find the 90%
confidence interval by taking the 5th and 95th percentiles of the trimmed mean distribution.
for (i in 1:B) {
This gives a 90% confidence interval for the 10% trimmed mean of (14.535, 15.235).
Find and compare the standard deviation of the measurements, the interquartile range, and the MAD.
We can calculate the standard deviation, interquartile range (IQR), and median absolute deviation
(MAD) using the following R code:
Standard deviation
sd(x)
Interquartile range
IQR(x)
[1] 0.8137343
[1] 1.135
[1] 0.721377
We can see that the standard deviation is 0.81, the IQR is 1.14, and the MAD is 0.72. The MAD is
smaller than the standard deviation and the IQR, which suggests that it may be a more robust
measure of dispersion for this data.
Use the bootstrap to find the approximate sampling distribution and standard error of the upper
quartile.
To use the bootstrap to find the approximate sampling distribution and standard error of the upper
quartile, we can follow a similar procedure as for the trimmed mean. We generate B bootstrap
samples, calculate the upper quartile for each sample, and use these values to approximate the
sampling distribution and standard error.
for (i in 1:B) {
hist(uq_boot, freq=FALSE)
This gives an approximate standard error of the upper quartile of 0.169. The histogram of the bootstrap
samples suggests that the sampling distribution of the upper quartile may be skewed, with a long right
tail.
Plot Output: