Description and Source of Data

This material was adapted from the UF Biostatistics open Open Learning Textbook. https://bolt.mph.ufl.edu/6050-6052/unit-4b/module-13/paired-t-test/

Project Background

Drunk driving is one of the main causes of car accidents. Interviews with drunk drivers who were involved in accidents and survived revealed that one of the main problems is that drivers do not realize that they are impaired, thinking “I only had 1-2 drinks … I am OK to drive.”

A random sample of 20 drivers was chosen, and their reaction times in an obstacle course were measured before and after drinking two beers. The purpose of this study was to check whether drivers are impaired after drinking two beers.

BeforeBeers <- read_csv("Before2Beers.csv")
## Rows: 20 Columns: 2
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## dbl (2): SubjectID, Before
## 
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(BeforeBeers)
AfterBeers <- read_csv("After2Beers.csv")
## Rows: 20 Columns: 2
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## dbl (2): SubjectID, After
## 
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(AfterBeers)
BeerTable <- sqldf("
 select
 BeforeBeers.SubjectID,
 BeforeBeers.Before,
 AfterBeers.After
 from
 BeforeBeers
 join
 AfterBeers
 on 
 BeforeBeers.SubjectID=AfterBeers.SubjectID
 ")
view(BeerTable)
BeerTable$Difference <- BeerTable$After - BeerTable$Before

Dataset with Calculated Differences

view(BeerTable)

SubjectID is the ID of each person who was examined in the study, this is what connects them in each table Before is the reaction times of the drivers before drinking two beers After is the reaction time of the drivers after drinking two beers Difference is the total difference in reaction times

Distribution

mu <-mean(BeerTable$Difference)
s <- sd(BeerTable$Difference)

qnorm(seq(0,1,0.1),mu,s)
##  [1]        -Inf -0.60504132 -0.22450185  0.04989388  0.28435491  0.50350000
##  [7]  0.72264509  0.95710612  1.23150185  1.61204132         Inf
quantile(BeerTable$Difference,probs=seq(0,1,0.1))
##     0%    10%    20%    30%    40%    50%    60%    70%    80%    90%   100% 
## -0.970 -0.555 -0.284 -0.020  0.506  0.565  0.720  0.964  1.126  1.568  1.970
theoretical_quantiles <- qnorm(seq(0.01,0.99,0.1), mean = mu, sd = s)
sample_quantiles <- quantile(BeerTable$Difference,seq(0.01,0.99,0.1))
qplot(theoretical_quantiles, sample_quantiles) + geom_abline()

This QQ-Plot shows that the data from this data set is normally distributed.

Paired Sample \(t\)-Test

mu <-mean(BeerTable$Difference)
mu
## [1] 0.5035

\[H_0: d= 0\] \[H_a: d ≠ 0\]

t.test(BeerTable$After,BeerTable$Before, paired = TRUE, conf.level = 0.98)
## 
##  Paired t-test
## 
## data:  BeerTable$After and BeerTable$Before
## t = 2.6031, df = 19, p-value = 0.01747
## alternative hypothesis: true difference in means is not equal to 0
## 98 percent confidence interval:
##  0.01231381 0.99468619
## sample estimates:
## mean of the differences 
##                  0.5035

Based on this test, we can reject \(H_0\).

At 0.02 level of significance, there is enough evidence to conclude that on average, the difference in a persons reaction time does not equal 0 after drinking 2 beers

Confidence Interval for the Differences in Reaction Times.

t.test(BeerTable$Difference, conf.level = 0.98)
## 
##  One Sample t-test
## 
## data:  BeerTable$Difference
## t = 2.6031, df = 19, p-value = 0.01747
## alternative hypothesis: true mean is not equal to 0
## 98 percent confidence interval:
##  0.01231381 0.99468619
## sample estimates:
## mean of x 
##    0.5035

This is a 98% confidence interval for the reaction times. Just like the paired sample T-test, 0 is not in the interval.

Translating the Impact of Alcoholic Impairement into Real Terms

Based on these tests, we can conclude that the range for additional distance (in feet) that a driver will travel after only 2 beers is between 6 and 54 feet!