Working backwards, Part II. (5.24, p. 203) 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 for confidence level 90% interval -> 65,77
s_m <- (65+77)/2
s_m
## [1] 71
Margin of Error. ME is always calculated as the product of a critical value and SE. Critical value is \(t_{*}\) as this is t distribution.
n <- 25 # number of observations
df <- n-1
t <- 1.7109 # based on df 24 (2 tail))
se <- (77-s_m)/t
me <- t*se
me
## [1] 6
Sample Standard Deviation.
s_sd <- se*sqrt(n)
s_sd
## [1] 17.53463
SAT scores. (7.14, p. 261) 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): 90% confidence: z score for 90% confidence interval is 1.65. \(ME < 25\) point. standard deviation is 250 points.
me <- 25
sd <- 250
se <- me/1.65
n <- (sd/se)^2
n
## [1] 272.25
(b): 99% confidence: z score is 2.58, which is higher than Raina’s. se will be lower and n would be higher. Luke’s sample size should be larger than Ragina’s.
(c): 99% confidence: z score for 99% confidence is 2.58.
z <- 2.58
se <- me/2.58
n <- (sd/se)^2
n
## [1] 665.64
High School and Beyond, Part I. (7.20, p. 266) 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.
(a): Looking at the histogram , differences in scores (read-white), We can see there is a difference between read-write schools however in average there is no (or very small) difference between reading and writing scores. On the other hand, if you look at the box plot, read score average is slightly lower than write average score. So, the answer is No, there is no clear difference in the average reading and writing.
(b): The reading and writing scores are independent from each other.
(c): Null Hypothesis is that there is no difference. \(H_{o}: \mu_{reading}-\mu_{writing}=0\) . Alternative Hypothesis is there is difference. \(H_{A}: \mu_{reading}-\mu_{writing}\neq0\)
(d): Reading and Writing scores are independent. The samples are random, based on the difference score histogram, distribution is near normal model. (there is no extreme skewness).
(e): \(\mu=-0.545\) , \(s=8.887\)
n <- 200
m <- -0.545
df <- n-1
sd <- 8.887
se <- sd/sqrt(n)
t <- m/se
p <- pt(t,df)
p
## [1] 0.1934182
We accept the null hypothesis. There is no difference between average reading and writing scores.
(f): If the alternative hypothesis is correct, where there is a difference between agerage reading and writing scores, we made Type II error by not rejecting the \(H_{0}\)
(g): Yes. The confidence interval will include the 0. point estimate +- ciritical value * se, - let’s say we have a confidence level of 95%, critical value would be 1.6525.
upper <- m + 1.6525*se
lower <- m - 1.6525*se
upper
## [1] 0.4934406
lower
## [1] -1.583441
-1.5 — 0.493 -> Includes 0
Fuel efficiency of manual and automatic cars, Part II. (7.28, p. 276) The table provides summary statistics on highway fuel economy of cars manufactured in 2012. Use these statistics to calculate a 98% confidence interval for the difference between average highway mileage of manual and automatic cars, and interpret this interval in the context of the data.
1- Create the null and alternative hyphothesis
\(H_{o}: \mu_{manual}-\mu_{auto}=0\). There is no difference between average highway mileage of manual and automatic cars.
\(H_{A}: \mu_{manual}-\mu_{auto}\neq 0\) There is a difference between average highway mileage of manual and automatic cars.
2- Calculate the p value for 98% confidence interval
n <- 26
sd_manual <- 5.01
sd_auto <- 5.29
m_manual <- 27.88
m_auto <- 22.92
df=n-1
se_manual <- sd_manual/sqrt(n)
se_auto <- sd_auto/sqrt(n)
var_manual <- se_manual^2
var_auto <-se_auto^2
se <- sqrt(var_manual + var_auto)
t <- (m_manual-m_auto)/se
p <- pt(t, df, lower.tail = FALSE)
p
## [1] 0.0009486853
We reject the null hypothesis, there is a differrence between average highway mileage of manual and automatic cars.
Email outreach efforts. (7.34, p. 284) A medical research group is recruiting people to complete short surveys about their medical history. For example, one survey asks for information on a person’s family history in regards to cancer. Another survey asks about what topics were discussed during the person’s last visit to a hospital. So far, as people sign up, they complete an average of just 4 surveys, and the standard deviation of the number of surveys is about 2.2. The research group wants to try a new interface that they think will encourage new enrollees to complete more surveys, where they will randomize each enrollee to either get the new interface or the current interface. How many new enrollees do they need for each interface to detect an effect size of 0.5 surveys per enrollee, if the desired power level is 80%?
The difference between average surveys that enrollees complete between new and current is 0.5 (effect size).
Single tail of 80%: 1.646 * SE Upper and Lower bounds: 1.96 (z value for 5% significance) * SE
\(SE(1.646+1.96)=4\)
#calculating se
se <- 4/(1.646+1.96)
se
## [1] 1.109262
\(SE=\sqrt{(s^{2}/n + s^{2}/n)}\)
# calculating n (new enrolees that is needed for each interface to detect effect size of 0.5)
s <- 2.2
n <- ((s^2)+(s^2))/(se^2)
n
## [1] 7.866958
We will need 8 enrollees for each interface
Work hours and education. 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.
(a): The null hypothesis is , average number of hours worked for respondents that are Less than high school, high school, Jr Collage, Bachelours and Graduate degrees are the same.
\(H_{o}: \mu_{l_hs}=\mu_{hs}=\mu_{jr_col}=\mu_{bach}=\mu_{grad}\)
The alternative hypothesis is, average number of hours worked for respondents that are Less than high school, high school, jr collage, bachelours and graduate degrees are NOT the same.
\(H_{A}: \mu_{l_hs}\neq\mu_{hs}\neq\mu_{jr_col}\neq\mu_{bach}\neq\mu_{grad}\)
(b): The observations are independent between the groups; the collected data is less than 10% of the population. The observations within each group are nearly normal. The variablity across the groups area about equal.
(c):
Df Degree
# there are 5 groups
df_degree <- 5-1
df_degree
## [1] 4
Df Total
# there are total 1172 observants
df_total <- 1172-1
df_total
## [1] 1171
Df Residuals
df_residuals <- df_total-df_degree
df_residuals
## [1] 1167
Sum Sq Degree
#def_degree is 4, mean sq is 501.54
sum_sq_degree <- 4*501.54
sum_sq_degree
## [1] 2006.16
Sum Sq Total
sum_sq_total <- sum_sq_degree + 267382
sum_sq_total
## [1] 269388.2
Mean Sq Residual
mean_sq_residual <- 267382/df_residuals
mean_sq_residual
## [1] 229.1191
F-Value
f_value <- 501.54/mean_sq_residual
f_value
## [1] 2.188992
(d): p value is 0.0682 as provided , based on the p value, we reject the null hypothesis. Average number of hours worked for respondents that are Less than high school, high school, jr collage, bachelours and graduate degrees are NOT the same.