Quickly analyze test market campaigns and promotions based on sales, locations and other key metrics. Predict which customers will respond to which campaign by which channel and why. Increase the likelihood of responses and quality of leads in future campaigns.
A fast food chain plans to add a new item to its menu. However, they are still undecided between three possible marketing campaigns for promoting the new product. In order to determine which promotion has the greatest effect on sales, the new item is introduced at locations in several randomly selected markets. A different promotion is used at each location, and the weekly sales of the new item are recorded for the first four weeks.
A. READING DATASET
Project.df <- read.csv(paste("file:///C:/Users/hp/Desktop/IIML/My Project files/real project/marketing campaign/WA_Fn-UseC_-Marketing-Campaign-Eff-UseC_-FastF.csv", sep=""))
attach(Project.df)
dim(Project.df)
## [1] 548 7
548 Rows and 7 columns
B. Dividing the tabe into important data set
Promotion1.df <- Project.df[which(Project.df$Promotion == 1), ]
Promotion2.df <- Project.df[which(Promotion == 2), ]
Promotion3.df <- Project.df[which(Promotion == 3), ]
Week1.df <- Project.df[which(Week == 1), ]
Week2.df <- Project.df[which(Week == 2), ]
Week3.df <- Project.df[which(Week == 3), ]
Week4.df <- Project.df[which(Week == 4), ]
Small.df <- Project.df[which(MarketSize == "Small"), ]
Medium.df <- Project.df[which(MarketSize == "Medium"), ]
Large.df <- Project.df[which(MarketSize == "Large"), ]
View(Project.df)
str(Project.df)
## 'data.frame': 548 obs. of 7 variables:
## $ ï..MarketID : int 1 1 1 1 1 1 1 1 1 1 ...
## $ MarketSize : Factor w/ 3 levels "Large","Medium",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ LocationID : int 1 1 1 1 2 2 2 2 3 3 ...
## $ AgeOfStore : int 4 4 4 4 5 5 5 5 12 12 ...
## $ Promotion : int 3 3 3 3 2 2 2 2 1 1 ...
## $ Week : int 1 2 3 4 1 2 3 4 1 2 ...
## $ SalesInThousands: num 33.7 35.7 29 39.2 27.8 ...
library(psych)
## Warning: package 'psych' was built under R version 3.3.3
describe(Project.df)
## vars n mean sd median trimmed mad min max
## ï..MarketID 1 548 5.72 2.88 6.0 5.76 4.45 1.00 10.00
## MarketSize* 2 548 1.80 0.61 2.0 1.75 0.00 1.00 3.00
## LocationID 3 548 479.66 287.97 504.0 483.96 421.06 1.00 920.00
## AgeOfStore 4 548 8.50 6.64 7.0 7.63 5.93 1.00 28.00
## Promotion 5 548 2.03 0.81 2.0 2.04 1.48 1.00 3.00
## Week 6 548 2.50 1.12 2.5 2.50 1.48 1.00 4.00
## SalesInThousands 7 548 53.47 16.76 50.2 52.02 12.76 17.34 99.65
## range skew kurtosis se
## ï..MarketID 9.00 -0.02 -1.18 0.12
## MarketSize* 2.00 0.14 -0.53 0.03
## LocationID 919.00 -0.02 -1.16 12.30
## AgeOfStore 27.00 1.04 0.35 0.28
## Promotion 2.00 -0.05 -1.48 0.03
## Week 3.00 0.00 -1.37 0.05
## SalesInThousands 82.31 0.80 0.14 0.72
mytable <- with(Project.df, table(ï..MarketID))
mytable
## ï..MarketID
## 1 2 3 4 5 6 7 8 9 10
## 52 24 88 36 60 60 60 48 40 80
mytable <- with(Project.df, table(MarketSize))
mytable
## MarketSize
## Large Medium Small
## 168 320 60
mytable <- with(Project.df, table(LocationID))
mytable
## LocationID
## 1 2 3 4 5 6 7 8 9 10 11 12 13 101 102 103 104 105
## 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
## 106 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
## 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
## 218 219 220 221 222 301 302 303 304 305 306 307 308 309 401 402 403 404
## 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
## 405 406 407 408 409 410 411 412 413 414 415 501 502 503 504 505 506 507
## 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
## 508 509 510 511 512 513 514 515 601 602 603 604 605 606 607 608 609 610
## 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
## 611 612 613 614 615 701 702 703 704 705 706 707 708 709 710 711 712 801
## 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
## 802 803 804 805 806 807 808 809 810 901 902 903 904 905 906 907 908 909
## 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
## 910 911 912 913 914 915 916 917 918 919 920
## 4 4 4 4 4 4 4 4 4 4 4
mytable <- with(Project.df, table(AgeOfStore))
mytable
## AgeOfStore
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 18 19 20 22 23 24 25 27 28
## 80 20 32 44 44 36 40 40 28 24 16 24 20 12 8 4 8 20 4 12 8 12 4 4 4
par(mfrow = c(1,2))
boxplot(Project.df$AgeOfStore, main = "AgeofStore")
count <- table(Project.df$AgeOfStore)
barplot(count, main = "age of store" , col = "Blue")
mean(Project.df$AgeOfStore)
## [1] 8.50365
median(Project.df$AgeOfStore)
## [1] 7
sd(Project.df$AgeOfStore)
## [1] 6.638345
mytable <- with(Project.df, table(Project.df$Promotion))
mytable
##
## 1 2 3
## 172 188 188
par(mfrow = c(1,2))
boxplot(Project.df$SalesInThousands, main = "Sales" , col = "yellow")
hist(Project.df$SalesInThousands, main = "sales" , col = "red")
mean(Project.df$SalesInThousands)
## [1] 53.4662
median(Project.df$SalesInThousands)
## [1] 50.2
sd(Project.df$SalesInThousands)
## [1] 16.75522
mytable <- xtabs(~ LocationID + MarketSize,)
mytable
## MarketSize
## LocationID Large Medium Small
## 1 0 4 0
## 2 0 4 0
## 3 0 4 0
## 4 0 4 0
## 5 0 4 0
## 6 0 4 0
## 7 0 4 0
## 8 0 4 0
## 9 0 4 0
## 10 0 4 0
## 11 0 4 0
## 12 0 4 0
## 13 0 4 0
## 101 0 0 4
## 102 0 0 4
## 103 0 0 4
## 104 0 0 4
## 105 0 0 4
## 106 0 0 4
## 201 4 0 0
## 202 4 0 0
## 203 4 0 0
## 204 4 0 0
## 205 4 0 0
## 206 4 0 0
## 207 4 0 0
## 208 4 0 0
## 209 4 0 0
## 210 4 0 0
## 211 4 0 0
## 212 4 0 0
## 213 4 0 0
## 214 4 0 0
## 215 4 0 0
## 216 4 0 0
## 217 4 0 0
## 218 4 0 0
## 219 4 0 0
## 220 4 0 0
## 221 4 0 0
## 222 4 0 0
## 301 0 0 4
## 302 0 0 4
## 303 0 0 4
## 304 0 0 4
## 305 0 0 4
## 306 0 0 4
## 307 0 0 4
## 308 0 0 4
## 309 0 0 4
## 401 0 4 0
## 402 0 4 0
## 403 0 4 0
## 404 0 4 0
## 405 0 4 0
## 406 0 4 0
## 407 0 4 0
## 408 0 4 0
## 409 0 4 0
## 410 0 4 0
## 411 0 4 0
## 412 0 4 0
## 413 0 4 0
## 414 0 4 0
## 415 0 4 0
## 501 0 4 0
## 502 0 4 0
## 503 0 4 0
## 504 0 4 0
## 505 0 4 0
## 506 0 4 0
## 507 0 4 0
## 508 0 4 0
## 509 0 4 0
## 510 0 4 0
## 511 0 4 0
## 512 0 4 0
## 513 0 4 0
## 514 0 4 0
## 515 0 4 0
## 601 0 4 0
## 602 0 4 0
## 603 0 4 0
## 604 0 4 0
## 605 0 4 0
## 606 0 4 0
## 607 0 4 0
## 608 0 4 0
## 609 0 4 0
## 610 0 4 0
## 611 0 4 0
## 612 0 4 0
## 613 0 4 0
## 614 0 4 0
## 615 0 4 0
## 701 0 4 0
## 702 0 4 0
## 703 0 4 0
## 704 0 4 0
## 705 0 4 0
## 706 0 4 0
## 707 0 4 0
## 708 0 4 0
## 709 0 4 0
## 710 0 4 0
## 711 0 4 0
## 712 0 4 0
## 801 0 4 0
## 802 0 4 0
## 803 0 4 0
## 804 0 4 0
## 805 0 4 0
## 806 0 4 0
## 807 0 4 0
## 808 0 4 0
## 809 0 4 0
## 810 0 4 0
## 901 4 0 0
## 902 4 0 0
## 903 4 0 0
## 904 4 0 0
## 905 4 0 0
## 906 4 0 0
## 907 4 0 0
## 908 4 0 0
## 909 4 0 0
## 910 4 0 0
## 911 4 0 0
## 912 4 0 0
## 913 4 0 0
## 914 4 0 0
## 915 4 0 0
## 916 4 0 0
## 917 4 0 0
## 918 4 0 0
## 919 4 0 0
## 920 4 0 0
chisq.test(mytable)
## Warning in chisq.test(mytable): Chi-squared approximation may be incorrect
##
## Pearson's Chi-squared test
##
## data: mytable
## X-squared = 1096, df = 272, p-value < 2.2e-16
Market size is dependenat on LOcationID
plot(MarketSize, AgeOfStore, main="MarketSize vs age of store", col = "green")
plot(MarketSize, Promotion, main="MarketSize vs Promotion", col = "blue")
plot(MarketSize, SalesInThousands, main="MarketSize vs Sales", col = "red")
sales <- aggregate(SalesInThousands ~ MarketSize, data = Project.df, sum)
sales
## MarketSize SalesInThousands
## 1 Large 11779.61
## 2 Medium 14075.31
## 3 Small 3444.56
Majority of sales has come from medium and large market. Medium being the higest.
plot(Promotion, SalesInThousands, main="Promotion vs Sales")
sales = aggregate(SalesInThousands ~ Promotion, data = Project.df, sum)
sales
## Promotion SalesInThousands
## 1 1 9993.03
## 2 2 8897.93
## 3 3 10408.52
Agrregate sales due to Promotion3>promotion2>promotion1. Although the sales are not very sinificalty different
boxplot(Promotion ~ SalesInThousands ,data=Project.df, main="Distribution of Sales with Promotion", ylab="Sales", xlab="Promtion", horizontal=TRUE)
scatter.hist(Promotion, SalesInThousands, main="Sales vs Promotion" , xlab = "Promotion" , ylab = "Sales")
plot(AgeOfStore, SalesInThousands, main="Age vs Sale")
scatter.hist(AgeOfStore, SalesInThousands, main="Age vs Sales" , xlab = "Age" , ylab = "Sales")
plot(Week, SalesInThousands, main="Week vs Sales")
scatter.hist(Week, SalesInThousands, main="Week Vs Sales" , xlab = "Week" , ylab = "Sales")
sales = aggregate(SalesInThousands ~ Week, data = Project.df, sum)
sales
## Week SalesInThousands
## 1 1 7369.31
## 2 2 7313.96
## 3 3 7326.02
## 4 4 7290.19
Sales in all the weeks are almost same.
x <- Project.df[,c("LocationID", "AgeOfStore","Promotion","Week","SalesInThousands")]
y <- Project.df[,c("Promotion", "SalesInThousands")]
cor(x,y)
## Promotion SalesInThousands
## LocationID -0.04991501 -0.18785183
## AgeOfStore 0.05976484 -0.02853288
## Promotion 1.00000000 -0.05921195
## Week 0.00000000 -0.01098354
## SalesInThousands -0.05921195 1.00000000
library(corrplot)
## Warning: package 'corrplot' was built under R version 3.3.3
## corrplot 0.84 loaded
corrplot(corr=cor(Project.df[ , c(3:7)], use="complete.obs"),
method ="ellipse")
mytable <- xtabs(~ SalesInThousands + Week,)
mytable
## Week
## SalesInThousands 1 2 3 4
## 17.34 0 1 0 0
## 19.26 0 0 0 1
## 22.18 0 1 0 0
## 23.35 0 0 0 1
## 23.44 0 0 0 1
## 23.93 0 0 1 0
## 24.75 1 0 0 0
## 24.77 0 0 1 0
## 24.82 0 1 0 0
## 25.4 0 0 1 0
## 25.7 0 0 0 1
## 26.68 0 0 0 1
## 27.26 0 0 0 1
## 27.37 0 0 0 1
## 27.55 0 0 1 0
## 27.71 0 0 1 0
## 27.72 0 0 0 1
## 27.81 1 0 0 0
## 27.98 0 0 1 0
## 28.62 0 1 0 0
## 29.03 0 0 1 0
## 29.12 0 0 0 1
## 29.3 0 1 0 0
## 29.64 0 1 0 0
## 30.08 1 0 0 0
## 30.26 0 1 0 0
## 30.37 1 0 0 0
## 30.52 0 1 0 0
## 30.81 0 0 0 1
## 30.98 0 0 0 1
## 31.62 0 0 0 1
## 31.85 0 0 1 0
## 31.94 1 0 0 0
## 32.05 0 0 1 0
## 32.18 0 0 1 0
## 32.21 1 0 0 0
## 32.51 0 0 1 0
## 32.61 1 0 0 0
## 32.77 1 0 0 0
## 32.9 1 0 0 0
## 33.14 0 0 1 0
## 33.35 0 0 0 1
## 33.42 1 0 0 0
## 33.64 0 0 1 0
## 33.73 1 0 0 0
## 33.85 0 0 1 0
## 34.27 1 0 0 0
## 34.33 0 0 0 1
## 34.46 1 0 0 0
## 34.67 0 1 0 0
## 34.75 0 0 0 1
## 35.1 0 0 1 0
## 35.16 0 0 0 1
## 35.24 0 1 0 0
## 35.3 1 0 0 0
## 35.46 0 1 0 0
## 35.6 0 0 1 0
## 35.67 0 1 0 0
## 35.68 0 0 1 0
## 35.85 1 0 0 0
## 35.86 0 1 0 0
## 36.05 0 0 0 1
## 36.17 0 0 1 1
## 36.24 0 1 0 0
## 36.39 0 0 1 0
## 36.7 1 0 0 0
## 36.8 0 2 0 0
## 36.88 0 1 0 0
## 37.14 0 0 1 0
## 37.17 1 0 0 0
## 37.2 0 0 0 1
## 37.29 0 1 0 0
## 37.32 0 0 1 1
## 37.41 1 0 0 0
## 37.45 1 0 0 0
## 37.47 0 0 1 0
## 37.84 0 0 1 0
## 37.9 0 0 1 0
## 37.93 0 1 0 0
## 37.94 0 1 0 0
## 38.26 0 1 0 0
## 38.3 0 0 0 1
## 38.41 0 1 0 0
## 38.51 0 0 1 0
## 38.56 1 0 0 0
## 38.64 0 1 0 0
## 38.65 1 0 0 0
## 38.85 0 0 0 1
## 39.25 0 0 0 2
## 39.28 1 0 0 0
## 39.36 0 1 0 0
## 39.41 0 1 0 0
## 39.67 0 0 0 1
## 39.73 1 0 0 0
## 39.8 0 1 0 0
## 39.98 1 0 0 0
## 40.13 0 1 0 0
## 40.16 0 0 1 0
## 40.17 0 0 1 0
## 40.25 0 1 0 1
## 40.26 0 0 0 1
## 40.29 1 0 0 0
## 40.4 1 0 0 0
## 40.43 1 0 0 0
## 40.46 1 0 0 0
## 40.71 1 0 0 0
## 40.84 0 1 0 0
## 40.9 0 0 1 0
## 40.97 0 0 0 1
## 41.1 1 0 1 0
## 41.11 0 0 0 1
## 41.12 0 1 0 0
## 41.22 0 0 0 1
## 41.25 0 1 0 0
## 41.37 0 0 0 1
## 41.44 0 0 1 0
## 41.47 0 1 0 0
## 41.53 0 1 0 0
## 41.54 0 0 0 1
## 41.56 0 1 0 0
## 41.71 0 1 0 0
## 41.73 0 0 1 0
## 41.85 0 0 0 1
## 41.96 1 0 0 0
## 42.15 1 0 1 0
## 42.16 1 1 0 0
## 42.27 0 1 0 0
## 42.46 0 0 1 0
## 42.5 0 0 1 0
## 42.56 0 1 0 0
## 42.59 0 1 0 1
## 42.76 1 0 0 0
## 42.82 0 0 0 1
## 42.92 1 0 0 0
## 42.98 0 0 1 0
## 43.11 0 1 0 0
## 43.15 0 0 0 1
## 43.24 0 0 0 1
## 43.26 0 0 1 0
## 43.27 1 0 0 0
## 43.29 0 0 1 0
## 43.44 0 1 0 0
## 43.51 0 0 0 1
## 43.59 1 0 0 0
## 43.61 1 0 0 0
## 43.69 0 1 0 0
## 43.73 0 0 0 1
## 43.77 0 0 0 1
## 43.78 0 0 1 0
## 43.91 0 0 1 0
## 44.14 0 1 1 0
## 44.16 0 0 1 1
## 44.19 0 0 1 0
## 44.2 0 0 0 1
## 44.29 0 0 1 0
## 44.31 0 0 1 0
## 44.43 0 0 0 1
## 44.54 1 0 0 0
## 44.64 0 0 1 0
## 44.66 1 0 0 0
## 44.67 0 0 0 1
## 44.7 1 0 0 0
## 44.84 0 1 0 1
## 44.98 1 0 0 0
## 45.02 0 1 0 0
## 45.03 0 0 1 0
## 45.08 0 0 1 0
## 45.11 0 0 0 1
## 45.21 1 0 0 0
## 45.3 1 0 0 0
## 45.35 0 0 1 0
## 45.42 0 1 0 0
## 45.43 0 0 0 1
## 45.49 0 0 1 0
## 45.56 1 0 0 0
## 45.57 0 1 0 0
## 45.75 0 1 0 0
## 45.77 0 0 1 0
## 45.84 0 0 0 1
## 45.9 0 0 0 1
## 45.92 0 0 1 0
## 46.02 1 0 0 0
## 46.03 0 1 0 1
## 46.06 0 1 0 0
## 46.14 1 0 0 0
## 46.2 0 1 0 0
## 46.22 0 0 1 0
## 46.26 1 0 0 0
## 46.29 0 1 0 0
## 46.3 0 0 0 1
## 46.42 0 0 1 0
## 46.45 0 0 0 1
## 46.47 0 0 0 1
## 46.49 0 0 1 0
## 46.66 0 0 0 1
## 46.83 0 0 1 0
## 46.84 0 0 0 1
## 46.89 0 0 0 1
## 46.98 1 0 1 0
## 47.06 0 0 0 1
## 47.2 0 0 1 0
## 47.22 1 0 2 0
## 47.33 1 0 0 0
## 47.35 0 0 0 2
## 47.36 0 0 0 1
## 47.48 1 0 0 0
## 47.5 0 0 0 1
## 47.51 0 0 0 1
## 47.63 1 0 0 0
## 47.71 0 1 0 0
## 47.89 1 0 0 0
## 47.92 0 1 0 0
## 47.93 0 0 1 0
## 48.06 1 0 0 0
## 48.12 0 0 0 1
## 48.18 2 0 0 0
## 48.25 0 1 0 0
## 48.32 0 0 1 0
## 48.33 0 1 0 0
## 48.35 0 1 0 0
## 48.36 0 0 0 1
## 48.5 1 0 0 0
## 48.64 0 1 0 0
## 48.76 1 0 0 0
## 48.77 0 0 1 0
## 48.84 0 1 0 0
## 49.01 1 0 0 0
## 49.08 0 0 1 1
## 49.11 0 0 1 0
## 49.16 0 1 0 0
## 49.3 1 0 1 0
## 49.38 0 1 0 0
## 49.39 1 0 0 0
## 49.41 0 0 0 1
## 49.44 0 0 1 0
## 49.5 0 0 1 0
## 49.52 0 0 0 1
## 49.56 0 0 1 0
## 49.61 1 0 0 0
## 49.62 1 0 0 0
## 49.63 0 0 0 1
## 49.67 1 0 0 0
## 49.71 0 0 0 1
## 49.72 0 1 0 0
## 49.76 0 1 0 0
## 49.91 0 0 0 1
## 49.95 1 0 0 0
## 49.98 1 1 0 0
## 50.05 0 0 0 1
## 50.07 0 0 0 1
## 50.11 1 0 1 0
## 50.2 1 0 0 1
## 50.26 1 0 0 0
## 50.28 0 1 0 0
## 50.3 0 1 0 0
## 50.48 1 0 0 0
## 50.52 0 1 0 1
## 50.54 1 0 0 0
## 50.55 0 0 1 0
## 50.59 1 0 0 0
## 50.94 1 0 0 0
## 51.01 1 0 0 0
## 51.09 1 2 0 0
## 51.14 0 0 1 0
## 51.15 0 1 0 0
## 51.16 0 0 1 0
## 51.17 0 1 0 0
## 51.26 1 0 0 0
## 51.32 0 0 0 1
## 51.33 0 0 0 1
## 51.35 0 0 1 0
## 51.41 0 0 0 2
## 51.47 1 0 0 0
## 51.5 0 0 0 1
## 51.52 0 0 1 0
## 51.68 0 1 1 0
## 51.72 0 0 2 0
## 51.73 0 1 0 0
## 51.79 1 0 0 0
## 51.82 1 0 0 0
## 51.83 0 0 1 0
## 51.87 1 0 0 0
## 51.89 1 0 0 0
## 51.91 0 0 0 1
## 52.05 0 1 0 0
## 52.21 0 1 0 0
## 52.23 1 0 0 0
## 52.36 0 0 1 0
## 52.37 0 1 0 0
## 52.39 0 1 0 0
## 52.41 0 0 0 1
## 52.64 0 0 1 0
## 52.72 0 0 1 0
## 52.76 0 0 0 1
## 52.85 1 0 0 0
## 52.88 0 0 0 1
## 53.14 0 0 1 0
## 53.38 1 0 0 0
## 53.41 0 1 0 0
## 53.47 0 1 0 0
## 53.5 1 0 0 0
## 53.51 1 0 0 0
## 53.53 1 0 0 0
## 53.56 1 0 0 0
## 53.66 0 0 0 1
## 53.68 0 1 0 0
## 53.76 1 0 0 0
## 53.78 0 1 0 0
## 53.79 1 0 0 0
## 53.95 0 0 0 1
## 54.01 1 0 0 0
## 54.06 0 1 0 0
## 54.09 0 0 1 0
## 54.33 0 0 1 0
## 54.34 1 0 0 0
## 54.37 0 0 1 0
## 54.38 0 1 0 0
## 54.49 0 0 1 0
## 54.58 0 1 0 0
## 54.68 0 0 1 0
## 54.7 0 0 0 1
## 54.79 1 0 0 0
## 54.82 0 1 0 0
## 54.95 1 0 0 0
## 55.02 0 1 0 0
## 55.11 0 1 0 0
## 55.12 0 0 1 0
## 55.19 0 1 0 0
## 55.2 0 0 0 1
## 55.28 0 0 1 0
## 55.3 0 0 0 1
## 55.31 0 1 0 0
## 55.39 1 0 0 0
## 55.46 0 0 1 0
## 55.53 0 1 0 0
## 55.59 0 1 0 0
## 55.78 0 1 0 0
## 55.9 1 0 0 0
## 55.91 0 0 0 1
## 55.94 1 0 0 0
## 55.98 0 0 0 1
## 56.1 0 0 1 0
## 56.16 0 1 0 0
## 56.18 0 0 1 0
## 56.19 0 0 1 0
## 56.34 0 1 0 0
## 56.39 0 0 1 0
## 56.64 1 0 0 0
## 56.7 0 0 0 1
## 56.72 0 0 0 1
## 56.84 0 0 0 1
## 56.86 0 0 1 0
## 56.9 0 0 0 1
## 56.99 1 0 0 0
## 57.04 0 1 0 0
## 57.06 0 0 0 1
## 57.1 0 0 1 0
## 57.14 0 0 1 0
## 57.2 0 0 1 0
## 57.27 0 1 0 0
## 57.37 1 0 0 0
## 58 0 0 1 0
## 58.01 0 1 0 0
## 58.04 0 0 0 1
## 58.1 0 0 1 0
## 58.19 1 0 0 0
## 58.26 0 0 1 0
## 58.33 0 0 0 1
## 58.43 0 1 0 0
## 58.55 1 0 0 0
## 58.77 0 1 0 0
## 59.17 0 1 0 0
## 59.34 1 0 0 0
## 59.64 0 0 0 1
## 59.65 1 0 0 0
## 59.73 0 0 1 0
## 59.76 1 0 0 0
## 59.77 0 0 1 0
## 59.8 0 1 0 0
## 59.87 1 0 0 0
## 60.24 0 1 0 0
## 60.44 0 0 0 1
## 60.59 0 1 0 0
## 60.93 0 0 0 1
## 60.97 0 0 1 0
## 61.24 0 0 0 1
## 61.25 0 0 0 1
## 61.36 0 1 0 0
## 61.53 1 0 0 0
## 61.59 1 0 0 0
## 61.63 0 0 0 1
## 61.77 0 0 0 1
## 61.8 0 1 0 0
## 61.95 0 0 1 0
## 61.96 0 0 1 0
## 62.06 0 0 0 1
## 62.16 1 0 1 0
## 62.19 0 1 0 0
## 62.27 0 0 0 1
## 62.33 1 0 0 0
## 62.37 0 0 1 0
## 62.54 0 1 0 0
## 62.63 0 1 0 0
## 62.72 0 1 0 0
## 62.93 1 0 0 0
## 62.99 0 1 0 0
## 63.48 0 1 0 0
## 63.58 0 0 0 1
## 63.64 0 1 0 0
## 63.73 0 0 1 0
## 63.98 0 0 1 0
## 64.04 0 0 0 1
## 64.14 0 0 0 1
## 64.34 0 0 0 1
## 64.45 0 0 1 0
## 64.66 0 0 0 1
## 65.06 0 0 0 1
## 65.11 1 0 0 0
## 65.12 0 0 0 1
## 65.57 0 1 0 0
## 66.1 0 0 0 1
## 66.11 0 1 0 0
## 66.22 1 0 0 0
## 66.34 1 0 0 0
## 66.66 0 0 1 0
## 66.96 0 1 0 0
## 67.48 1 0 0 0
## 67.84 0 0 0 1
## 68.31 0 0 1 0
## 68.42 0 0 1 0
## 70.6 0 0 1 0
## 73.22 1 0 0 0
## 74.03 0 1 0 0
## 74.75 0 1 0 0
## 75.29 0 0 0 1
## 75.61 0 0 0 1
## 75.88 0 1 0 0
## 76.12 0 0 1 0
## 76.71 0 0 0 1
## 77.17 0 0 0 1
## 77.36 0 0 1 0
## 77.39 0 1 0 0
## 78.01 0 0 1 0
## 78.43 0 1 0 0
## 78.53 0 0 1 0
## 79.02 0 1 0 0
## 79.36 0 0 1 0
## 79.53 1 0 0 0
## 79.64 0 0 0 1
## 80.17 0 0 0 1
## 80.61 0 1 0 0
## 80.75 0 0 0 1
## 80.82 0 0 0 1
## 80.83 0 0 1 0
## 81.16 0 1 0 0
## 81.18 0 0 0 1
## 81.37 0 1 0 0
## 81.55 0 0 1 0
## 81.58 0 0 1 0
## 81.72 0 0 0 1
## 81.79 0 1 0 0
## 82.13 0 0 1 0
## 82.14 0 0 1 0
## 82.56 0 1 0 0
## 82.64 1 0 0 0
## 82.65 1 0 0 0
## 82.72 0 0 0 1
## 82.86 0 1 0 0
## 82.88 0 0 0 1
## 82.89 0 1 0 0
## 83.02 1 0 0 0
## 83.4 0 0 1 0
## 83.43 0 0 0 1
## 84.05 0 0 1 0
## 84.13 0 1 0 0
## 84.34 1 0 0 0
## 85.11 1 0 0 0
## 85.18 0 0 1 0
## 85.21 0 1 0 0
## 85.71 0 1 0 0
## 85.85 0 0 0 1
## 86.11 0 0 1 0
## 86.14 1 0 0 0
## 86.96 0 0 1 0
## 87.08 1 0 0 0
## 87.43 1 0 0 0
## 87.7 1 0 0 0
## 87.9 0 1 0 0
## 88.07 0 1 0 0
## 88.12 0 0 1 0
## 88.64 1 1 0 0
## 88.73 1 0 0 0
## 88.91 0 0 0 1
## 89.25 0 0 0 1
## 89.32 0 1 0 0
## 89.44 0 0 0 1
## 89.7 1 0 0 0
## 89.77 0 0 0 1
## 90.3 0 1 0 0
## 91.29 0 0 0 1
## 91.6 1 0 0 0
## 91.61 1 0 0 0
## 91.98 0 0 1 0
## 93.03 0 0 1 0
## 93.32 1 0 0 0
## 93.63 0 0 1 0
## 93.71 1 0 0 0
## 93.86 0 0 1 0
## 94.17 0 0 0 1
## 94.21 0 0 0 1
## 94.43 0 0 1 0
## 94.89 1 0 0 0
## 96.01 0 1 0 0
## 96.48 1 0 0 0
## 97.61 0 0 0 1
## 99.12 0 0 1 0
## 99.65 1 0 0 0
sales = aggregate(SalesInThousands ~ Week, data = Project.df, sum)
sales
## Week SalesInThousands
## 1 1 7369.31
## 2 2 7313.96
## 3 3 7326.02
## 4 4 7290.19
chisq.test(mytable)
## Warning in chisq.test(mytable): Chi-squared approximation may be incorrect
##
## Pearson's Chi-squared test
##
## data: mytable
## X-squared = 1549.3, df = 1548, p-value = 0.4857
aggregate(SalesInThousands, by=list(Week = Week), mean)
## Week x
## 1 1 53.79058
## 2 2 53.38657
## 3 3 53.47460
## 4 4 53.21307
Clearly no affect of week on sales.
plot(Promotion,SalesInThousands , main="Age vs Sale")
mytable <- xtabs(~ SalesInThousands+Week+ Promotion,data = Promotion1.df )
mytable
## , , Promotion = 1
##
## Week
## SalesInThousands 1 2 3 4
## 30.81 0 0 0 1
## 32.05 0 0 1 0
## 34.75 0 0 0 1
## 35.3 1 0 0 0
## 35.68 0 0 1 0
## 35.85 1 0 0 0
## 35.86 0 1 0 0
## 36.17 0 0 0 1
## 36.24 0 1 0 0
## 36.39 0 0 1 0
## 36.8 0 1 0 0
## 36.88 0 1 0 0
## 37.32 0 0 0 1
## 37.41 1 0 0 0
## 37.94 0 1 0 0
## 38.64 0 1 0 0
## 39.67 0 0 0 1
## 40.46 1 0 0 0
## 40.84 0 1 0 0
## 40.9 0 0 1 0
## 40.97 0 0 0 1
## 41.1 1 0 1 0
## 41.11 0 0 0 1
## 41.25 0 1 0 0
## 41.56 0 1 0 0
## 41.71 0 1 0 0
## 41.73 0 0 1 0
## 42.16 1 1 0 0
## 42.76 1 0 0 0
## 42.92 1 0 0 0
## 43.11 0 1 0 0
## 43.24 0 0 0 1
## 43.78 0 0 1 0
## 44.43 0 0 0 1
## 44.54 1 0 0 0
## 44.98 1 0 0 0
## 45.02 0 1 0 0
## 45.49 0 0 1 0
## 45.57 0 1 0 0
## 45.92 0 0 1 0
## 46.06 0 1 0 0
## 46.45 0 0 0 1
## 46.49 0 0 1 0
## 46.66 0 0 0 1
## 46.98 0 0 1 0
## 47.35 0 0 0 1
## 47.5 0 0 0 1
## 47.51 0 0 0 1
## 47.92 0 1 0 0
## 48.18 1 0 0 0
## 49.08 0 0 1 0
## 49.3 1 0 1 0
## 49.44 0 0 1 0
## 49.62 1 0 0 0
## 49.76 0 1 0 0
## 49.91 0 0 0 1
## 49.95 1 0 0 0
## 50.11 0 0 1 0
## 50.48 1 0 0 0
## 50.52 0 1 0 1
## 50.54 1 0 0 0
## 51.32 0 0 0 1
## 51.41 0 0 0 1
## 51.72 0 0 2 0
## 51.82 1 0 0 0
## 52.85 1 0 0 0
## 53.38 1 0 0 0
## 53.51 1 0 0 0
## 53.53 1 0 0 0
## 53.68 0 1 0 0
## 53.79 1 0 0 0
## 54.01 1 0 0 0
## 54.06 0 1 0 0
## 54.38 0 1 0 0
## 54.7 0 0 0 1
## 54.95 1 0 0 0
## 55.11 0 1 0 0
## 55.2 0 0 0 1
## 55.28 0 0 1 0
## 55.3 0 0 0 1
## 55.31 0 1 0 0
## 55.46 0 0 1 0
## 55.78 0 1 0 0
## 55.94 1 0 0 0
## 56.1 0 0 1 0
## 56.18 0 0 1 0
## 56.19 0 0 1 0
## 56.64 1 0 0 0
## 56.84 0 0 0 1
## 56.86 0 0 1 0
## 56.9 0 0 0 1
## 56.99 1 0 0 0
## 57.1 0 0 1 0
## 57.14 0 0 1 0
## 57.2 0 0 1 0
## 58 0 0 1 0
## 58.04 0 0 0 1
## 58.19 1 0 0 0
## 58.43 0 1 0 0
## 59.17 0 1 0 0
## 59.34 1 0 0 0
## 59.64 0 0 0 1
## 59.77 0 0 1 0
## 59.87 1 0 0 0
## 60.44 0 0 0 1
## 60.59 0 1 0 0
## 60.93 0 0 0 1
## 61.36 0 1 0 0
## 61.53 1 0 0 0
## 61.63 0 0 0 1
## 61.77 0 0 0 1
## 61.8 0 1 0 0
## 61.95 0 0 1 0
## 61.96 0 0 1 0
## 62.06 0 0 0 1
## 62.16 1 0 0 0
## 62.33 1 0 0 0
## 62.37 0 0 1 0
## 62.54 0 1 0 0
## 62.63 0 1 0 0
## 62.72 0 1 0 0
## 62.99 0 1 0 0
## 63.48 0 1 0 0
## 63.58 0 0 0 1
## 63.73 0 0 1 0
## 64.34 0 0 0 1
## 64.45 0 0 1 0
## 64.66 0 0 0 1
## 65.11 1 0 0 0
## 65.12 0 0 0 1
## 65.57 0 1 0 0
## 66.1 0 0 0 1
## 66.34 1 0 0 0
## 66.66 0 0 1 0
## 66.96 0 1 0 0
## 67.48 1 0 0 0
## 67.84 0 0 0 1
## 68.31 0 0 1 0
## 68.42 0 0 1 0
## 77.36 0 0 1 0
## 80.61 0 1 0 0
## 81.55 0 0 1 0
## 83.43 0 0 0 1
## 85.11 1 0 0 0
## 85.21 0 1 0 0
## 85.71 0 1 0 0
## 85.85 0 0 0 1
## 86.96 0 0 1 0
## 87.08 1 0 0 0
## 88.07 0 1 0 0
## 88.64 0 1 0 0
## 88.73 1 0 0 0
## 89.25 0 0 0 1
## 89.32 0 1 0 0
## 89.44 0 0 0 1
## 91.29 0 0 0 1
## 91.6 1 0 0 0
## 93.03 0 0 1 0
## 93.32 1 0 0 0
## 93.71 1 0 0 0
## 93.86 0 0 1 0
## 94.17 0 0 0 1
## 94.43 0 0 1 0
## 96.01 0 1 0 0
## 97.61 0 0 0 1
## 99.12 0 0 1 0
## 99.65 1 0 0 0
aggregate(Promotion1.df$SalesInThousands, by=list(Week = Promotion1.df$Week), mean)
## Week x
## 1 1 58.24442
## 2 2 56.92953
## 3 3 58.77488
## 4 4 58.44721
mytable <- xtabs(~ SalesInThousands+Week+ Promotion,data = Promotion2.df )
mytable
## , , Promotion = 2
##
## Week
## SalesInThousands 1 2 3 4
## 17.34 0 1 0 0
## 19.26 0 0 0 1
## 23.35 0 0 0 1
## 23.44 0 0 0 1
## 23.93 0 0 1 0
## 24.77 0 0 1 0
## 24.82 0 1 0 0
## 25.4 0 0 1 0
## 25.7 0 0 0 1
## 27.26 0 0 0 1
## 27.37 0 0 0 1
## 27.55 0 0 1 0
## 27.71 0 0 1 0
## 27.72 0 0 0 1
## 27.81 1 0 0 0
## 27.98 0 0 1 0
## 28.62 0 1 0 0
## 29.3 0 1 0 0
## 29.64 0 1 0 0
## 30.08 1 0 0 0
## 30.26 0 1 0 0
## 30.37 1 0 0 0
## 30.98 0 0 0 1
## 31.62 0 0 0 1
## 31.85 0 0 1 0
## 31.94 1 0 0 0
## 32.21 1 0 0 0
## 32.61 1 0 0 0
## 32.77 1 0 0 0
## 33.14 0 0 1 0
## 33.35 0 0 0 1
## 33.64 0 0 1 0
## 34.27 1 0 0 0
## 34.67 0 1 0 0
## 35.16 0 0 0 1
## 35.46 0 1 0 0
## 35.6 0 0 1 0
## 36.05 0 0 0 1
## 36.17 0 0 1 0
## 36.7 1 0 0 0
## 36.8 0 1 0 0
## 37.2 0 0 0 1
## 37.29 0 1 0 0
## 37.32 0 0 1 0
## 37.45 1 0 0 0
## 37.47 0 0 1 0
## 37.9 0 0 1 0
## 38.26 0 1 0 0
## 38.3 0 0 0 1
## 38.41 0 1 0 0
## 38.56 1 0 0 0
## 38.65 1 0 0 0
## 39.25 0 0 0 1
## 39.28 1 0 0 0
## 39.36 0 1 0 0
## 39.73 1 0 0 0
## 39.8 0 1 0 0
## 40.16 0 0 1 0
## 40.25 0 1 0 0
## 40.26 0 0 0 1
## 40.4 1 0 0 0
## 40.71 1 0 0 0
## 41.22 0 0 0 1
## 41.37 0 0 0 1
## 41.44 0 0 1 0
## 41.53 0 1 0 0
## 41.54 0 0 0 1
## 41.85 0 0 0 1
## 42.15 1 0 0 0
## 42.46 0 0 1 0
## 42.56 0 1 0 0
## 42.59 0 1 0 0
## 43.27 1 0 0 0
## 43.44 0 1 0 0
## 43.59 1 0 0 0
## 43.61 1 0 0 0
## 43.69 0 1 0 0
## 43.77 0 0 0 1
## 44.14 0 1 1 0
## 44.16 0 0 1 1
## 44.29 0 0 1 0
## 44.31 0 0 1 0
## 44.64 0 0 1 0
## 44.67 0 0 0 1
## 44.7 1 0 0 0
## 44.84 0 1 0 1
## 45.08 0 0 1 0
## 45.11 0 0 0 1
## 45.21 1 0 0 0
## 45.3 1 0 0 0
## 45.35 0 0 1 0
## 45.42 0 1 0 0
## 45.75 0 1 0 0
## 45.9 0 0 0 1
## 46.02 1 0 0 0
## 46.03 0 1 0 0
## 46.2 0 1 0 0
## 46.26 1 0 0 0
## 46.42 0 0 1 0
## 46.89 0 0 0 1
## 46.98 1 0 0 0
## 47.06 0 0 0 1
## 47.2 0 0 1 0
## 47.22 0 0 1 0
## 47.33 1 0 0 0
## 47.36 0 0 0 1
## 47.71 0 1 0 0
## 47.89 1 0 0 0
## 47.93 0 0 1 0
## 48.12 0 0 0 1
## 48.18 1 0 0 0
## 48.25 0 1 0 0
## 48.32 0 0 1 0
## 48.33 0 1 0 0
## 48.5 1 0 0 0
## 48.76 1 0 0 0
## 48.84 0 1 0 0
## 49.11 0 0 1 0
## 49.16 0 1 0 0
## 49.39 1 0 0 0
## 49.41 0 0 0 1
## 49.56 0 0 1 0
## 49.61 1 0 0 0
## 49.71 0 0 0 1
## 49.98 1 0 0 0
## 50.2 1 0 0 0
## 50.28 0 1 0 0
## 50.3 0 1 0 0
## 51.09 1 1 0 0
## 51.26 1 0 0 0
## 51.33 0 0 0 1
## 51.35 0 0 1 0
## 51.41 0 0 0 1
## 51.5 0 0 0 1
## 51.52 0 0 1 0
## 51.68 0 0 1 0
## 51.73 0 1 0 0
## 51.79 1 0 0 0
## 51.87 1 0 0 0
## 52.36 0 0 1 0
## 52.37 0 1 0 0
## 52.72 0 0 1 0
## 52.88 0 0 0 1
## 53.41 0 1 0 0
## 53.66 0 0 0 1
## 53.76 1 0 0 0
## 53.95 0 0 0 1
## 54.09 0 0 1 0
## 54.49 0 0 1 0
## 54.82 0 1 0 0
## 55.02 0 1 0 0
## 55.12 0 0 1 0
## 55.39 1 0 0 0
## 55.91 0 0 0 1
## 55.98 0 0 0 1
## 57.27 0 1 0 0
## 58.01 0 1 0 0
## 58.1 0 0 1 0
## 58.26 0 0 1 0
## 61.25 0 0 0 1
## 66.22 1 0 0 0
## 73.22 1 0 0 0
## 74.03 0 1 0 0
## 75.29 0 0 0 1
## 75.61 0 0 0 1
## 75.88 0 1 0 0
## 76.71 0 0 0 1
## 77.39 0 1 0 0
## 78.01 0 0 1 0
## 78.53 0 0 1 0
## 79.53 1 0 0 0
## 79.64 0 0 0 1
## 80.17 0 0 0 1
## 80.75 0 0 0 1
## 80.83 0 0 1 0
## 81.37 0 1 0 0
## 81.79 0 1 0 0
## 82.14 0 0 1 0
## 82.65 1 0 0 0
## 82.86 0 1 0 0
## 83.4 0 0 1 0
## 87.43 1 0 0 0
## 88.12 0 0 1 0
## 88.64 1 0 0 0
aggregate(Promotion2.df$SalesInThousands, by=list(Week = Promotion2.df$Week), mean)
## Week x
## 1 1 47.73021
## 2 2 47.58255
## 3 3 47.72213
## 4 4 46.28277
mytable <- xtabs(~ SalesInThousands+Week+ Promotion,data = Promotion3.df )
mytable
## , , Promotion = 3
##
## Week
## SalesInThousands 1 2 3 4
## 22.18 0 1 0 0
## 24.75 1 0 0 0
## 26.68 0 0 0 1
## 29.03 0 0 1 0
## 29.12 0 0 0 1
## 30.52 0 1 0 0
## 32.18 0 0 1 0
## 32.51 0 0 1 0
## 32.9 1 0 0 0
## 33.42 1 0 0 0
## 33.73 1 0 0 0
## 33.85 0 0 1 0
## 34.33 0 0 0 1
## 34.46 1 0 0 0
## 35.1 0 0 1 0
## 35.24 0 1 0 0
## 35.67 0 1 0 0
## 37.14 0 0 1 0
## 37.17 1 0 0 0
## 37.84 0 0 1 0
## 37.93 0 1 0 0
## 38.51 0 0 1 0
## 38.85 0 0 0 1
## 39.25 0 0 0 1
## 39.41 0 1 0 0
## 39.98 1 0 0 0
## 40.13 0 1 0 0
## 40.17 0 0 1 0
## 40.25 0 0 0 1
## 40.29 1 0 0 0
## 40.43 1 0 0 0
## 41.12 0 1 0 0
## 41.47 0 1 0 0
## 41.96 1 0 0 0
## 42.15 0 0 1 0
## 42.27 0 1 0 0
## 42.5 0 0 1 0
## 42.59 0 0 0 1
## 42.82 0 0 0 1
## 42.98 0 0 1 0
## 43.15 0 0 0 1
## 43.26 0 0 1 0
## 43.29 0 0 1 0
## 43.51 0 0 0 1
## 43.73 0 0 0 1
## 43.91 0 0 1 0
## 44.19 0 0 1 0
## 44.2 0 0 0 1
## 44.66 1 0 0 0
## 45.03 0 0 1 0
## 45.43 0 0 0 1
## 45.56 1 0 0 0
## 45.77 0 0 1 0
## 45.84 0 0 0 1
## 46.03 0 0 0 1
## 46.14 1 0 0 0
## 46.22 0 0 1 0
## 46.29 0 1 0 0
## 46.3 0 0 0 1
## 46.47 0 0 0 1
## 46.83 0 0 1 0
## 46.84 0 0 0 1
## 47.22 1 0 1 0
## 47.35 0 0 0 1
## 47.48 1 0 0 0
## 47.63 1 0 0 0
## 48.06 1 0 0 0
## 48.35 0 1 0 0
## 48.36 0 0 0 1
## 48.64 0 1 0 0
## 48.77 0 0 1 0
## 49.01 1 0 0 0
## 49.08 0 0 0 1
## 49.38 0 1 0 0
## 49.5 0 0 1 0
## 49.52 0 0 0 1
## 49.63 0 0 0 1
## 49.67 1 0 0 0
## 49.72 0 1 0 0
## 49.98 0 1 0 0
## 50.05 0 0 0 1
## 50.07 0 0 0 1
## 50.11 1 0 0 0
## 50.2 0 0 0 1
## 50.26 1 0 0 0
## 50.55 0 0 1 0
## 50.59 1 0 0 0
## 50.94 1 0 0 0
## 51.01 1 0 0 0
## 51.09 0 1 0 0
## 51.14 0 0 1 0
## 51.15 0 1 0 0
## 51.16 0 0 1 0
## 51.17 0 1 0 0
## 51.47 1 0 0 0
## 51.68 0 1 0 0
## 51.83 0 0 1 0
## 51.89 1 0 0 0
## 51.91 0 0 0 1
## 52.05 0 1 0 0
## 52.21 0 1 0 0
## 52.23 1 0 0 0
## 52.39 0 1 0 0
## 52.41 0 0 0 1
## 52.64 0 0 1 0
## 52.76 0 0 0 1
## 53.14 0 0 1 0
## 53.47 0 1 0 0
## 53.5 1 0 0 0
## 53.56 1 0 0 0
## 53.78 0 1 0 0
## 54.33 0 0 1 0
## 54.34 1 0 0 0
## 54.37 0 0 1 0
## 54.58 0 1 0 0
## 54.68 0 0 1 0
## 54.79 1 0 0 0
## 55.19 0 1 0 0
## 55.53 0 1 0 0
## 55.59 0 1 0 0
## 55.9 1 0 0 0
## 56.16 0 1 0 0
## 56.34 0 1 0 0
## 56.39 0 0 1 0
## 56.7 0 0 0 1
## 56.72 0 0 0 1
## 57.04 0 1 0 0
## 57.06 0 0 0 1
## 57.37 1 0 0 0
## 58.33 0 0 0 1
## 58.55 1 0 0 0
## 58.77 0 1 0 0
## 59.65 1 0 0 0
## 59.73 0 0 1 0
## 59.76 1 0 0 0
## 59.8 0 1 0 0
## 60.24 0 1 0 0
## 60.97 0 0 1 0
## 61.24 0 0 0 1
## 61.59 1 0 0 0
## 62.16 0 0 1 0
## 62.19 0 1 0 0
## 62.27 0 0 0 1
## 62.93 1 0 0 0
## 63.64 0 1 0 0
## 63.98 0 0 1 0
## 64.04 0 0 0 1
## 64.14 0 0 0 1
## 65.06 0 0 0 1
## 66.11 0 1 0 0
## 70.6 0 0 1 0
## 74.75 0 1 0 0
## 76.12 0 0 1 0
## 77.17 0 0 0 1
## 78.43 0 1 0 0
## 79.02 0 1 0 0
## 79.36 0 0 1 0
## 80.82 0 0 0 1
## 81.16 0 1 0 0
## 81.18 0 0 0 1
## 81.58 0 0 1 0
## 81.72 0 0 0 1
## 82.13 0 0 1 0
## 82.56 0 1 0 0
## 82.64 1 0 0 0
## 82.72 0 0 0 1
## 82.88 0 0 0 1
## 82.89 0 1 0 0
## 83.02 1 0 0 0
## 84.05 0 0 1 0
## 84.13 0 1 0 0
## 84.34 1 0 0 0
## 85.18 0 0 1 0
## 86.11 0 0 1 0
## 86.14 1 0 0 0
## 87.7 1 0 0 0
## 87.9 0 1 0 0
## 88.91 0 0 0 1
## 89.7 1 0 0 0
## 89.77 0 0 0 1
## 90.3 0 1 0 0
## 91.61 1 0 0 0
## 91.98 0 0 1 0
## 93.63 0 0 1 0
## 94.21 0 0 0 1
## 94.89 1 0 0 0
## 96.48 1 0 0 0
aggregate(Promotion3.df$SalesInThousands, by=list(Week = Promotion3.df$Week), mean)
## Week x
## 1 1 55.77617
## 2 2 55.94915
## 3 3 54.37787
## 4 4 55.35468
It Can be clearly seen that Mean sales through out the week due to promotion1> Promotion2>Promotion3
mytable <- xtabs(~ SalesInThousands+Promotion, data = Medium.df)
mytable
## Promotion
## SalesInThousands 1 2 3
## 17.34 0 1 0
## 19.26 0 1 0
## 22.18 0 0 1
## 23.35 0 1 0
## 23.44 0 1 0
## 23.93 0 1 0
## 24.75 0 0 1
## 24.77 0 1 0
## 24.82 0 1 0
## 25.4 0 1 0
## 25.7 0 1 0
## 26.68 0 0 1
## 27.26 0 1 0
## 27.37 0 1 0
## 27.55 0 1 0
## 27.71 0 1 0
## 27.72 0 1 0
## 27.81 0 1 0
## 27.98 0 1 0
## 28.62 0 1 0
## 29.03 0 0 1
## 29.12 0 0 1
## 29.3 0 1 0
## 29.64 0 1 0
## 30.08 0 1 0
## 30.26 0 1 0
## 30.37 0 1 0
## 30.52 0 0 1
## 30.81 1 0 0
## 30.98 0 1 0
## 31.62 0 1 0
## 31.85 0 1 0
## 31.94 0 1 0
## 32.05 1 0 0
## 32.18 0 0 1
## 32.21 0 1 0
## 32.51 0 0 1
## 32.61 0 1 0
## 32.77 0 1 0
## 32.9 0 0 1
## 33.14 0 1 0
## 33.35 0 1 0
## 33.42 0 0 1
## 33.64 0 1 0
## 33.73 0 0 1
## 33.85 0 0 1
## 34.27 0 1 0
## 34.33 0 0 1
## 34.46 0 0 1
## 34.67 0 1 0
## 34.75 1 0 0
## 35.1 0 0 1
## 35.16 0 1 0
## 35.24 0 0 1
## 35.3 1 0 0
## 35.46 0 1 0
## 35.6 0 1 0
## 35.67 0 0 1
## 35.68 1 0 0
## 35.85 1 0 0
## 35.86 1 0 0
## 36.05 0 1 0
## 36.17 1 0 0
## 36.24 1 0 0
## 36.39 1 0 0
## 36.7 0 1 0
## 36.8 1 1 0
## 36.88 1 0 0
## 37.14 0 0 1
## 37.17 0 0 1
## 37.2 0 1 0
## 37.29 0 1 0
## 37.32 1 1 0
## 37.41 1 0 0
## 37.45 0 1 0
## 37.47 0 1 0
## 37.84 0 0 1
## 37.9 0 1 0
## 37.93 0 0 1
## 37.94 1 0 0
## 38.26 0 1 0
## 38.3 0 1 0
## 38.41 0 1 0
## 38.51 0 0 1
## 38.56 0 1 0
## 38.64 1 0 0
## 38.65 0 1 0
## 38.85 0 0 1
## 39.25 0 1 1
## 39.28 0 1 0
## 39.41 0 0 1
## 39.67 1 0 0
## 39.73 0 1 0
## 39.8 0 1 0
## 39.98 0 0 1
## 40.13 0 0 1
## 40.16 0 1 0
## 40.17 0 0 1
## 40.25 0 1 1
## 40.26 0 1 0
## 40.29 0 0 1
## 40.4 0 1 0
## 40.43 0 0 1
## 40.46 1 0 0
## 40.71 0 1 0
## 40.84 1 0 0
## 40.9 1 0 0
## 40.97 1 0 0
## 41.1 2 0 0
## 41.11 1 0 0
## 41.12 0 0 1
## 41.22 0 1 0
## 41.25 1 0 0
## 41.37 0 1 0
## 41.44 0 1 0
## 41.47 0 0 1
## 41.53 0 1 0
## 41.54 0 1 0
## 41.56 1 0 0
## 41.71 1 0 0
## 41.73 1 0 0
## 41.96 0 0 1
## 42.15 0 1 1
## 42.16 2 0 0
## 42.27 0 0 1
## 42.46 0 1 0
## 42.5 0 0 1
## 42.56 0 1 0
## 42.59 0 1 1
## 42.76 1 0 0
## 42.82 0 0 1
## 42.92 1 0 0
## 42.98 0 0 1
## 43.11 1 0 0
## 43.15 0 0 1
## 43.24 1 0 0
## 43.26 0 0 1
## 43.27 0 1 0
## 43.29 0 0 1
## 43.51 0 0 1
## 43.73 0 0 1
## 43.77 0 1 0
## 43.78 1 0 0
## 43.91 0 0 1
## 44.14 0 2 0
## 44.16 0 1 0
## 44.19 0 0 1
## 44.2 0 0 1
## 44.31 0 1 0
## 44.43 1 0 0
## 44.54 1 0 0
## 44.64 0 1 0
## 44.66 0 0 1
## 44.67 0 1 0
## 44.84 0 1 0
## 44.98 1 0 0
## 45.02 1 0 0
## 45.03 0 0 1
## 45.08 0 1 0
## 45.11 0 1 0
## 45.3 0 1 0
## 45.42 0 1 0
## 45.43 0 0 1
## 45.49 1 0 0
## 45.56 0 0 1
## 45.57 1 0 0
## 45.77 0 0 1
## 45.84 0 0 1
## 45.92 1 0 0
## 46.02 0 1 0
## 46.03 0 0 1
## 46.06 1 0 0
## 46.14 0 0 1
## 46.22 0 0 1
## 46.26 0 1 0
## 46.29 0 0 1
## 46.3 0 0 1
## 46.42 0 1 0
## 46.45 1 0 0
## 46.47 0 0 1
## 46.49 1 0 0
## 46.66 1 0 0
## 46.84 0 0 1
## 46.89 0 1 0
## 46.98 1 0 0
## 47.22 0 0 2
## 47.33 0 1 0
## 47.35 1 0 1
## 47.48 0 0 1
## 47.5 1 0 0
## 47.51 1 0 0
## 47.63 0 0 1
## 47.71 0 1 0
## 47.92 1 0 0
## 48.06 0 0 1
## 48.18 1 1 0
## 48.25 0 1 0
## 48.32 0 1 0
## 48.33 0 1 0
## 48.35 0 0 1
## 48.36 0 0 1
## 48.5 0 1 0
## 48.64 0 0 1
## 48.76 0 1 0
## 48.77 0 0 1
## 48.84 0 1 0
## 49.01 0 0 1
## 49.08 1 0 1
## 49.3 2 0 0
## 49.38 0 0 1
## 49.39 0 1 0
## 49.44 1 0 0
## 49.5 0 0 1
## 49.52 0 0 1
## 49.56 0 1 0
## 49.63 0 0 1
## 49.67 0 0 1
## 49.72 0 0 1
## 49.91 1 0 0
## 49.95 1 0 0
## 49.98 0 0 1
## 50.07 0 0 1
## 50.11 0 0 1
## 50.26 0 0 1
## 50.28 0 1 0
## 50.3 0 1 0
## 50.48 1 0 0
## 50.52 2 0 0
## 50.54 1 0 0
## 50.55 0 0 1
## 50.59 0 0 1
## 50.94 0 0 1
## 51.01 0 0 1
## 51.09 0 1 1
## 51.14 0 0 1
## 51.15 0 0 1
## 51.16 0 0 1
## 51.32 1 0 0
## 51.41 1 0 0
## 51.5 0 1 0
## 51.68 0 1 1
## 51.72 1 0 0
## 51.79 0 1 0
## 51.82 1 0 0
## 51.91 0 0 1
## 52.05 0 0 1
## 52.21 0 0 1
## 52.23 0 0 1
## 52.39 0 0 1
## 52.41 0 0 1
## 52.64 0 0 1
## 52.72 0 1 0
## 52.76 0 0 1
## 52.85 1 0 0
## 53.38 1 0 0
## 53.53 1 0 0
## 53.56 0 0 1
## 53.78 0 0 1
## 54.09 0 1 0
## 54.37 0 0 1
## 54.38 1 0 0
## 54.58 0 0 1
## 54.7 1 0 0
## 54.79 0 0 1
## 54.95 1 0 0
## 55.11 1 0 0
## 55.19 0 0 1
## 55.2 1 0 0
## 55.28 1 0 0
## 55.31 1 0 0
## 55.46 1 0 0
## 55.53 0 0 1
## 55.59 0 0 1
## 55.78 1 0 0
## 55.9 0 0 1
## 55.91 0 1 0
## 56.1 1 0 0
## 56.16 0 0 1
## 56.18 1 0 0
## 56.64 1 0 0
## 56.84 1 0 0
## 56.86 1 0 0
## 56.9 1 0 0
## 56.99 1 0 0
## 57.06 0 0 1
## 57.14 1 0 0
## 57.27 0 1 0
## 57.37 0 0 1
## 58 1 0 0
## 58.04 1 0 0
## 58.1 0 1 0
## 58.43 1 0 0
## 59.34 1 0 0
## 59.77 1 0 0
## 59.8 0 0 1
## 60.44 1 0 0
## 60.97 0 0 1
## 61.8 1 0 0
## 62.63 1 0 0
## 63.98 0 0 1
## 64.14 0 0 1
## 64.45 1 0 0
## 65.11 1 0 0
chisq.test(mytable)
## Warning in chisq.test(mytable): Chi-squared approximation may be incorrect
##
## Pearson's Chi-squared test
##
## data: mytable
## X-squared = 607.3, df = 604, p-value = 0.4547
aggregate(Medium.df$SalesInThousands, by=list(Promotion = Medium.df$Promotion), mean)
## Promotion x
## 1 1 47.67260
## 2 2 39.11435
## 3 3 45.46888
aggregate(Medium.df$SalesInThousands, by=list(Promotion = Medium.df$Promotion), sum)
## Promotion x
## 1 1 4576.57
## 2 2 4224.35
## 3 3 5274.39
P value > 0.01 so no relation between promotion and sales in Medium market also, also the sales of the product in medium market is less that that of Small market Also mean sales of Promotion1>Promotion2>Promotion3 but again for agregate sales promotion3>promotion2>promotion1
mytable <- xtabs(~ SalesInThousands+Promotion, data = Large.df)
mytable
## Promotion
## SalesInThousands 1 2 3
## 39.36 0 1 0
## 41.85 0 1 0
## 43.44 0 1 0
## 43.59 0 1 0
## 43.61 0 1 0
## 44.16 0 1 0
## 44.29 0 1 0
## 44.7 0 1 0
## 44.84 0 1 0
## 45.21 0 1 0
## 45.35 0 1 0
## 45.75 0 1 0
## 45.9 0 1 0
## 46.03 0 1 0
## 46.2 0 1 0
## 47.06 0 1 0
## 47.2 0 1 0
## 47.22 0 1 0
## 47.36 0 1 0
## 48.12 0 1 0
## 49.16 0 1 0
## 49.41 0 1 0
## 49.62 1 0 0
## 49.71 0 1 0
## 49.76 1 0 0
## 49.98 0 1 0
## 50.05 0 0 1
## 50.11 1 0 0
## 50.2 0 1 1
## 51.09 0 1 0
## 51.17 0 0 1
## 51.26 0 1 0
## 51.35 0 1 0
## 51.41 0 1 0
## 51.52 0 1 0
## 51.73 0 1 0
## 51.83 0 0 1
## 51.89 0 0 1
## 52.36 0 1 0
## 53.5 0 0 1
## 53.51 1 0 0
## 53.66 0 1 0
## 53.68 1 0 0
## 53.76 0 1 0
## 53.95 0 1 0
## 54.33 0 0 1
## 54.34 0 0 1
## 54.82 0 1 0
## 55.02 0 1 0
## 55.12 0 1 0
## 55.39 0 1 0
## 56.34 0 0 1
## 56.39 0 0 1
## 57.2 1 0 0
## 58.19 1 0 0
## 58.26 0 1 0
## 58.33 0 0 1
## 59.17 1 0 0
## 59.87 1 0 0
## 60.24 0 0 1
## 60.59 1 0 0
## 61.53 1 0 0
## 61.63 1 0 0
## 61.77 1 0 0
## 61.95 1 0 0
## 62.33 1 0 0
## 62.37 1 0 0
## 62.54 1 0 0
## 62.72 1 0 0
## 62.99 1 0 0
## 63.58 1 0 0
## 63.73 1 0 0
## 64.34 1 0 0
## 64.66 1 0 0
## 66.1 1 0 0
## 66.22 0 1 0
## 66.34 1 0 0
## 66.66 1 0 0
## 67.84 1 0 0
## 68.31 1 0 0
## 73.22 0 1 0
## 74.03 0 1 0
## 74.75 0 0 1
## 75.29 0 1 0
## 75.61 0 1 0
## 75.88 0 1 0
## 76.12 0 0 1
## 76.71 0 1 0
## 77.17 0 0 1
## 77.36 1 0 0
## 77.39 0 1 0
## 78.01 0 1 0
## 78.43 0 0 1
## 78.53 0 1 0
## 79.02 0 0 1
## 79.36 0 0 1
## 79.53 0 1 0
## 79.64 0 1 0
## 80.17 0 1 0
## 80.61 1 0 0
## 80.75 0 1 0
## 80.82 0 0 1
## 80.83 0 1 0
## 81.16 0 0 1
## 81.18 0 0 1
## 81.37 0 1 0
## 81.55 1 0 0
## 81.58 0 0 1
## 81.72 0 0 1
## 81.79 0 1 0
## 82.13 0 0 1
## 82.14 0 1 0
## 82.56 0 0 1
## 82.64 0 0 1
## 82.65 0 1 0
## 82.72 0 0 1
## 82.86 0 1 0
## 82.88 0 0 1
## 82.89 0 0 1
## 83.02 0 0 1
## 83.4 0 1 0
## 83.43 1 0 0
## 84.05 0 0 1
## 84.13 0 0 1
## 84.34 0 0 1
## 85.11 1 0 0
## 85.18 0 0 1
## 85.21 1 0 0
## 85.71 1 0 0
## 85.85 1 0 0
## 86.11 0 0 1
## 86.14 0 0 1
## 86.96 1 0 0
## 87.08 1 0 0
## 87.43 0 1 0
## 87.7 0 0 1
## 87.9 0 0 1
## 88.07 1 0 0
## 88.12 0 1 0
## 88.64 1 1 0
## 88.73 1 0 0
## 88.91 0 0 1
## 89.25 1 0 0
## 89.32 1 0 0
## 89.44 1 0 0
## 89.7 0 0 1
## 89.77 0 0 1
## 90.3 0 0 1
## 91.29 1 0 0
## 91.6 1 0 0
## 91.61 0 0 1
## 91.98 0 0 1
## 93.03 1 0 0
## 93.32 1 0 0
## 93.63 0 0 1
## 93.71 1 0 0
## 93.86 1 0 0
## 94.17 1 0 0
## 94.21 0 0 1
## 94.43 1 0 0
## 94.89 0 0 1
## 96.01 1 0 0
## 96.48 0 0 1
## 97.61 1 0 0
## 99.12 1 0 0
## 99.65 1 0 0
chisq.test(mytable)
## Warning in chisq.test(mytable): Chi-squared approximation may be incorrect
##
## Pearson's Chi-squared test
##
## data: mytable
## X-squared = 330.13, df = 330, p-value = 0.4877
aggregate(Large.df$SalesInThousands, by=list(Promotion = Large.df$Promotion), mean)
## Promotion x
## 1 1 75.23589
## 2 2 60.32203
## 3 3 77.20396
aggregate(Large.df$SalesInThousands, by=list(Promotion = Large.df$Promotion), sum)
## Promotion x
## 1 1 4213.21
## 2 2 3860.61
## 3 3 3705.79
P value > 0.01 so no relation between promotion and sales in Large Market also, also the sales of the product in Large market is greater than small and medium market as expected But mean sales of Promotion31>Promotion1>Promotion2 but this time agregate sales due to Promotion1>Promotion2>Promotion3
Model1 <- SalesInThousands ~
MarketSize +LocationID +AgeOfStore +Promotion +Week
fit1 <- lm(Model1, data = Project.df)
summary(fit1)
##
## Call:
## lm(formula = Model1, data = Project.df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.3477 -7.9005 0.9609 7.8503 25.3592
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 78.71444 2.12507 37.041 < 2e-16 ***
## MarketSizeMedium -26.95356 1.08634 -24.811 < 2e-16 ***
## MarketSizeSmall -17.55114 1.80793 -9.708 < 2e-16 ***
## LocationID -0.01418 0.00177 -8.013 6.9e-15 ***
## AgeOfStore 0.10316 0.07374 1.399 0.162
## Promotion -0.61694 0.59726 -1.033 0.302
## Week -0.16445 0.43088 -0.382 0.703
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.28 on 541 degrees of freedom
## Multiple R-squared: 0.552, Adjusted R-squared: 0.547
## F-statistic: 111.1 on 6 and 541 DF, p-value: < 2.2e-16
Model2 <- SalesInThousands ~
MarketSize +LocationID
fit2 <- lm(Model2, data = Project.df)
summary(fit2)
##
## Call:
## lm(formula = Model2, data = Project.df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.6864 -7.8978 0.7938 8.0269 25.4638
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 77.799484 1.297405 59.965 < 2e-16 ***
## MarketSizeMedium -26.848447 1.078206 -24.901 < 2e-16 ***
## MarketSizeSmall -17.223092 1.787925 -9.633 < 2e-16 ***
## LocationID -0.014113 0.001768 -7.983 8.54e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.28 on 544 degrees of freedom
## Multiple R-squared: 0.5495, Adjusted R-squared: 0.547
## F-statistic: 221.2 on 3 and 544 DF, p-value: < 2.2e-16
Model3 <- SalesInThousands ~
AgeOfStore +Promotion +Week
fit3 <- lm(Model3, data = Project.df)
summary(fit3)
##
## Call:
## lm(formula = Model3, data = Project.df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -36.465 -10.856 -2.798 7.006 44.298
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 56.83602 2.63759 21.548 <2e-16 ***
## AgeOfStore -0.06331 0.10818 -0.585 0.559
## Promotion -1.19274 0.88578 -1.347 0.179
## Week -0.16445 0.64058 -0.257 0.797
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 16.77 on 544 degrees of freedom
## Multiple R-squared: 0.004254, Adjusted R-squared: -0.001238
## F-statistic: 0.7746 on 3 and 544 DF, p-value: 0.5085
P values of regression analysis shows that the model1 and model2 are acceptable while model3 is not acceptable. Also Sales in thousand is affected by the location and market size but promotion and week and age of store do not have a significat affect on the Sales of the product
1.Market size is dependenat on LOcationID
2.Majority of sales has come from medium and large market. Medium being the higest.
3.Sales in all the weeks are almost same.
4.Agrregate sales due to Promotion3>promotion2>promotion1. Although the sales are not very sinificalty different. MAking Promotion 3 the best promotion stategy overall.
Considering Marketwise
small Market
5.P > 0.01 suggest that for small market there is no relationship between promotion and sales although mean Promotion1>Promotion2>Promotion3, agregate sales due Promotion3>Promotion1>Promotin2
Medium Market
6.P value > 0.01 so no relation between promotion and sales in Medium market also, also the sales of the product in medium market is less that that of Small market Also mean sales of Promotion1>Promotion2>Promotion3 but again for agregate sales promotion3>promotion2>promotion1
Large Market
7.P value > 0.01 so no relation between promotion and sales in Large Market also, also the sales of the product in Large market is greater than small and medium market as expected But mean sales of Promotion31>Promotion1>Promotion2 but this time agregate sales due to Promotion1>Promotion2>Promotion3
Regression
8.P values of regression analysis shows that the model1 and model2 are acceptable while model3 is not acceptable. Also Sales in thousand is affected by the location and market size but promotion and week and age of store do not have a significat affect on the Sales of the product
In this Project just by starting with some simple, plain language questions I was able to explore and visualize the marketing campaign data to find valuable insights between the promotions and the sales that were generated.
1.https://www.ibm.com/communities/analytics/watson-analytics-blog/marketing-campaign-eff-usec_-fastf/
2.Professor Sameer Mathur at the Indian Institute of Management (IIM), Lucknow
3.https://www.udemy.com/data-science-and-analytics-using-r/learn/v4/content
4.Kandasamy, P., “Engineering mathematics - Vol II, S.Chand &Company Ltd.,New Delhi, 1996.
5.Frvend John, E. and Miller Irwin, “Probability and Statistics for Engineers”, Prentice Hall, New York.
6.Allen A.O., “Probability statistics and Queuing theory with computer science applications”, Academic press, 1978.