Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using R Studio. The data set below, contains mercury levels (parts per million)

ID: 3181941 • Letter: U

Question

Using R Studio.

The data set below, contains mercury levels (parts per million) for 30 fish caught in lakes in some place in US. SHOW ALL CODES:


(a) Create a index plot, histogram, and boxplot of the data.
(b) Bootstrap the mean and find the bootstrap standard error and the 95% bootstrap percentile interval.
(c) Remove the outlier and repeat part (b). [Hint: you may use the code below to remove the outlier in a data set.]

      par(mfrow=c(2,2))
      plot(y)
boxplot(y)
      hist(y)
      which(y>a) # this produce an index of the outlier
      y[index] <- b #some value that you need to remove the outlier
      plot(y)
(d) What effect did removing the outlier have on the bootstrap distribution, in particular, the standard error?

Data Set:

Explanation / Answer

fish <- read.csv("mercury.txt")
par(mfrow = c(3,1))
plot(fish$Mercury, main = "Index plot of Mercury levels", ylab = "Mercury")
hist(fish$Mercury, main = "Histogram of Mercury Levels", xlab = "Mercury")
boxplot(fish$Mercury, ylab = "Mercury", main = "Boxplot of Mercury level")

N = 10^4
boot.mean <- numeric(N)
fish1 <- fish[,1]
for(i in 1:N){
        boot.mean[i] <- mean(sample(fish1,length(fish1),replace=TRUE))
}
mean(boot.mean)
sd(boot.mean)

CI <- quantile(boot.mean, prob = c(.025, .975))

fish2 <-fish[fish < max(fish)]
boot.mean2 <- numeric(N)
par(mfrow = c(3,1))
plot(fish2, main = "Index plot of Mercury levels", ylab = "Mercury")
hist(fish2, main = "Histogram of Mercury Levels", xlab = "Mercury")
boxplot(fish2, ylab = "Mercury", main = "Boxplot of Mercury level")
for(i in 1:N){
        boot.mean2[i] <- mean(sample(fish2,length(fish2),replace=TRUE))
}
mean(boot.mean2)
sd(boot.mean2)

CI2 <- quantile(boot.mean2, prob = c(.025, .975))

paste("Removing the outlier out reduced our bootstrap mean and the standard error by ",round(abs(mean(boot.mean2)-mean(boot.mean))/mean(boot.mean)*100,2%))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote