We are going to firstly make some descriptive statistics, see boxplot and a histogram in the first section to get to know the data we will be working on. In the second section we are going to focus on Point & Interval Estimation. Finally we are going to make some summary in section no. 3.
This is an R Markdown document describing data from questionnaires among the people. What’s our data?
n <- length(wage1$wage)
xbar <- mean(wage1$wage, na.rm = TRUE)
s <- sd(wage1$wage)
c("Number of wages:"=n, "Mean:"=xbar, "Standard deviation:"=s)## Number of wages: Mean: Standard deviation:
## 526.000000 5.896103 3.693086
margin <- qt(0.975, df=n-1) * s / sqrt(n)
low <- xbar - margin
high <- xbar + margin
c("From:" = low, "To:" = high)## From: To:
## 5.579768 6.212437
# Standard error of mean (whole)
s/sqrt(n)## [1] 0.1610262
samp_mean <- rep(NA, 55)
samp_sd <- rep(NA, 55)
samp_n <- 44
for(i in 1:55) {
samp <- sample(wage1$wage, samp_n)
samp_mean[i] <- mean(samp)
samp_sd[i] <- s
}lower_ie <- samp_mean - 1.96 * samp_sd / sqrt(samp_n)
upper_ie <- samp_mean + 1.96 * samp_sd / sqrt(samp_n)
c("Lower bound:" = lower_ie[1], "Upper bound:" = upper_ie[1])## Lower bound: Upper bound:
## 4.561490 6.743964
plotCI(1:55,
samp_mean,
uiw = qnorm(0.975)*samp_sd,
pt.bg=par("bg"),
pch=21,
xlab = "Sample means confidence interval (from 1 to 55)",
ylab = "Samples of size 44",
main = "Mean confidence interval")