Introduction

In this report we compare the mpg of US and Japanese cars from: https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv

US <- c(
  18, 15, 18, 16, 17, 15, 14, 14, 14, 15,
  15, 14, 15, 14, 22, 18, 21, 21, 10, 10,
  11, 9, 28, 25, 19, 16, 17, 19, 18, 14,
  14, 14, 14, 12, 13
)

JP<- c(
  24, 27, 27, 25, 31, 35, 24, 19, 28, 23,
  27, 20, 22, 18, 20, 31, 32, 31, 32, 24,
  26, 29, 24, 24, 33, 33, 32, 28
)

1. Normal Probability Plots

par(mfrow = c(1, 2))

qqnorm(US, main = "US Cars")
qqline(US, col = "blue")

qqnorm(JP, main = "Japanese Cars")
qqline(JP, col = "red")

par(mfrow = c(1, 1))

We see that the Japanese data is approximately Normally distributed, while the US data show some variance from Normality in the upper tail.

2. Side-by-Side Boxplots

boxplot(US, JP,
        names = c("US", "Japan"),
        ylab = "mpg",
        main = "MPG of US and Japanese Cars",
        col = c("blue", "red"))

Here the Japanese cars have more spread, hence the variance does not appear completely constant.

3. Log Transformation

log_US <- log(US)
log_JP<- log(JP)
par(mfrow = c(1, 2))

qqnorm(log_US, main = "Log MPG: US Cars")
qqline(log_US, col = "blue")

qqnorm(log_JP, main = "Log MPG: Japanese Cars")
qqline(log_JP, col = "red")

par(mfrow = c(1, 1))
boxplot(log_US, log_JP,
        names = c("US", "Japan"),
        ylab = "log(mpg)",
        main = "Log MPG of US and Japanese Cars",
        col = c("blue", "red"))

After we do the log transformation, the US data appears more Normal and box widths are more similar.

4. Hypothesis Test

Let mu_US be the population mean log(mpg) for US cars, and let mu_JP be the population mean log(mpg) for Japanese cars.

Null hypothesis: H0: mu_US = mu_JP

Alternative hypothesis: Ha: mu_US < mu_JP

The significance level is 0.05.

Sample Averages

mean(log_US)
## [1] 2.741001
mean(log_JP)
## [1] 3.270957

Here the sample average log(mpg) is 2.7410 for US cars and 3.2710 for Japanese cars.

Pooled Two-Sample t-Test

t.test(log_US, log_JP,
       alternative = "less",
       var.equal = TRUE)
## 
##  Two Sample t-test
## 
## data:  log_US and log_JP
## 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

The test gives a p-value less than 0.05. Hence we reject the null hypothesis.

We can conclude with our evidence that the mean log(mpg) of US cars is less than the mean log(mpg) of Japanese cars.