Load Data

cars<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv")

1. Normal Probability Plots

qqnorm(cars$US,main="NPP of US Cars")
qqline(cars$US)

qqnorm(cars$Japan,main="NPP of Japanese Cars")
qqline(cars$Japan)

The mpg of both US cars and Japanese cars appear to be approximately Normally distributed, with minor deviations near the tails.

2. Boxplots

boxplot(cars$US,cars$Japan,names=c("US","Japan"),ylab="MPG",main="MPG of US and Japanese Cars")

The boxplots show that the Japanese car mpg values have greater spread than the US car mpg values. There also appear to be two potential outliers in the US car data. Therefore, the variance does not appear to be constant.

3. Transformation

logUS<-log(cars$US[1:35])
logJapan<-log(cars$Japan[1:28])

NPPs after Transformation

qqnorm(logUS,main="NPP of Log(US MPG)")
qqline(logUS)

qqnorm(logJapan,main="NPP of Log(Japanese MPG)")
qqline(logJapan)

Boxplots after Transformation

boxplot(logUS,logJapan,names=c("US","Japan"),ylab="Log(MPG)",main="Log(MPG of US and Japanese Cars)")

After transformation, the points in the NPPs follow the reference lines more closely. The boxplots also show more comparable spreads. Therefore, the log transformation improves the Normality and constant variance assumptions.

4. Hypothesis Test

\[H_0: \mu_{US} = \mu_{Japan}\] \[H_a: \mu_{US} < \mu_{Japan}\] The level of significance is \(\alpha = 0.05\).

4a. Sample Averages

mean(logUS)
## [1] 2.741001
mean(logJapan)
## [1] 3.270957

The sample average of log(MPG) is approximately 2.741 for US cars and 3.271 for Japanese cars.

Two-Sample t-Test Pooled Variance

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

4. Conclusion

Since p-value = 6.528e-14 is less than alpha = 0.05, reject the null hypothesis. There is sufficient evidence to conclude that the mean log(MPG) of US cars is less than the mean log(MPG) of Japanese cars.

Complete R Code

cars<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv")

qqnorm(cars$US,main="NPP of US Cars")
qqline(cars$US)

qqnorm(cars$Japan,main="NPP of Japanese Cars")
qqline(cars$Japan)

boxplot(cars$US,cars$Japan,names=c("US","Japan"),ylab="MPG",main="MPG of US and Japanese Cars")

logUS<-log(cars$US[1:35])
logJapan<-log(cars$Japan[1:28])

qqnorm(logUS,main="NPP of Log(US MPG)")
qqline(logUS)

qqnorm(logJapan,main="NPP of Log(Japanese MPG)")
qqline(logJapan)

boxplot(logUS,logJapan,names=c("US","Japan"),ylab="Log(MPG)",main="Log(MPG of US and Japanese Cars)")

mean(logUS)
mean(logJapan)

t.test(logUS,logJapan,alternative="less",var.equal=TRUE)