Session_9

Om Joy Halder
16-10-2017

What is the mean, standard deviation and variance of the sales of Coke?

Storedata <- read.csv(paste("StoreData.csv", sep=" "))
mean(Storedata$p1sales)
[1] 133.0486
sd(Storedata$p1sales)
[1] 28.3726
var(Storedata$p1sales)
[1] 805.0044

What is the correlation of the sales of Coke with the promotions of Coke?

cor(Storedata$p1sales,Storedata$p2sales)
[1] -0.5583594

What is the correlation of the sales of Coke with the promotions of Pepsi?

cor(Storedata$p1sales,Storedata$p2prom)
[1] -0.01334702

Create a correlation matrix of the sales and prices of Coke and Pepsi versus the promotions of Coke and Pepsi.

x <- subset(Storedata[c(4,5,6,7)])
y <- subset(Storedata[c(8,9)])
z<- cor(x,y)
round(z,3)
        p1prom p2prom
p1sales  0.421 -0.013
p2sales -0.014  0.560
p1price -0.015  0.024
p2price -0.001 -0.012

Draw a corrgram illustrating the previous question

library(corrgram)
corrgram(Storedata[,c(4:7,8:9)], order=FALSE, lower.panel=panel.conf,
         upper.panel=panel.pie, text.panel=panel.txt,
         main="Corrgram - Storedata")

plot of chunk unnamed-chunk-5

Test the null hypothesis that the sales of Pepsi are uncorrelated with Pepsi's promotions

cor.test(Storedata$p2sales, Storedata$p2prom)

    Pearson's product-moment correlation

data:  Storedata$p2sales and Storedata$p2prom
t = 30.804, df = 2078, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 0.5296696 0.5887155
sample estimates:
     cor 
0.559903 

Test the null hypothesis that the sales of Pepsi are uncorrelated with Coke's promotions

cor.test(Storedata$p2sales, Storedata$p1prom)

    Pearson's product-moment correlation

data:  Storedata$p2sales and Storedata$p1prom
t = -0.6361, df = 2078, p-value = 0.5248
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.05689831  0.02904415
sample estimates:
        cor 
-0.01395285 

Run a simple linear regression of the sales of Coke on the price of Coke

regr<-lm(Storedata$p1sales~Storedata$p2price)
summary(regr)

Call:
lm(formula = Storedata$p1sales ~ Storedata$p2price)

Residuals:
    Min      1Q  Median      3Q     Max 
-58.002 -17.884  -2.643  14.177 106.998 

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)    
(Intercept)          6.716      4.317   1.555     0.12    
Storedata$p2price   46.798      1.588  29.478   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 23.83 on 2078 degrees of freedom
Multiple R-squared:  0.2949,    Adjusted R-squared:  0.2945 
F-statistic:   869 on 1 and 2078 DF,  p-value: < 2.2e-16

Run another simple linear regression of the sales of Pepsi on the price of Pepsi

regr2<-lm(Storedata$p2sales~Storedata$p2price)
summary(regr2)

Call:
lm(formula = Storedata$p2sales ~ Storedata$p2price)

Residuals:
    Min      1Q  Median      3Q     Max 
-45.657 -15.657  -3.077  11.400 110.184 

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)    
(Intercept)        196.788      3.877   50.76   <2e-16 ***
Storedata$p2price  -35.796      1.425  -25.11   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 21.4 on 2078 degrees of freedom
Multiple R-squared:  0.2328,    Adjusted R-squared:  0.2324 
F-statistic: 630.6 on 1 and 2078 DF,  p-value: < 2.2e-16

Compare the two simple linear regressions. The sales of which product are more responsive to a change in its price?

For Coke, Beta = -52.7 For Pepsi, Beta = -35.8

Thus, the sales of Coke are more responsive to a change in its price. The sales of Coke increase by 52.7 units for unit decrease in its price. Whereas for Pepsi, there is an increase in sales of only 35.8 units for unit decrease in its price.