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

x_bar = mean(Highway_Speeds$Speed) = 66

s = sd(Highway_Speeds$Speed) = 3.00427046479524

n = 40

mu_0 = 65

df = n-1 = 39

\(\alpha = 0.01\).

Step 2: Hypothesis

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

Step 3: Standard Error

SE = s/sqrt(n)

SE = 0.475016868796284

Step 4: T-statistics

Tstat = (x_bar - mu_0)/SE

Tstat = 2.10518839580171

Step 5: find pvalue

pvalue = pt(Tstat,df,lower.tail=FALSE)

pvalue = 0.0208836093938327

Conclusion:

Since p_value (0.0208836) > \(\alpha\) (0.01), do not reject the null hypothesis. At the 1% significance level, we can conclude that the average speed of cars is 65 mph or lower, so officers should not be concerned.

Approach 2 (use t.test)

if(!require(BSDA)) install.packages(“BSDA”) library(BSDA)

Step 1: Hypothesis

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

Step 2: Find sample size and alpha

n= nrow(Highway_Speeds)

n = 40

\(\alpha = 0.01\)

Step 3: Use t-test

results = t.test(Highway_Speeds$Speed,alternative=“greater”,mu=65,conf.level=0.99)

Tstat = results$statistic

pvalue = results$p.value

Conclusion: Since p_value (0.0208836) > \(\alpha\) (0.01), do not reject the null hypothesis. At the 1% significance level, we can conclude that the average speed of cars is 65 mph or lower, so officers should not be concerned.