Graded: 5.6, 5.14, 5.20, 5.32, 5.48
library ('DATA606')
##
## Welcome to CUNY DATA606 Statistics and Probability for Data Analytics
## This package is designed to support this course. The text book used
## is OpenIntro Statistics, 3rd Edition. You can read this by typing
## vignette('os3') or visit www.OpenIntro.org.
##
## The getLabs() function will return a list of the labs available.
##
## The demo(package='DATA606') will list the demos that are available.
##
## Attaching package: 'DATA606'
## The following object is masked from 'package:utils':
##
## demo
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.
Ans:
X + ME = 77 x - ME = 65
2X = 142 X= 71 ME = X-65 = 71-65 = 6
t* x (s/sqrt(25)) = 6
the T distribution degree of freedom is n-1 =24 Using the t distribution table at 90% confidence is 1.711 1.711 * s/5 = 6 s= 30/1.711 = 17.53
Sample mean = 71 Margin of erro = 6 Sample standard deviation = 17.53
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 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? (b) 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. (c) Calculate the minimum required sample size for Luke.
Ans
ME = z* x s/sqrt(n) at 90% confidence z is 1.645 1.645 x 250/sqrt(n) <= 25 sqrt(n) >= (1.645 x 250) /25 sqrt(n) >= 16.45 n >= 270.6 n >= 271
at 99% confidence z is 2.57 So the sample size should be more
sqrt(n) >= ( 2.57 x 250 )/25 sqrt(n) >= 25.7 n >= 660.49 n >= 661
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 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.
No, there is no clear difference in the average reading and writing scores from the box plots
Are the reading and writing scores of each student independent of each other? No, the reading and writing scores of a given student is dependent because it is done by same student. It is paired dataset
Create hypotheses appropriate for the following research question: is there an evident di???erence in the average scores of students in the reading and writing exam? Ho: There is no difference in the reading and writing scores of students, HA: There is a difference in the reading and writing scores of students \[ H0: \mu = 0 \] \[ HA: \mu != 0 \]
Check the conditions required to complete this test. We have independence in the difference of exam scores, because of random sampling and we know n is <10% of population. We also see that the n>30 which the histogram showing a normal distribution
The average observed di???erence in scores is ¯xread???write = ???0.545, and the standard deviation of the di???erences is 8.887 points. Do these data provide convincing evidence of a di???erence between the average scores on the two exams?
Let’s calculate the test statistic
Z = (x - Mu)/SE SE = s/sqrt(n) = 8.887/sqrt(200) = 0.628 Z= (???0.545 - 0)/0.628 = -0.868
p-value = 0.1922. and 0.1922 > 0.025 for one side
Therefore we fail to reject the null hypothesis, the data do not provide convincine evidence of a difference between the average reading and writing scores.
Type 2 error. This means that we incorrectly retained the null hypothesis which is that their is no difference between the average reading and writing scores
g)Based on the results of this hypothesis test, would you expect a confidence interval for the average di???erence between the reading and writing scores to include 0? Explain your reasoning
Yes the confidence interval will include 0, since we failed to reject the null hypothesis
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 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.
Ans
Ho: \[ \mu = 0 \] There is no difference between the average fuel efficiency of cars with manual and automatic transmissions HA: \[ \mu <> 0 \] There is a difference between the average fuel efficiency of cars with manual and automatic transmissions
Since the sample size is small, we will use the T statistics
X_diff= 16.12 - 19.85 =3.73 S_diff = sqrt(SD1^2/n1 + SD2^2/n2) =sqrt( (3.58^2 + 4.51^2)/26)=1.129 T= 3.73 -0/1.129 = 3.304
df= 26-1 =25
2 * pt(3.304, df = 25, lower.tail = FALSE)
## [1] 0.002876635
0.002876635 <0.05 therefore we reject the null hypothesis, We think there is a enough evidence to suggest that there is a difference in average fuel efficiency of cars with manual and automatic transmissions
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.
Ho: Mu_less_HS = Mu_less_HS = Mu_Jr_Coll = Mu_Bachelor = Mu_Graduate
there is no difference in average number of hours worked between the 5 educational attainment levels
HA : At least one mean is different
b)Check conditions and describe any assumptions you must make to proceed with the test. The selection was random, and sample size <10% of population with n >30
What is the overall mean = 40.45 Lets caculate sum of squares between groups SSG SSG = 121(3867-40.45)^2 + 546(39.6-40.45)^2 + 97(41.39-40.45)^2 + 253(42.55-40.45)^2 + 155*(40.85 -40.45)^2
121*(38.67-40.45)^2 + 546*(39.6-40.45)^2 + 97*(41.39-40.45)^2 + 253*(42.55-40.45)^2 + 155*(40.85 -40.45)^2
## [1] 2004.101
SSG =2004.101
Now, lets calculate sum of squares total SST SST = SSG + SSE = 2004.101 + 267382 = 269386.101
MSG = SSG/Group_degree_of_freedom = 2004.101/4 = 501.025 MSE = SSE/Error_degree_of_freedom = 267382/1167 = 229.12
F= MSG/MSE = 501.54/229.12 = 2.189
Since the Pr(>F) is 0.0682. 0.0682>0.05 therefore we fail to reject then null hypothesis. We conclude that there is not enough evidence to show that their is a significiant difference in at least one of the education attainment levels