Restaurant.df<-read.csv("AdvertisingDataV2.csv")
attach(Restaurant.df)

Frequency Table

table(adType,restaurantType)
##           restaurantType
## adType     chain independent
##   Curr Ads  4000        6000
##   New Ads   4000        6000
##   No Ads    4000        6000

Table describing data

library(psych)
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

Box-plots

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")

Mean Plots

library(gplots)
## 
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
## 
##     lowess
plotmeans(reservations ~ adType, data = Restaurant.df,
          xlab = "Ad Type", ylab = "No. of Reservations",digits = 2, col = "red",ccol = "green", barwidth = 2,legends = TRUE, mean.labels = TRUE, frame = TRUE)
## Warning in text.default(x, y, label = labels, col = col, ...): "frame" is
## not a graphical parameter
## Warning in arrows(x, li, x, pmax(y - gap, li), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped

## Warning in arrows(x, li, x, pmax(y - gap, li), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped

## Warning in arrows(x, li, x, pmax(y - gap, li), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
## Warning in arrows(x, ui, x, pmin(y + gap, ui), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped

## Warning in arrows(x, ui, x, pmin(y + gap, ui), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped

## Warning in arrows(x, ui, x, pmin(y + gap, ui), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "frame" is not a
## graphical parameter
## Warning in axis(1, at = 1:length(means), labels = legends, ...): "frame" is
## not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "frame" is not a
## graphical parameter

One-way ANOVA

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

As p<0.05, so we reject null hypothesis. Phonecalls are not same across all ad types

Checking ANOVA assumptions

Anderson Darling Normality Test
library(nortest)
ad.test(phoneCalls)
## 
##  Anderson-Darling normality test
## 
## data:  phoneCalls
## A = 172.76, p-value < 2.2e-16

As p<0.05, reject null hypohesis. We can’t assume normality.

Checking homogeneity of variance
library(car)
## Loading required package: carData
## 
## 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

As p<0.05, we reject null hypothesis. There is heterogeneity in variances of phone calls.

Pair wise comparison test value

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

One-way ANOVA

oneWayTransfit <- aov(log(phoneCalls) ~ adType, data = Restaurant.df)
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)