load("more/nc.RData")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.
Distribution: Student t
Sample mean: equal midpoint in ci = (65+77)/2 = 71.
Margin of error: ci(high)- sample mean = (77-71) = 6
Standard Deviation: ME*sqrt(n) / t(df24) = (6 *Sqrt(25)) / 1.710882 = 17.5348146
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?
Given sd = 250 and margin of error of 25:
If ci = 90% then z* = qnorm(0.05) = -1.6448536.
n = ((z* * sd) / ME)^2 = round(((qnorm(0.05) * 250)/25)^2,0) = 271
(b) Luke wants to use a 99% confidence interval. Without calculating the actual sample size,
Luke's sample size would have to increase because n = ((z* * sd) / ME)^2. Since Lukes wants a 99% confidence intervale we know the z* would increase and n would increase with z*.
(c) Calculate the minimum required sample size for Luke.
Lukes minimum required sample size would be ((z* * sd) / ME)^2, where z* = -2.5758293;
or round(((qnorm(0.01/2) * 250)/25)^2,0) = 663
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) Is there a clear difference in the average reading and writing scores?
The box plots do not indicate a clear difference. The box plot shows similar central tendencies and spread. The distribution of the differences appears nearly normal with a mean close to zero.
(b) Are the reading and writing scores of each student independent of each other?
Data is described as independent when the sets of data arise from separate individuals or paired when it arises from the same individual at different points in time. I believe the the question is a bit ambiguous on this, but I interpret it to be paired data with independent scores.
(c) Create hypotheses appropriate for the following research question: is there an evident difference
H0 = mu_reading_score - mu_writing_score = 0
HA = mu_reading_score - mu_writing_score != 0
(d) Check the conditions required to complete this test.
Distribution: near normal
Independence: Yes, 200 random observations > 30
Skew: limited, box plots don't indicate too much
Conditions appear to be satisfied.
(e) The average observed difference in scores is ¯xread???write = ???0.545, and the standard deviation of the differences is 8.887 points.
Given:
delta_mu = 0.545, sd = 8.887, n = 200 and df = 199
SE = (sd / sqrt(n)) = (8.887/sqrt(200)) = 0.6284058
t = (delta_mu - 0)/ SE = -0.545/(8.887/sqrt(200)) = 0.867274
p = r pt(q=-0.867274, df=199, lower.tail = TRUE) = 0.1934182
p-value is greater than 0.05 so we can not reject the null hypothesis. There is no convincing evidence that mu_reading_score - mu_writing_score != 0.
(f) What type of error might we have made? Explain what the error means in the context of the application
We might have made a type 2 error, if there really was a difference. A type 2 error arises when you don't reject the null Hypothesis (no difference between mu1 and mu1) when you should have because there was a difference.
(g) Based on the results of this hypothesis test, would you expect a confidence interval for the
Yes, since we could not reject, mu_reading_score - mu_writing_score = 0, we would expect the confidence interval to contain 0. This is borne out with the confidence interval below:
SE <- 8.887/sqrt(200)
critical_value <- qt(p=(.05/2), df=199, lower.tail=FALSE)
critical_value## [1] 1.971957
delta_mu <- -0.545
c(delta_mu - SE * critical_value, delta_mu + SE * critical_value)## [1] -1.7841889 0.6941889
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.
H0 = mu_auto - mu_manual = 0
HA = mu_auto - mu_manual != 0
Given, n =26, sd_auto = 3.58, sd_manual = 4.51 abd mu_diff = (16.12-19.85) = -3.73
SE = sqrt((3.58^2)/26 + (4.51^2)/26) = 1.1292697
df = 25
t = (mu_diff -0) / se = (-3.73) / 1.1292697 = -3.30302
p-value = pt(q=t_score, df=n-1, lower.tail = TRUE) * 2 = 0.0028836
p-value is less than 0.05 so we can reject the null (H0) hypothesis. There is convincing evidence that the difference in the average mpg of automatic and manual autos.
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.
(a) Write hypotheses for evaluating whether the average number of hours worked varies across the
H0 = mu_ltHS = mu_HS = mu_JC = mu_BA = mu_GR
HA = at least one of the means is not equal for the groups
(b) Check conditions and describe any assumptions you must make to proceed with the test.
Conditions:
- observation are independent
- data for each group normal or near normal
- similar variability across grups
Assumptions:
- 1172 observations selected randomly
- independence across the groups
- based on box plots the groups are near normal
- based on box plots variability is similar
(c) Below is part of the output associated with this test. Fill in the empty cells.
library(knitr)
hrs <- data.frame (
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)
)
colnames(hrs) <- c("mean","sd","n")
knitr::kable(hrs)| mean | sd | n |
|---|---|---|
| 38.67 | 15.81 | 121 |
| 39.60 | 14.97 | 546 |
| 41.39 | 18.10 | 97 |
| 42.55 | 13.62 | 253 |
| 40.85 | 15.51 | 155 |
n <- sum(hrs$n)
n## [1] 1172
k <- length(hrs$sd)
k## [1] 5
df_degrees <- k-1
df_degrees## [1] 4
df_residual <- n-k
df_residual## [1] 1167
prf <- 0.0682
prf## [1] 0.0682
F <- qf(1-prf, df_degrees, df_residual)
F## [1] 2.188931
ttl_mean = 40.45
ttl_mean## [1] 40.45
SSG <- sum(hrs$n * (hrs$mean - ttl_mean)^2)
SSG## [1] 2004.101
MSE <- 501.54
MSE## [1] 501.54
MSG <- MSE / F
MSG## [1] 229.1255
anova <- data.frame(
names <- c("degree","Residuals","Total"),
Df <- c("4","1167","1171"),
SumSq <- c("2004.1","267382","269386.1"),
MeanSq <- c("501.54","229.13",""),
Fvalue <- c("2.19","",""),
prf <- c("0.0682","","")
)
colnames(anova) <- c("names","Df","Sum Sq","Mean Sq","F value","Pr(>F)")
knitr::kable(anova)| names | Df | Sum Sq | Mean Sq | F value | Pr(>F) |
|---|---|---|---|---|---|
| degree | 4 | 2004.1 | 501.54 | 2.19 | 0.0682 |
| Residuals | 1167 | 267382 | 229.13 | ||
| Total | 1171 | 269386.1 |
(d) What is the conclusion of the test?
The p-value is greater than 0.05, so we do not refject the null, so there exsists no significant difference between the groups.