store24 <- read.csv("C:/Program Files/RStudio/files/Store24.csv")
View(store24)
summary(store24)
## store Sales Profit MTenure
## Min. : 1.0 Min. : 699306 Min. :122180 Min. : 0.00
## 1st Qu.:19.5 1st Qu.: 984579 1st Qu.:211004 1st Qu.: 6.67
## Median :38.0 Median :1127332 Median :265014 Median : 24.12
## Mean :38.0 Mean :1205413 Mean :276314 Mean : 45.30
## 3rd Qu.:56.5 3rd Qu.:1362388 3rd Qu.:331314 3rd Qu.: 50.92
## Max. :75.0 Max. :2113089 Max. :518998 Max. :277.99
## CTenure Pop Comp Visibility
## Min. : 0.8871 Min. : 1046 Min. : 1.651 Min. :2.00
## 1st Qu.: 4.3943 1st Qu.: 5616 1st Qu.: 3.151 1st Qu.:3.00
## Median : 7.2115 Median : 8896 Median : 3.629 Median :3.00
## Mean : 13.9315 Mean : 9826 Mean : 3.788 Mean :3.08
## 3rd Qu.: 17.2156 3rd Qu.:14104 3rd Qu.: 4.230 3rd Qu.:4.00
## Max. :114.1519 Max. :26519 Max. :11.128 Max. :5.00
## PedCount Res Hours24 CrewSkill
## Min. :1.00 Min. :0.00 Min. :0.00 Min. :2.060
## 1st Qu.:2.00 1st Qu.:1.00 1st Qu.:1.00 1st Qu.:3.225
## Median :3.00 Median :1.00 Median :1.00 Median :3.500
## Mean :2.96 Mean :0.96 Mean :0.84 Mean :3.457
## 3rd Qu.:4.00 3rd Qu.:1.00 3rd Qu.:1.00 3rd Qu.:3.655
## Max. :5.00 Max. :1.00 Max. :1.00 Max. :4.640
## MgrSkill ServQual
## Min. :2.957 Min. : 57.90
## 1st Qu.:3.344 1st Qu.: 78.95
## Median :3.589 Median : 89.47
## Mean :3.638 Mean : 87.15
## 3rd Qu.:3.925 3rd Qu.: 99.90
## Max. :4.622 Max. :100.00
==> mean and standard deviation of Profit.
mean(store24$Profit)
## [1] 276313.6
sd(store24$Profit)
## [1] 89404.08
==> mean and standard deviation of MTenure.
mean(store24$MTenure)
## [1] 45.29644
sd(store24$MTenure)
## [1] 57.67155
==> mean and standard deviation of CTenure.
mean(store24$CTenure)
## [1] 13.9315
sd(store24$CTenure)
## [1] 17.69752
==> {StoreID, Sales, Profit, MTenure, CTenure} of the top 10 most profitable stores.
attach(store24)
profit_st <- store24[order(Profit),]
profit_st[1:10,]
## store Sales Profit MTenure CTenure Pop Comp Visibility
## 57 57 699306 122180 24.3485700 2.956879 3642 2.973376 3
## 66 66 879581 146058 115.2039000 3.876797 1046 6.569790 2
## 41 41 744211 147327 14.9180200 11.926080 9701 4.364600 2
## 55 55 925744 147672 6.6703910 18.365500 10532 6.389294 4
## 32 32 828918 149033 36.0792600 6.636550 9697 4.641468 3
## 13 13 857843 152513 0.6571813 1.577002 14186 4.435671 3
## 54 54 811190 159792 6.6703910 3.876797 3747 3.756011 3
## 52 52 1073008 169201 24.1185600 3.416838 14859 6.585143 3
## 61 61 716589 177046 21.8184200 13.305950 3014 3.263994 3
## 37 37 1202917 187765 23.1985000 1.347023 8870 4.491863 3
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## 57 2 1 1 3.35 2.956667 84.21266
## 66 3 1 1 4.03 3.673333 80.26675
## 41 3 1 1 3.03 3.672222 81.13993
## 55 3 1 1 3.49 3.477778 76.31346
## 32 3 1 0 3.28 3.550000 73.68654
## 13 2 1 1 4.10 3.000000 76.30609
## 54 2 1 1 3.08 3.933333 65.78734
## 52 3 1 1 3.83 3.833333 94.73510
## 61 1 1 1 3.07 3.126667 73.68654
## 37 3 1 1 3.38 4.016667 73.68654
==> {StoreID, Sales, Profit, MTenure, CTenure} of the top 10 least profitable stores.
attach(store24)
## The following objects are masked from store24 (pos = 3):
##
## Comp, CrewSkill, CTenure, Hours24, MgrSkill, MTenure,
## PedCount, Pop, Profit, Res, Sales, ServQual, store, Visibility
profit_st <- store24[order(-Profit),]
profit_st[1:10,]
## store Sales Profit MTenure CTenure Pop Comp Visibility
## 74 74 1782957 518998 171.09720 29.519510 10913 2.319850 3
## 7 7 1809256 476355 62.53080 7.326488 17754 3.377900 2
## 9 9 2113089 474725 108.99350 6.061602 26519 2.637630 2
## 6 6 1703140 469050 149.93590 11.351130 16926 3.184613 3
## 44 44 1807740 439781 182.23640 114.151900 20624 3.628561 3
## 2 2 1619874 424007 86.22219 6.636550 8630 4.235555 4
## 45 45 1602362 410149 47.64565 9.166325 17808 3.472609 5
## 18 18 1704826 394039 239.96980 33.774130 3807 3.994713 5
## 11 11 1583446 389886 44.81977 2.036961 21550 3.272398 2
## 47 47 1665657 387853 12.84790 6.636550 23623 2.422707 2
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## 74 4 1 0 3.50 4.405556 94.73878
## 7 5 1 1 3.94 4.100000 81.57837
## 9 4 1 1 3.22 3.583333 100.00000
## 6 4 1 0 3.58 4.605556 94.73510
## 44 4 0 1 4.06 4.172222 86.84327
## 2 3 1 1 3.20 3.556667 94.73510
## 45 3 1 1 3.58 4.622222 100.00000
## 18 3 1 1 3.18 3.866667 97.36939
## 11 5 1 1 3.43 3.200000 100.00000
## 47 5 1 1 4.23 3.950000 99.80105
==> Scatter plot of Profit vs. MTenure.
scatter.smooth(store24$MTenure, store24$Profit,xlab="Mtenure",ylab="Profit",main="Profit vs Mtenure")
==> Scatter plot of Profit vs. CTenure.
scatter.smooth(store24$CTenure, store24$Profit,xlab="Ctenure",ylab="Profit",main="Profit vs Ctenure")
==> Correlation Matrix for all the variables in the dataset.(up to 2 Decimal places)
options(digits = 2)
cor(store24)
## store Sales Profit MTenure CTenure Pop Comp Visibility
## store 1.000 -0.227 -0.200 -0.057 0.0199 -0.2894 0.032 -0.026
## Sales -0.227 1.000 0.924 0.455 0.2543 0.4035 -0.235 0.131
## Profit -0.200 0.924 1.000 0.439 0.2577 0.4306 -0.335 0.136
## MTenure -0.057 0.455 0.439 1.000 0.2434 -0.0609 0.181 0.157
## CTenure 0.020 0.254 0.258 0.243 1.0000 -0.0015 -0.070 0.067
## Pop -0.289 0.403 0.431 -0.061 -0.0015 1.0000 -0.268 -0.050
## Comp 0.032 -0.235 -0.335 0.181 -0.0703 -0.2683 1.000 0.028
## Visibility -0.026 0.131 0.136 0.157 0.0665 -0.0500 0.028 1.000
## PedCount -0.221 0.424 0.450 0.062 -0.0841 0.6076 -0.146 -0.141
## Res -0.031 -0.167 -0.159 -0.062 -0.3403 -0.2369 0.219 0.022
## Hours24 0.027 0.063 -0.026 -0.165 0.0729 -0.2218 0.130 0.047
## CrewSkill 0.049 0.164 0.160 0.102 0.2572 0.2828 -0.042 -0.197
## MgrSkill -0.072 0.312 0.323 0.230 0.1240 0.0836 0.224 0.073
## ServQual -0.322 0.386 0.362 0.182 0.0812 0.1239 0.018 0.210
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## store -0.2212 -0.031 0.027 0.049 -0.072 -0.3225
## Sales 0.4239 -0.167 0.063 0.164 0.312 0.3864
## Profit 0.4502 -0.159 -0.026 0.160 0.323 0.3625
## MTenure 0.0620 -0.062 -0.165 0.102 0.230 0.1817
## CTenure -0.0841 -0.340 0.073 0.257 0.124 0.0812
## Pop 0.6076 -0.237 -0.222 0.283 0.084 0.1239
## Comp -0.1463 0.219 0.130 -0.042 0.224 0.0181
## Visibility -0.1411 0.022 0.047 -0.197 0.073 0.2099
## PedCount 1.0000 -0.284 -0.276 0.214 0.087 -0.0054
## Res -0.2844 1.000 -0.089 -0.153 -0.032 0.0908
## Hours24 -0.2760 -0.089 1.000 0.105 -0.039 0.0583
## CrewSkill 0.2137 -0.153 0.105 1.000 -0.021 -0.0335
## MgrSkill 0.0875 -0.032 -0.039 -0.021 1.000 0.3567
## ServQual -0.0054 0.091 0.058 -0.034 0.357 1.0000
==> Correlation between Profit and MTenure.(up to 2 Decimal places)
cor.test(store24[,"Profit"],store24[,"MTenure"])
##
## Pearson's product-moment correlation
##
## data: store24[, "Profit"] and store24[, "MTenure"]
## t = 4, df = 70, p-value = 8e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.24 0.61
## sample estimates:
## cor
## 0.44
==> Correlation between Profit and MTenure.(up to 2 Decimal places)
cor.test(store24[,"Profit"],store24[,"CTenure"])
##
## Pearson's product-moment correlation
##
## data: store24[, "Profit"] and store24[, "CTenure"]
## t = 2, df = 70, p-value = 0.03
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.033 0.458
## sample estimates:
## cor
## 0.26
==> Corrgram based on all variables in the dataset.
library(corrgram)
corrgram(store24, order=TRUE, lower.panel=panel.shade,
upper.panel=panel.pie, text.panel=panel.txt)
==> Pearson’s Correlation test on the correlation between Profit and MTenure.
cor.test(store24[,"Profit"],store24[,"MTenure"],method="pearson")
##
## Pearson's product-moment correlation
##
## data: store24[, "Profit"] and store24[, "MTenure"]
## t = 4, df = 70, p-value = 8e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.24 0.61
## sample estimates:
## cor
## 0.44
p-value = 8e-05
==> Pearson’s Correlation test on the correlation between Profit and CTenure.
cor.test(store24[,"Profit"],store24[,"MTenure"],method="pearson")
##
## Pearson's product-moment correlation
##
## data: store24[, "Profit"] and store24[, "MTenure"]
## t = 4, df = 70, p-value = 8e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.24 0.61
## sample estimates:
## cor
## 0.44
p-value = 0.03
==> Regression of Profit on {MTenure, CTenure Comp, Pop, PedCount, Res, Hours24, Visibility}.
regression<-lm(Profit~MTenure+CTenure+Comp+Pop+PedCount+Res+Hours24+Visibility, data=store24)
summary(regression)
##
## Call:
## lm(formula = Profit ~ MTenure + CTenure + Comp + Pop + PedCount +
## Res + Hours24 + Visibility, data = store24)
##
## Residuals:
## Min 1Q Median 3Q Max
## -105789 -35946 -7069 33780 112390
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7610.04 66821.99 0.11 0.90967
## MTenure 760.99 127.09 5.99 9.7e-08 ***
## CTenure 944.98 421.69 2.24 0.02840 *
## Comp -25286.89 5491.94 -4.60 1.9e-05 ***
## Pop 3.67 1.47 2.50 0.01489 *
## PedCount 34087.36 9073.20 3.76 0.00037 ***
## Res 91584.68 39231.28 2.33 0.02262 *
## Hours24 63233.31 19641.11 3.22 0.00199 **
## Visibility 12625.45 9087.62 1.39 0.16941
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 57000 on 66 degrees of freedom
## Multiple R-squared: 0.638, Adjusted R-squared: 0.594
## F-statistic: 14.5 on 8 and 66 DF, p-value: 5.38e-12
fitted(regression)
## 1 2 3 4 5 6 7 8 9 10
## 282885 311617 247387 188867 308773 379779 392305 371985 443237 300475
## 11 12 13 14 15 16 17 18 19 20
## 390415 420779 210320 268640 279296 202381 352534 455293 256082 275088
## 21 22 23 24 25 26 27 28 29 30
## 277490 271166 309003 214341 246051 219299 258930 280699 210844 260035
## 31 32 33 34 35 36 37 38 39 40
## 197083 191247 207235 370486 318629 232328 240431 199027 260631 173787
## 41 42 43 44 45 46 47 48 49 50
## 237766 277756 375932 475486 350221 279391 399518 208750 215973 307813
## 51 52 53 54 55 56 57 58 59 60
## 282908 212114 252711 195980 214674 167064 227969 218550 265068 331876
## 61 62 63 64 65 66 67 68 69 70
## 192084 218926 238527 318618 293397 218980 261546 240964 280082 282110
## 71 72 73 74 75
## 205893 262435 269862 412871 252828
residuals(regression)
## 1 2 3 4 5 6 7 8 9
## -17871 112390 -24652 21255 -8293 89271 84050 -10870 31488
## 10 11 12 13 14 15 16 17 18
## -21850 -529 -91759 -57807 -7069 -75345 -6104 -86950 -61254
## 19 20 21 22 23 24 25 26 27
## 5413 -5853 5094 95870 -31589 53013 36073 -7387 -28736
## 28 29 30 31 32 33 34 35 36
## -7663 53112 73572 14802 -42214 85510 11713 3995 -13036
## 37 38 39 40 41 42 43 44 45
## -52666 4157 -39501 49126 -90439 -13684 -38699 -35705 59928
## 46 47 48 49 50 51 52 53 54
## 36389 -11665 75419 -20697 -56800 -45564 -42913 112307 -36188
## 55 56 57 58 59 60 61 62 63
## -67002 22171 -105789 9051 38001 24195 -15038 -16285 509
## 64 65 66 67 68 69 70 71 72
## -97461 8244 -72922 100521 -4625 95311 -27907 -7364 -65663
## 73 74 75
## 9331 106127 43998
For every one month increase in the tenure of the manager at Store24, the profit goes up by 761, and for every one month increase in the tenure of the crew at Store24, the profit goes up by 945.
We can see that profit has the strongest correlation with crew tenure and with manager tenure. the crew skill is directly dependent on the crew tenure, meaning crew retention will lead to increase in skills, which inturn leads to higher profits.
From this analysis and taking into consideration the different correlation plots, we can say that Profit is very closely linked with sales. The tenure of the MTenure is more dominant in getting more profits than the tenure of the CTenure. If a store was present in a resedntial area, it had more profits than the stores which had more competitiors in a half mile radius. This can be explained in a matter of probability as the competitor could possibly get a fraction of the customers. Also a store located in a densely populated area had more profits than the stores which had competitors around.
R square value is:0.6379.It means that 63.79% of variations in the dependent variable is explained by the independent variable.
Regarding the regression part,the p-value of the model is statistically significant.It means it is a good fit model.
R square value is:0.6379.It means that 63.79% of variations in the dependent variable is explained by the independent variable.
Adjusted R square value is 0.594.It means 59.4% variation in the dependent variable is explained by the independent variable.This values decreases as we add no of independent variables.
Variables MTenure, CTenure, Comp, Pop, PedCount, Res, Hours24 are statistically significant as their p-values are < 0.05.Only Visibility variable is insignificant.