library(psych)
library(corrplot)
## corrplot 0.84 loaded
setwd("d:/IIML/Term 5/DAM/")
df<-read.csv("SubAdvData.csv")
addmargins(table(df$adType,df$restaurantType),margin = c(1,2))
##           
##            chain independent   Sum
##   Curr Ads  2023        2972  4995
##   New Ads   1958        3010  4968
##   No Ads    2003        3034  5037
##   Sum       5984        9016 15000
round(prop.table(table(df$adType,df$restaurantType)),2)
##           
##            chain independent
##   Curr Ads  0.13        0.20
##   New Ads   0.13        0.20
##   No Ads    0.13        0.20
aggregate(df$reservations,by=list(df$restaurantType),mean)
##       Group.1        x
## 1       chain 42.58205
## 2 independent 32.50688
aggregate(df$reservations,by=list(df$adType),mean)
##    Group.1        x
## 1 Curr Ads 34.03283
## 2  New Ads 41.62762
## 3   No Ads 33.96724
cor(df$reservations,df$phoneCalls)
## [1] 0.6516813
cor.test(df$reservations,df$phoneCalls,method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  df$reservations and df$phoneCalls
## t = 105.22, df = 14998, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.6423774 0.6607932
## sample estimates:
##       cor 
## 0.6516813
prop.test(x=4995,n=15000,p=0.4,correct = F)
## 
##  1-sample proportions test without continuity correction
## 
## data:  4995 out of 15000, null probability 0.4
## X-squared = 280.56, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is not equal to 0.4
## 95 percent confidence interval:
##  0.3255016 0.3405839
## sample estimates:
##     p 
## 0.333
mean(df$reservations)
## [1] 36.5262
s1=subset(df,restaurantType=="chain",select=reservations)
s2=subset(df,restaurantType=="independent",select=reservations)
t.test(s1,s2,var.equal = T)
## 
##  Two Sample t-test
## 
## data:  s1 and s2
## t = 97.503, df = 14998, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##   9.872633 10.277718
## sample estimates:
## mean of x mean of y 
##  42.58205  32.50688