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.
# Sample mean is midpoint of the confidence interval endpoints
x_bar <- mean(c(65,77))
# Margin of error is the difference between the midpoint and the CI endpoints
moe <- 77 - x_bar
\(71 \pm 6 = \bar{x} \pm Z \frac{s}{\sqrt{n}}\)
Given z = 1.645 and n = 25
\(6 = 1.645 \frac{s}{\sqrt{25}} \rightarrow 6 = 1.645 \frac{s}{5} \rightarrow 30 = 8.225 \times s \rightarrow s = \frac{30}{8.225} \rightarrow s = 3.6474164\)
# Given
z <- 1.645 # 90% confidence interval z-score
n <- 25
# Sample standard deviation (s)
s <- (sqrt(n) * moe) / (sqrt(n) * z)
Sample mean: 71; Margin of Error: 6; Sample Standard Deviation: 3.6474164;
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.
z <- 1.645 # 90% confidence interval z-score
sigma <- 250
moe <- 25
n <- ((z*sigma)/moe)^2
Sample Size: 270.6025
\(25 = 1.645 \frac{250}{\sqrt{n}} \rightarrow 25 = \frac{411.25}{\sqrt{n}} \rightarrow 1 = \frac{16.45}{\sqrt{n}} \rightarrow \sqrt{n} = 16.45 \rightarrow n = \pm 270.6025\)
Luke wants to use a 99% confidence interval. Without calculating the actual sample size, determine whether his sample should be larger or smaller than Raina’s, and explain your reasoning. Larger. In order to have a higher confidence we would need a larger sample size.
Calculate the minimum required sample size for Luke. collect?
z <- 2.58 # 99% confidence interval z-score
sigma <- 250
moe <- 25
n <- ((z*sigma)/moe)^2
Sample Size: 665.64
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 differences in scores are shown below.
Is there a clear difference in the average reading and writing scores? Yes the reading score appears to be lower with more variation than the writing score.
Are the reading and writing scores of each student independent of each other? No because the same student takes both tests.
Create hypotheses appropriate for the following research question: is there an evident difference in the average scores of students in the reading and writing exam? \(H_0 = \bar{x}_\text{read} - \bar{x}_\text{write} = 0\) and \(H_A = \bar{x}_\text{read} - \bar{x}_\text{write} != 0\)
Check the conditions required to complete this test. Both distributions appear to be normally distributed and centered around zero. The number of observations is larger than 30.
The average observed difference in scores is \(\bar{x}_{read−write}\) = −0.545, and the standard deviation of the differences is 8.887 points. Do these data provide convincing evidence of a difference between the average scores on the two exams? The p-value suggests we should not reject the null hypothesis
x_bar <- -0.545
sigma <- 8.887
n <- 200
z <- (x_bar)/(sigma/sqrt(n))
1.96 * pnorm(-abs(z))
## [1] 0.3780761
What type of error might we have made? Explain what the error means in the context of the application.A type II error. We beleive there isn’t a difference when there is.
Based on the results of this hypothesis test, would you expect a confidence interval for the average difference between the reading and writing scores to include 0? Explain your reasoning.
Yes. Using an confidence level of 95%, the margin of error is:
\(MOE = Z\frac{s}{\sqrt{n}} \rightarrow MOE = 1.96\frac{8.887}{\sqrt{200}} \rightarrow MOE = 1.231675\)
Therefore the confidence interval is -1.776675 to 0.686675 which contains zero, so we cannot reject the null hypothesis.
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 difference 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.
x_bar_automatic <- 16.12
s_automatic <- 3.58
n_automatic <- 26
x_bar_manual <- 19.85
s_manual <- 4.51
n_manual <- 26
point_estimate <- x_bar_automatic - x_bar_manual
df <- n_automatic - 1
se <- sqrt(((s_automatic^2)/n_automatic) + ((s_manual^2)/n_manual))
t_value <- point_estimate/se
critical_t <- pt(t_value, df)
c(point_estimate + (critical_t * 1.95), point_estimate - (critical_t * 1.95))
## [1] -3.727188 -3.732812
The difference is roughly -3.727 and -3.733 mpg.
The General Social Survey collects data on demographics, education, and work, among many other characteristics of US residents. 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.
Write hypotheses for evaluating whether the average number of hours worked varies across the five groups. H0: \(\mu_1\) = \(\mu_2\) = \(\mu_3\) = \(\mu_4\) = \(\mu_5\) and HA: The average varies across some or all groups.
Check conditions and describe any assumptions you must make to proceed with the test. Independent, normaly distributed observations across groups.
Below is part of the output associated with this test. Fill in the empty cells.
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)
n <- 1172
k <- 5
Prf <- 0.0682
f_value <- qf( 1 - Prf, k-1 , n-k)
# Get missing values
sum_sq <- 501.54 * (k-1)
mean_sq <- 267382 / (n-k)
total <- sum_sq + 267382
Df | Sum Sq | Mean Sq | F value | Pr(>F) | |
---|---|---|---|---|---|
degree | 4 | 2006.16 | 501.54 | 2.1889312 | 0.0682 |
Residuals | 1167 | 267,382 | 229.1191088 | ||
Total | 1,172 | 269388.16 |