data <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv")
head(data)
##   USCars JapaneseCars
## 1     18           24
## 2     15           27
## 3     18           27
## 4     16           25
## 5     17           31
## 6     15           35
dim(data)
## [1] 35  2
qqnorm(data$USCars)
qqline(data$USCars)

qqnorm(data$JapaneseCars)
qqline(data$JapaneseCars)

summary(data)
##      USCars       JapaneseCars  
##  Min.   : 9.00   Min.   :18.00  
##  1st Qu.:14.00   1st Qu.:24.00  
##  Median :15.00   Median :27.00  
##  Mean   :15.97   Mean   :26.75  
##  3rd Qu.:18.00   3rd Qu.:31.00  
##  Max.   :28.00   Max.   :35.00  
##                  NAs    :7

A1. Both group appear to be approximately normally distributed, with the japanese cars showing a slightly better fit to the reference line.

boxplot(data$USCars, data$JapaneseCars, names = c("US","Japan"))

A2. The variances do not appear to be equal, as the Japanese cars show greater variability than the US cars.

logUS <- log(data$USCars)

logJapan <- log(data$JapaneseCars)

qqnorm(logUS)
qqline(logUS)

qqnorm(logJapan)
qqline(logJapan)

boxplot(logUS, logJapan, names = c("US","Japan"))

A3. The log transformation slightly changed the distribution of the US car data, while the Japanese car data remained approximately normal. The variability between the two groups also became more comparable.

t.test(logUS,
       logJapan,
       alternative = "less",
       var.equal = TRUE
       )
## 
##  Two Sample t-test
## 
## data:  logUS and logJapan
## t = -9.4828, df = 61, p-value = 6.528e-14
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
##        -Inf -0.4366143
## sample estimates:
## mean of x mean of y 
##  2.741001  3.270957

A4-a. The sample average of log-transformed mpg values of US cars is 2.74, while the sample average for Japanese cars is 3.27. Therfore the average log(mpg) is higher for Japanese cars than for US cars

A4-b. The p-value is less than 0.05, so we reject the null hypothesis. There is sufficient evidence to conclude that the mean mpg of US car is lower than that of Japanese cars.