1 Introduction

This report documents the testing of data about the fuel efficiency of cars manufactured in Japan versus data from cars manufactured in the United States. Both data sets are assumed to be random samples.

Does the mpg of both US cars and Japanese cars appear to be Normally distributed? This is investigated using normal probability plots.

df <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv")
USA <- df$USCars
JAPAN <- df$JapaneseCars

qqnorm(USA, main = "Normal probability plot of the MPG of cars made in the USA  ", xlab = "Theoretical Quantiles ", ylab = "MPG of cars made in the USA ", col = "blue")
qqline(USA)

It can be concluded that the data collected from the USA cars is approximately normal because the normal probability plot is approximately linear.

qqnorm(df$JapaneseCars, main = "Normal probability plot of the MPG of cars made in Japan  ", xlab = "Theoretical Quantiles ", ylab = "MPG of cars made in the Japan ", col = "blue")
qqline(JAPAN)

It can be concluded that the data collected from the Japanese cars is approximately normal because the normal probability plot is approximately linear.

boxplot(df$USCars,df$JapaneseCars, names = c("USA", "Japan"), col = c("blue","pink"), main = "Box plot of mpg: USA vs Japan", ylab = "MPG")

The Variation of the two data sets can not be assumed to be constant. The mpg data from the USA cars have a much smaller variance then the mpg data from the Japanese cars. This rules out a pooled T test until the data can be transformed and the variance can be equal.

USAlog<- log(USA)
JAPANlog<- log(JAPAN)
qqnorm(USAlog, main = "Normal probability plot of the log \n of the data from MPG of cars made in the USA  ", xlab = "Theoretical Quantiles ", ylab = "log of MPG of cars made in the USA ", col = "blue")
qqline(USAlog)

It can be concluded that the log of the data collected from the USA cars is approximately normal because the normal probability plot is approximately linear.

qqnorm(JAPANlog, main = "Normal probability plot of the log of\nthe data from the MPG of cars made in Japan  ", xlab = "Theoretical Quantiles ", ylab = "MPG of cars made in the Japan ", col = "blue")
qqline(JAPANlog)

It can be concluded that the log of the data collected from the Japanese cars is approximately normal because the normal probability plot is approximately linear.

boxplot(USAlog,JAPANlog, names = c("USA", "Japan"), col = c("blue","pink"), main = "Box plot of  log of mpg:\nUSA vs Japan", ylab = "MPG")

The Variation of the two data sets can be assumed to be constant. The log of the mpg data from the USA cars have a similar variance to the log of the mpg data from the Japanese cars. This allows for a pooled T test to be done to compare the means of the data.

2 Pooled T Test

A pooled T test assumes the variances of the two indpendent populations are approximately equal. In a pooled T test it is also assumed that the assumption of the distribution of the independent populations are approximately normal.

\[ H_{0}: \mu_{1} = \mu_{2} \] \[ H_{a}: \mu_{1} < \mu_{2} \] \[ \alpha = 0.05 \]

t.test(USAlog,JAPANlog,alternative="less", var.equal=TRUE)
## 
##  Two Sample t-test
## 
## data:  USAlog and JAPANlog
## 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 sample averages for the log of the USA data is 2.741 mpg and the sample averages for the log of the Japanese data is 3.271 mpg.

In conclusion, the p-value is less than the a=0.05 so we reject the null hypothesis and go with the alternate hypothesis. We have sufficient evidence that the mean MPG of the cars made in the USA is less then the mean MPG of the cars made in Japan.

3 Complete R Code

knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message = FALSE) 
df <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv")
USA <- df$USCars
JAPAN <- df$JapaneseCars

qqnorm(USA, main = "Normal probability plot of the MPG of cars made in the USA  ", xlab = "Theoretical Quantiles ", ylab = "MPG of cars made in the USA ", col = "blue")
qqline(USA)
qqnorm(df$JapaneseCars, main = "Normal probability plot of the MPG of cars made in Japan  ", xlab = "Theoretical Quantiles ", ylab = "MPG of cars made in the Japan ", col = "blue")
qqline(JAPAN)
boxplot(df$USCars,df$JapaneseCars, names = c("USA", "Japan"), col = c("blue","pink"), main = "Box plot of mpg: USA vs Japan", ylab = "MPG")
USAlog<- log(USA)
JAPANlog<- log(JAPAN)
qqnorm(USAlog, main = "Normal probability plot of the log \n of the data from MPG of cars made in the USA  ", xlab = "Theoretical Quantiles ", ylab = "log of MPG of cars made in the USA ", col = "blue")
qqline(USAlog)
qqnorm(JAPANlog, main = "Normal probability plot of the log of\nthe data from the MPG of cars made in Japan  ", xlab = "Theoretical Quantiles ", ylab = "MPG of cars made in the Japan ", col = "blue")
qqline(JAPANlog)
boxplot(USAlog,JAPANlog, names = c("USA", "Japan"), col = c("blue","pink"), main = "Box plot of  log of mpg:\nUSA vs Japan", ylab = "MPG")
t.test(USAlog,JAPANlog,alternative="less", var.equal=TRUE)