dat <- read.csv('https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv')
dat
## USCars JapaneseCars
## 1 18 24
## 2 15 27
## 3 18 27
## 4 16 25
## 5 17 31
## 6 15 35
## 7 14 24
## 8 14 19
## 9 14 28
## 10 15 23
## 11 15 27
## 12 14 20
## 13 15 22
## 14 14 18
## 15 22 20
## 16 18 31
## 17 21 32
## 18 21 31
## 19 10 32
## 20 10 24
## 21 11 26
## 22 9 29
## 23 28 24
## 24 25 24
## 25 19 33
## 26 16 33
## 27 17 32
## 28 19 28
## 29 18 NA
## 30 14 NA
## 31 14 NA
## 32 14 NA
## 33 14 NA
## 34 12 NA
## 35 13 NA
uscar <- dat[,1]
uscar
## [1] 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
## [26] 16 17 19 18 14 14 14 14 12 13
jpcar <- dat[1:28,2]
jpcar
## [1] 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
## [26] 33 32 28
##US CARS Distribution Plot
qqnorm(uscar, main = 'US Car Q_Q Plot', col ='blue')
qqnorm(jpcar, main = 'Japanes Car Q_Q Plot', col= 'red' )
#2 Check Variance
boxplot(uscar, jpcar, main='Box Plot For US Car and Japanese Car', col=c('blue','red'))
comment: The plot clearly shows that the vraiance appear is not constant
#3 Apply Log Transformations
lus <- log(uscar)
ljp <- log(jpcar)
qqnorm(lus, main = 'Log US Car Q_Q Plot', col='blue')
Comment: tend lay about straight line normality ## After Log conversion fo Japanese car QQ Normal Plot
qqnorm(ljp, main = 'Log Japanease Car Q_Q Plot', col='red')
Comment: tend lay about straight line normality
#Box Plot after Log conversion of US Car and Japanese Car
boxplot(lus, ljp, main='Log Coversion Box Plot For US Car and Japanese Car', names =c("US Car", "Japanese Car"), col=c('blue', 'red'))
comment: variance is most closer after the log transformation #4. Hypothesis Test - \(H_0:\mu_{\text{UScars}} = \mu_{\test{JPCars}}\) - \(H_a:\mu_{\text{UScars}} < \mu_{\test{JPCars}}\)
#Apply Two Sample T- Test
t.test(x= lus, y = ljp,
alternative = c("less"),
mu = 0, paired = FALSE, var.equal = TRUE)
##
## Two Sample t-test
##
## data: lus and ljp
## 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
About the P value is is than 0, we can reject the Null Hypothesis, The Sample mean of US Cars is 2.74 and Japanease Car 3.27
#Conclusions:
US car has less MPG than Japanease Car Following the normal distribution, befor log transformation variance of the sample are different, Some outliars observe in US car samples
#Load Data
dat <- read.csv('https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv')
dat
#Observing Datas US and Japanese Car
uscar <- dat[,1]
uscar
jpcar <- dat[1:28,2]
jpcar
#Check Normal Distribution of US and Japanese Car
qqnorm(uscar, main = 'US Car Q_Q Plot', col ='blue')
qqnorm(jpcar, main = 'Japanes Car Q_Q Plot', col= 'red' )
#Check Variances using Box Plot
boxplot(uscar, jpcar, main='Box Plot For US Car and Japanese Car', col=c('blue','red'))
#Apply Log Transformations
lus <- log(uscar)
ljp <- log(jpcar)
#Check Normal Distribution After Log Conversion
qqnorm(lus, main = 'Log US Car Q_Q Plot', col='blue')
qqnorm(ljp, main = 'Log Japanease Car Q_Q Plot', col='red')
#check variance after log transformation
boxplot(lus, ljp, main='Log Coversion Box Plot For US Car and Japanese Car', names =c("US Car", "Japanese Car"), col=c('blue', 'red'))
#Apply Two Sample T-tes
t.test(x= lus, y = ljp,
alternative = c("less"),
mu = 0, paired = FALSE, var.equal = TRUE)