A 90% confidence interval for a population mean is (65, 77). The population distribution is approximately normal and the population standard deviation is unknown. This confidence interval is based on a simple random sample of 25 observations. Calculate the sample mean, the margin of error, and the sample standard deviation.
smean= (77+65)/2
paste('The Sample mean is:', round(smean, 4))
## [1] "The Sample mean is: 71"
We know that the margin of error ME is \(\frac{x2???x1}{2}\), and we have that confidence interval CI is (x1,x2)
n <- 25
x1 <- 65
x2 <- 77
ME <- (x2 - x1) / 2
paste('The margin of error (ME) is:', round(ME, 4))
## [1] "The margin of error (ME) is: 6"
For sample standard deviation, \(ME = t??????SE\), We will usthe qt() function, df = 25 - 1.
df <- 25 - 1
p <- 0.9
p2tails <- p + (1 - p)/2
tval <- qt(p2tails, df)
# Since ME = t * SE
SE <- ME / tval
# Since SE = sd/sqrt(n)
sd <- SE * sqrt(n)
paste('The standard deviation is:', round(sd, 4))
## [1] "The standard deviation is: 17.5348"
SAT scores of students at an Ivy League college are distributed with a standard deviation of 250 points. Two statistics students, Raina and Luke, want to estimate the average SAT score of students at this college as part of a class project. They want their margin of error to be no more than 25 points. (a) Raina wants to use a 90% confidence interval. How large a sample should she collect?
Answer:
we have that \(ME = z???SE\) and \(SE = \frac{sd}{\sqrt(n)} => ME = Z.\frac{sd}{\sqrt(n)} => n = (\frac{z.sd}{ME})^2\)
z <- 1.65 # 90% CI
ME <- 25
sd <- 250
n <- ((z * sd) / ME ) ^ 2
paste('Raina should use a sample of size ', n)
## [1] "Raina should use a sample of size 272.25"
From the above, the original calculation yielded 272.25 so it ia approximated to 273 students
Answer:
z <- 2.575 # 99% CI
ME <- 25
sd <- 250
n <- ((z * sd) / ME ) ^ 2
n
## [1] 663.0625
Luke’s sample size should be 664 students
The National Center of Education Statistics conducted a survey of high school seniors, collecting test data on reading, writing, and several other subjects. Here we examine a simple random sample of 200 students from this survey. Side-by-side box plots of reading and writing scores as well as a histogram of the di???erences in scores are shown below.
knitr::include_graphics('https://raw.githubusercontent.com/henryvalentine/MSDS2019/master/Classes/DATA%20606/Home%20works/data606_h5_20.png')
Answer: #### There seems to be a slight difference between the means, while the distribution of differences appear to be quite normal
Answer:
Answer
H_0: The difference of average in between reading and writing equal zero. That is: ??r?????w=0
H_A: The difference of average in between reading and writing does NOT equal zero. That is: ??r?????w???0
Answer:
Answer:
H0: ??diff=0 => There is no difference between the average scores
HA: ??diff???0 => There exists a difference between the average scores
sd_Diff <- 8.887
mean_Dif <- -0.545
n <- 200
SE_Diff <- sd_Diff / sqrt(n)
# to calculate T statistic
t_value <- (mean_Dif - 0) / SE_Diff
df <- n - 1
p <- pt(t_value, df = df)
paste('p-value is: ', p)
## [1] "p-value is: 0.193418237099674"
The NULL hypothesis stands because the p-value is not less that 0.05, which indicates that no convincing evidence of a difference in student’s reading and writing exam scores exists.
Answer:
Type II error: Incorrectly reject the alternative hypothesis.
Our conclusion that no difference exists between the average student reading and writing exam scores might have been a wrong one. We might have wrongly rejected the alternative hypothesis, HA.
Answer:
Each year the US Environmental Protection Agency (EPA) releases fuel economy data on cars manufactured in that year. Below are summary statistics on fuel efficiency (in miles/gallon) from random samples of cars with manual and automatic transmissions manufactured in 2012. Do these data provide strong evidence of a di???erence between the average fuel efficiency of cars with manual and automatic transmissions in terms of their average city mileage? Assume that conditions for inference are satisfied.
knitr::include_graphics('https://raw.githubusercontent.com/henryvalentine/MSDS2019/master/Classes/DATA%20606/Home%20works/data606_h5_img2.png')
Answer:
H0: ??diff=0 => The difference of average miles is equal to zero.
HA: ??diff???0 The difference of average miles is NOT equal to zero.
n <- 26
# for Manual vehicles
mean_m <- 19.85
sd_m <- 4.51
# for Automatic vehicles
mean_a <- 16.12
sd_a <- 3.58
# difference in sample means
mean_Diff <- mean_m - mean_m
# standard error of this point estimate
SE_Diff <- ( (sd_a ^ 2 / n) + ( sd_m ^ 2 / n) ) ^ 0.5
t_val <- (mean_Diff - 0) / SE_Diff
df <- n - 1
p <- pt(t_val, df = df)
paste('p-value is: ', p)
## [1] "p-value is: 0.5"
The p-value is less than 0.05, which means we can conclude that there is strong evidence of a difference in fuel efficiency between these type of vehicles. Therefore, we reject the null hypothesis H0.
The General Social Survey collects data on demographics, education, and work, among many other characteristics of US residents.47 Using ANOVA, we can consider educational attainment levels for all 1,172 respondents at once. Below are the distributions of hours worked by educational attainment and relevant summary statistics that will be helpful in carrying out this analysis.
knitr::include_graphics('https://raw.githubusercontent.com/henryvalentine/MSDS2019/master/Classes/DATA%20606/Home%20works/data606_h5_img3.png')
Answer:
H0: \(\mul=\muh=\muj=\mub=\mug\) => The difference of ALL averages is equal
HA: The avg hours across some or all groups does vary
Answer:
knitr::include_graphics('https://raw.githubusercontent.com/henryvalentine/MSDS2019/master/Classes/DATA%20606/Home%20works/data606_h5_img4.png')
mu <- c(38.67, 39.6, 41.39, 42.55, 40.85)
sd <- c(15.81, 14.97, 18.1, 13.62, 15.51)
n <- c(121, 546, 97, 253, 155)
df <- data.frame (mu, sd, n)
n <- sum(df$n)
k <- length(df$mu)
#degrees of freedom
df <- k - 1
dfResidual <- n - k
# let's use the qf function on the Pr(>F) to get the F-statistic:
Prf <- 0.0682
F_statistic <- qf( 1 - Prf, df , dfResidual)
MSG <- 501.54
MSE <- MSG / F_statistic
SSG <- df * MSG
SSE <- 267382
SST <- SSG + SSE
dft <- df + dfResidual
Answer: