Restaurant.df<-read.csv("AdvertisingDataV2.csv")
View(Restaurant.df)
attach(Restaurant.df)
table(adType,restaurantType)
## restaurantType
## adType chain independent
## Curr Ads 4000 6000
## New Ads 4000 6000
## No Ads 4000 6000
library(psych)
## Warning: package 'psych' was built under R version 3.5.1
describe(Restaurant.df)
## vars n mean sd median trimmed mad min
## adType* 1 30000 2.00 0.82 2.0 2.00 1.48 1
## pageViews 2 30000 468.06 168.16 391.0 458.18 149.74 145
## phoneCalls 3 30000 37.71 7.97 37.0 37.20 7.41 17
## reservations 4 30000 36.55 7.99 36.0 35.97 7.41 15
## businessID 5 30000 15000.50 8660.40 15000.5 15000.50 11119.50 1
## restaurantType* 6 30000 1.60 0.49 2.0 1.62 0.00 1
## max range skew kurtosis se
## adType* 3 2 0.00 -1.50 0.00
## pageViews 929 784 0.45 -1.29 0.97
## phoneCalls 77 60 0.65 0.57 0.05
## reservations 79 64 0.78 0.88 0.05
## businessID 30000 29999 0.00 -1.20 50.00
## restaurantType* 2 1 -0.41 -1.83 0.00
boxplot(phoneCalls~adType, ylab="phonecalls", xlab="adtype", main= "Table 1")
boxplot(pageViews~adType, ylab="pageviews", xlab="adtype", main= "Table 2")
boxplot(reservations~adType, ylab="reservations", xlab="adtype", main= "Table 3")
boxplot(phoneCalls~restaurantType, ylab="phonecalls", xlab="restaurantType", main= "Table 4")
boxplot(pageViews~restaurantType, ylab="pageviews", xlab="restaurantType", main= "Table 5")
boxplot(reservations~restaurantType, ylab="reservations", xlab="restaurantType", main= "Table 6")
oneWayfit <- aov(phoneCalls~adType, data = Restaurant.df)
# summary of the ANOVA model
summary(oneWayfit)
## Df Sum Sq Mean Sq F value Pr(>F)
## adType 2 297584 148792 2780 <2e-16 ***
## Residuals 29997 1605692 54
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p<0.05, so we reject null hypothesis. Phonecalls are not same across all adtypes
library(nortest)
ad.test(phoneCalls)
##
## Anderson-Darling normality test
##
## data: phoneCalls
## A = 172.76, p-value < 2.2e-16
P< 0.05, reject null hypohesis. We can’t assume normality
library(car)
## Warning: package 'car' was built under R version 3.5.1
## Loading required package: carData
## Warning: package 'carData' was built under R version 3.5.1
##
## Attaching package: 'car'
## The following object is masked from 'package:psych':
##
## logit
leveneTest(phoneCalls ~ adType, data = Restaurant.df)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 79.125 < 2.2e-16 ***
## 29997
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p< 0.05, we reject null hypothesis. There is heterogeneity in variances of phone calls
library(car)
leveneTest(log(phoneCalls) ~ adType, data = Restaurant.df)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 31.254 2.759e-14 ***
## 29997
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwise.t.test(phoneCalls, adType, data = Restaurant.df,
p.adjust.method = "BH", pool.sd = FALSE)
##
## Pairwise comparisons using t tests with non-pooled SD
##
## data: phoneCalls and adType
##
## Curr Ads New Ads
## New Ads <2e-16 -
## No Ads <2e-16 <2e-16
##
## P value adjustment method: BH
oneWayTransfit <- aov(log(phoneCalls) ~ adType, data = Restaurant.df)
# summary of the ANOVA model
summary(oneWayTransfit)
## Df Sum Sq Mean Sq F value Pr(>F)
## adType 2 209.9 104.93 2887 <2e-16 ***
## Residuals 29997 1090.0 0.04
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(oneWayfit,2)
plot(oneWayTransfit,2)
plot(oneWayfit,1)
plot(oneWayTransfit,1)