Use both approach 1 and approach 2.

Dataset: Highway_Speeds

A police officer is concerned about speeds on the Newburgh-New Paltz section of NYS Thruway I-87. The data accompanying this exercise show the speeds of 40 cars on a Saturday afternoon. The speed limit on this portion of I-87 is 65 mph. Test if the average speed is greater than the speed limit, at \(\alpha = 0.01\). Are the officer’s concerns warranted?

We will use the second column, and rename the column to “Speed”:

colnames(Highway_Speeds)[2]="Speed"
head(Highway_Speeds)
##   Highway.1..55.mph. Speed
## 1                 60    70
## 2                 55    65
## 3                 53    65
## 4                 65    62
## 5                 57    70
## 6                 58    64

Approach 1 (find sample statistics, df, Tstat, ect.)

Step 1 Hypothesis: \(H_0:\mu \le 65\); \(H_1:\mu > 65\)

#sample stats

n = nrow(Highway_Speeds)
n
## [1] 40
x_bar = mean(Highway_Speeds$Speed)
x_bar
## [1] 66
s = sd(Highway_Speeds$Speed)
s
## [1] 3.00427
mu_0 = 65
df = n - 1
alpha = .05
#Standard Error
SE = s/sqrt(n)
SE
## [1] 0.4750169
#Z statistics
Tstat = (x_bar - mu_0)/SE
Tstat
## [1] 2.105188
#The pvalue is
pvalue = pt(Tstat,df,lower.tail=FALSE)
pvalue
## [1] 0.02088361

#conclusion Since p_value (.02088361) > \(\alpha\) (0.01), do not reject the null hypothesis. At the 5% significance level, We can not conclude that cars on the NYS Thruway I-87 in New Paltz drive at a average speed that is greater than the speed limit.

Approach 2 (use t.test)

Step 1

Hypothesis: \(H_0:\mu \le 65\); \(H_1:\mu > 65\)

#Sample size

n = nrow(Study_Hours)
n
## [1] 35

#significance level alpha = .01

Use t.test

results = t.test(Highway_Speeds$Speed,alternative="greater",mu=65,conf.level=0.99)
Tstat = results$statistic
Tstat
##        t 
## 2.105188
pvalue = results$p.value
pvalue
## [1] 0.02088361

#conclusion Since p_value (.02088361) > \(\alpha\) (0.01), do not reject the null hypothesis. At the 5% significance level, We can not conclude that cars on the NYS Thruway I-87 in New Paltz drive at a average speed that is greater than the speed limit.