Part 1: Read the data..
# reading external data and storing into a dataframe called "airline.df"
df <- read.csv("AdvertisingDataV2.csv")
Part 2: Column names
# Display the column names
colnames(df)
## [1] "adType" "pageViews" "phoneCalls" "reservations"
## [5] "businessID" "restaurantType"
Part 3: Data Dimensions
# Display the Data Dimensions
dim(df)
## [1] 30000 6
Part 4: One way anova
# Compute the analysis of variance
res.aov <- aov(reservations ~ adType, data = df)
# Summary of the analysis
summary(res.aov)
## Df Sum Sq Mean Sq F value Pr(>F)
## adType 2 394228 197114 3885 <2e-16 ***
## Residuals 29997 1522018 51
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# multiple pairwise-comparison using TukeyHSD
TukeyHSD(res.aov)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = reservations ~ adType, data = df)
##
## $adType
## diff lwr upr p adj
## New Ads-Curr Ads 7.6593 7.4232043 7.8953957 0.0000000
## No Ads-Curr Ads -0.0608 -0.2968957 0.1752957 0.8181708
## No Ads-New Ads -7.7201 -7.9561957 -7.4840043 0.0000000
Part 5: Two way anova
# two-way ANOVA test
res.aov2 <- aov(reservations ~ adType + restaurantType + adType:restaurantType,
data = df)
summary(res.aov2)
## Df Sum Sq Mean Sq F value Pr(>F)
## adType 2 394228 197114 7658.285 < 2e-16 ***
## restaurantType 1 749570 749570 29122.292 < 2e-16 ***
## adType:restaurantType 2 442 221 8.594 0.000186 ***
## Residuals 29994 772006 26
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# multiple pairwise-comparison using TukeyHSD
TukeyHSD(res.aov2)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = reservations ~ adType + restaurantType + adType:restaurantType, data = df)
##
## $adType
## diff lwr upr p adj
## New Ads-Curr Ads 7.6593 7.4911448 7.8274552 0.0000000
## No Ads-Curr Ads -0.0608 -0.2289552 0.1073552 0.6734651
## No Ads-New Ads -7.7201 -7.8882552 -7.5519448 0.0000000
##
## $restaurantType
## diff lwr upr p adj
## independent-chain -10.20328 -10.32046 -10.08609 0
##
## $`adType:restaurantType`
## diff lwr
## New Ads:chain-Curr Ads:chain 7.901000 7.5777205
## No Ads:chain-Curr Ads:chain -0.176000 -0.4992795
## Curr Ads:independent-Curr Ads:chain -10.133000 -10.4281125
## New Ads:independent-Curr Ads:chain -2.634833 -2.9299458
## No Ads:independent-Curr Ads:chain -10.117000 -10.4121125
## No Ads:chain-New Ads:chain -8.077000 -8.4002795
## Curr Ads:independent-New Ads:chain -18.034000 -18.3291125
## New Ads:independent-New Ads:chain -10.535833 -10.8309458
## No Ads:independent-New Ads:chain -18.018000 -18.3131125
## Curr Ads:independent-No Ads:chain -9.957000 -10.2521125
## New Ads:independent-No Ads:chain -2.458833 -2.7539458
## No Ads:independent-No Ads:chain -9.941000 -10.2361125
## New Ads:independent-Curr Ads:independent 7.498167 7.2342101
## No Ads:independent-Curr Ads:independent 0.016000 -0.2479566
## No Ads:independent-New Ads:independent -7.482167 -7.7461233
## upr p adj
## New Ads:chain-Curr Ads:chain 8.2242795 0.0000000
## No Ads:chain-Curr Ads:chain 0.1472795 0.6307226
## Curr Ads:independent-Curr Ads:chain -9.8378875 0.0000000
## New Ads:independent-Curr Ads:chain -2.3397209 0.0000000
## No Ads:independent-Curr Ads:chain -9.8218875 0.0000000
## No Ads:chain-New Ads:chain -7.7537205 0.0000000
## Curr Ads:independent-New Ads:chain -17.7388875 0.0000000
## New Ads:independent-New Ads:chain -10.2407209 0.0000000
## No Ads:independent-New Ads:chain -17.7228875 0.0000000
## Curr Ads:independent-No Ads:chain -9.6618875 0.0000000
## New Ads:independent-No Ads:chain -2.1637209 0.0000000
## No Ads:independent-No Ads:chain -9.6458875 0.0000000
## New Ads:independent-Curr Ads:independent 7.7621233 0.0000000
## No Ads:independent-Curr Ads:independent 0.2799566 0.9999788
## No Ads:independent-New Ads:independent -7.2182101 0.0000000