This analysis compares the fuel efficiency of cars manufactured in the US and Japan.
dat <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv")
US <- na.omit(dat$USCars)
Japan <- na.omit(dat$JapaneseCars)
length(US)
## [1] 35
length(Japan)
## [1] 28
There are 35 observations for US cars and 28 observations for Japanese cars.
qqnorm(US,
main="Normal Probability Plot - US Cars")
qqline(US)
qqnorm(Japan,
main="Normal Probability Plot - Japanese Cars")
qqline(Japan)
The normal probability plots show some departures from a straight line. Therefore, the original MPG data do not appear to follow normal distributions particularly well.
boxplot(US, Japan,
names=c("US Cars","Japanese Cars"),
main="MPG: US vs Japanese Cars",
ylab="MPG")
The side-by-side boxplots show differences in both the centers and spreads of the two samples. The Japanese cars generally have higher MPG values. The spreads also appear somewhat different, so the constant variance assumption is questionable for the original data.
logUS <- log(US)
logJapan <- log(Japan)
qqnorm(logUS,
main="Normal Probability Plot - Log MPG of US Cars")
qqline(logUS)
qqnorm(logJapan,
main="Normal Probability Plot - Log MPG of Japanese Cars")
qqline(logJapan)
boxplot(logUS, logJapan,
names=c("US Cars","Japanese Cars"),
main="Log MPG: US vs Japanese Cars",
ylab="Log(MPG)")
After applying the log transformation, the observations in the normal probability plots are more consistent with approximately normal distributions. The transformation also makes the spreads of the two groups more comparable. Therefore, the log-transformed data are used for the remaining analysis.
The hypotheses are:
\(H_0: \mu_{US} = \mu_{Japan}\)
\(H_a: \mu_{US} < \mu_{Japan}\)
where the means refer to the population means of log MPG.
mean(logUS)
## [1] 2.741001
mean(logJapan)
## [1] 3.270957
The values above are the sample averages of the log MPG for US and Japanese cars.
test <- t.test(logUS, logJapan,
alternative="less",
var.equal=TRUE)
test
##
## 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
The test uses a significance level of 0.05. If the p-value is less than 0.05, the null hypothesis is rejected.
Based on the test result, the p-value is below 0.05. Therefore, we reject the null hypothesis. There is statistically significant evidence at the 0.05 significance level that the mean log MPG of US-manufactured cars is less than the mean log MPG of Japanese-manufactured cars.
dat <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv")
US <- na.omit(dat$USCars)
Japan <- na.omit(dat$JapaneseCars)
length(US)
length(Japan)
qqnorm(US, main="Normal Probability Plot - US Cars")
qqline(US)
qqnorm(Japan, main="Normal Probability Plot - Japanese Cars")
qqline(Japan)
boxplot(US, Japan,
names=c("US Cars","Japanese Cars"),
main="MPG: US vs Japanese Cars",
ylab="MPG")
logUS <- log(US)
logJapan <- log(Japan)
qqnorm(logUS,
main="Normal Probability Plot - Log MPG of US Cars")
qqline(logUS)
qqnorm(logJapan,
main="Normal Probability Plot - Log MPG of Japanese Cars")
qqline(logJapan)
boxplot(logUS, logJapan,
names=c("US Cars","Japanese Cars"),
main="Log MPG: US vs Japanese Cars",
ylab="Log(MPG)")
mean(logUS)
mean(logJapan)
test <- t.test(logUS, logJapan,
alternative="less",
var.equal=TRUE)
test