First Problem

We use Normal Probability Plots (NPP) to assess whether the MPG data for both US and Japanese cars follow a normal distribution. Substantial deviations from the reference line suggest departures from normality.

Second Problem

Side-by-side boxplots are used to visually compare the spread and variability of MPG between the two groups. Equal variance is indicated by similar box sizes and interquartile ranges.

Third Problem

After applying a log transformation to the MPG data, we reassess normality and variance using NPP and box plots. The log transformation often stabilizes variance and improves normality, making the data more suitable for parametric tests like t-tests.

Fourth Problem

a)

US Cars:    2.741001
Japan Cars: 3.270957
Difference: -0.5299558
t-statistic: -9.4828
p-value:     0
95% CI:     [ -Inf ,  -0.4366 ]

b)

The sample means of log(MPG) are 2.741 for US cars and 3.271 for Japanese cars, with a difference of -0.530. The two-sample t-test yields a t-statistic of -9.4828 with a p-value ≈ 0, which is far below the α = 0.05 significance level. Since the p-value < 0.05, we reject H₀ and conclude that US cars have significantly lower mean MPG than Japanese cars.

dat<-as.data.frame(read.csv('https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv'))

library(dplyr)
library(ggplot2)
US<-as.data.frame(dat[,1])
JP<-as.data.frame(dat[,2])

ggplot(US, aes(sample = US[,1])) + 
  stat_qq(color = "blue") +                              
  stat_qq_line()+
  labs(x = "Actual Data", y = "Expected", title = "US  Normal Probability Plot")


ggplot(JP, aes(sample = JP[,1])) + 
  stat_qq(color = "red") +                              
  stat_qq_line()+
  labs(x = "Actual Data", y = "Expected", title = "Japan  Normal Probability Plot")

boxplot(list(US[,1], JP[,1]), 
        names = c("US Cars", "Japanese Cars"),
        main = "Side by Side Boxplot: Original MPG",
        ylab = "MPG",
        col = c("blue", "red"))


logdat<-log(dat)
lus<-as.data.frame(logdat[,1])
ljp<-as.data.frame(logdat[,2])

ggplot(lus, aes(sample = lus[,1])) + 
  stat_qq(color = "blue") +                              
  stat_qq_line()+
  labs(x = "Actual Data", y = "Expected", title = "US  Normal Probability Plot Log Ver")


ggplot(ljp, aes(sample = ljp[,1])) + 
  stat_qq(color = "red") +                              
  stat_qq_line()+
  labs(x = "Actual Data", y = "Expected", title = "Japan  Normal Probability Plot Log Ver")

boxplot(list(lus[,1], ljp[,1]), 
        names = c("US Cars", "Japanese Cars"),
        main = "Side by Side Boxplot: Logarithm Ver",
        ylab = "MPG",
        col = c("blue", "red"))


result <- t.test(lus, ljp, alternative = "less", var.equal = TRUE,na.action = na.omit)

cat("US Cars:   ", mean(lus[,1]))
cat("Japan Cars:", mean(ljp[,1],, na.rm = TRUE))
cat("Difference:", mean(lus[,1]) - mean(ljp[,1], na.rm = TRUE))

cat("t-statistic:", round(result$statistic, 4))
cat("p-value:    ", round(result$p.value, 6))
cat("95% CI:     [", round(result$conf.int[1], 4), ", ", round(result$conf.int[2], 4),"]")