READING THE DATA
df<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv")
str(df)
## 'data.frame': 35 obs. of 2 variables:
## $ USCars : int 18 15 18 16 17 15 14 14 14 15 ...
## $ JapaneseCars: int 24 27 27 25 31 35 24 19 28 23 ...
Taking data of US cars and Japanese cars
df1<-(df$USCars)
df2<-(df$JapaneseCars)
qqnorm(df1,main="NPP of US cars")
qqline(df1)
qqnorm(df2,main="NPP of Japanese cars")
qqline(df2)
Boxplot of the US cars and Japoanese cars
boxplot(df1,df2, names = c("USCars","JapaneseCars"), main= "Boxplot of US and Japanese cars")
As the median does seem close, we tranforming the data into log.
data_log_Us<-log(df1)
data_log_Japanese<-log(df2)
qqnorm(data_log_Us,main = "log of NPP of US cars")
qqline(data_log_Us)
qqnorm(data_log_Japanese, main = "log of NPP of Japanese cars")
qqline(data_log_Japanese)
boxplot(data_log_Us,data_log_Japanese, names = c("Uscars","Japanesecars"),main="boxplot of transfprmed data")
t.test(data_log_Us,data_log_Japanese,var.equal=TRUE)
##
## Two Sample t-test
##
## data: data_log_Us and data_log_Japanese
## t = -9.4828, df = 61, p-value = 1.306e-13
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.6417062 -0.4182053
## sample estimates:
## mean of x mean of y
## 2.741001 3.270957
mean(data_log_Us)
## [1] 2.741001
data_log_Japanese1<-data_log_Japanese[1:28]
mean(data_log_Japanese1)
## [1] 3.270957
Conclusion, Null Hypothesis is failed to Reject because the p.value is greater than 0.05.
#R Complete Code
df<- read.csv(“https://raw.githubusercontent.com/tmatis12/datafiles/main/US_Japanese_Cars.csv”)
str(df)
df1<-(df$USCars)
df2<-(df$JapaneseCars)
length(df1)
length(df2)
data<-data.frame(df1,df2)
qqnorm(df1,main=“NPP of US cars”)
qqline(df1)
qqnorm(df2,main=“NPP of Japaneese cars”)
qqline(df2)
boxplot(df1,df2,names=c(“USCars”,“JapaneseCars”),main = “Box Plot of US and Japaneese Cars” )
##Log Transformation
data_log_US<-log(df1)
data_log_Japaneese<-log(df2)
qqnorm(data_log_US,main=“Log NPP of US cars”)
qqline(data_log_US)
qqnorm(data_log_Japaneese,main=“Log NPP of Japaneese cars”)
qqline(data_log_Japaneese)
#boxplot after log Transformation
boxplot(data_log_US,data_log_Japaneese,names=c(“USCars”,“JapaneseCars”),main = “Log Box Plot of US and Japaneese Cars” )
?t.test
t.test(data_log_US,data_log_Japaneese1,var.equal = TRUE)
#Sample Mean
mean(data_log_US)
data_log_Japaneese1<-data_log_Japaneese[1:28]
mean(data_log_Japaneese1)