5.6 Working Backwards, PART II. 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.
n <- 25

#we know that the margin of error is (b-a)/2 where the confidence interval is (a,b)
ME <- ((77-65)/2)
ME
## [1] 6
#we know that sample mean is calculated as (a+b)/2 for confidence interval (a,b)
xbar <- ((77+65)/2)
xbar
## [1] 71
#to calculate the sample standard devation we use ME = t(.05)*s/sqrt(n). Using the qt function and df = 25-1 we get

df <- 25-1
t.value <- qt(.95, df)
t.value
## [1] 1.710882
sd <- (ME/t.value)*5
sd
## [1] 17.53481
5.14 SAT Scores 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 in this college as part of a class project. They want their margin of error to be no more that 25 points.
#we will use formual n = (Z(.05)*(standard deviation)/ME)^2
z.star <- 1.65
ME <- 25
SD <- 250

sample.size <- (((z.star*SD)/(ME))^2)
sample.size
## [1] 272.25
#we would need 273 participants
#we will use formual n = (Z(.05)*(standard deviation)/ME)^2
zstar.Luke <- 2.58
ME <- 25
SD <- 250

samplesize.Luke <- (((zstar.Luke*SD)/(ME))^2)
samplesize.Luke
## [1] 665.64
#we would need 273 participants
5.20 High School and Beyond, Part I The National Center of Education Statistics conducted a survey of high school seniors, collecting test data on reading, writing, and serveral other subjects. Here we examine a simple random sample of 200 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.
n <- 200
mean.diff <- -.545
df <- n-1
SD <- 8.887
SE <- SD/sqrt(n)
T <- (mean.diff-0)/SE
pvalue <- pt(T, df)
pvalue
## [1] 0.1934182
#our t-value, .19 > .05 so we fail to reject the null hypothesis. we do no have convining evidence of a difference between the average reading and writing exam scores.
5.32 Fuel Efficiency of manual and automatic cars, Part I 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 transmission in terms of their average city mileage? Assume that conditions of inference are satisfied.
+ Null: mean.A - mean.M = 0
+ alternate: mean.A - mean.M does not equal 0
n.a <- 26
n.m <- 26
SD.A <- 3.58
SD.M <- 4.51
mean.A <- 16.12
mean.M <- 19.85
alpha <- .05
meandiff <- mean.A - mean.M
SE.A <- SD.A/sqrt(n.a) 
SE.M <- SD.M/sqrt(n.m)
SE <- sqrt(((SE.A)^2)+(SE.M)^2)
T.1 <- (meandiff-0)/SE
pvalue.1 <- pt(T.1, 25)
pvalue.1 <- 2*pvalue.1 #because we are running a two tailed test, we multiply by 2
pvalue.1
## [1] 0.002883615
##our pvalue, .003 < .05 so we will reject out null hypothesis. This means that there is enough evidence supporting that there is a difference in the average city miles of automatic and manual vehicles.
5.48 Work hours and education 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.
anova.table <- read.csv("C:/Users/OluwakemiOmotunde/Desktop/6.48.csv")
anova.table
##           X    DF    SUM.SQ MEAN.SQ F.VALUE Pr...F.
## 1    degree     4   2004.11  501.54    2.19  0.0682
## 2 Residuals 1,167   267,383  229.11      NA      NA
## 3     Total  1171 269387.11      NA      NA      NA
##pdf for calculations is attached.