store.df<- read.csv("store24.csv",sep = ",")
View(store.df)
mean(store.df$Profit)
## [1] 276313.6
sd(store.df$Profit)
## [1] 89404.08
mean(store.df$MTenure)
## [1] 45.29644
sd(store.df$MTenure)
## [1] 57.67155
mean(store.df$CTenure)
## [1] 13.9315
sd(store.df$CTenure)
## [1] 17.69752
```
newdata1 <- store.df[order(store.df$store),]
newdata1[1:10,]
## store Sales Profit MTenure CTenure Pop Comp Visibility
## 1 1 1060294 265014 0.00000 24.804930 7535 2.797888 3
## 2 2 1619874 424007 86.22219 6.636550 8630 4.235555 4
## 3 3 1099921 222735 23.88854 5.026694 9695 4.494666 3
## 4 4 1053860 210122 0.00000 5.371663 2797 4.253946 4
## 5 5 1227841 300480 3.87737 6.866530 20335 1.651364 2
## 6 6 1703140 469050 149.93590 11.351130 16926 3.184613 3
## 7 7 1809256 476355 62.53080 7.326488 17754 3.377900 2
## 8 8 1378482 361115 0.00000 56.772080 20824 2.895114 4
## 9 9 2113089 474725 108.99350 6.061602 26519 2.637630 2
## 10 10 1080979 278625 31.47899 23.195070 16381 2.270771 4
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## 1 3 1 1 3.56 3.150000 86.84327
## 2 3 1 1 3.20 3.556667 94.73510
## 3 3 1 1 3.80 4.116667 78.94776
## 4 2 1 1 2.06 4.100000 100.00000
## 5 5 0 1 3.65 3.588889 68.42164
## 6 4 1 0 3.58 4.605556 94.73510
## 7 5 1 1 3.94 4.100000 81.57837
## 8 3 1 1 3.98 3.800000 78.94776
## 9 4 1 1 3.22 3.583333 100.00000
## 10 3 1 0 3.54 3.561111 100.00000
newdata2 <- store.df[order(store.df$Sales),]
newdata2[1:10,]
## store Sales Profit MTenure CTenure Pop Comp Visibility
## 57 57 699306 122180 24.3485700 2.956879 3642 2.973376 3
## 61 61 716589 177046 21.8184200 13.305950 3014 3.263994 3
## 41 41 744211 147327 14.9180200 11.926080 9701 4.364600 2
## 54 54 811190 159792 6.6703910 3.876797 3747 3.756011 3
## 32 32 828918 149033 36.0792600 6.636550 9697 4.641468 3
## 72 72 848140 196772 126.4745000 27.449690 3151 3.680586 2
## 13 13 857843 152513 0.6571813 1.577002 14186 4.435671 3
## 66 66 879581 146058 115.2039000 3.876797 1046 6.569790 2
## 16 16 883864 196277 23.6585300 4.681725 6872 3.344703 3
## 26 26 898548 211912 0.6571813 20.435320 9999 4.178195 3
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## 57 2 1 1 3.35 2.956667 84.21266
## 61 1 1 1 3.07 3.126667 73.68654
## 41 3 1 1 3.03 3.672222 81.13993
## 54 2 1 1 3.08 3.933333 65.78734
## 32 3 1 0 3.28 3.550000 73.68654
## 72 1 1 1 3.73 3.416667 73.68654
## 13 2 1 1 4.10 3.000000 76.30609
## 66 3 1 1 4.03 3.673333 80.26675
## 16 3 1 0 3.05 4.000000 97.36939
## 26 2 1 1 3.52 3.100000 97.36939
newdata3 <- store.df[order(store.df$Profit),]
newdata3[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
newdata4 <- store.df[order(store.df$MTenure),]
newdata4[1:10,]
## store Sales Profit MTenure CTenure Pop Comp Visibility
## 1 1 1060294 265014 0.0000000 24.8049300 7535 2.797888 3
## 4 4 1053860 210122 0.0000000 5.3716630 2797 4.253946 4
## 8 8 1378482 361115 0.0000000 56.7720800 20824 2.895114 4
## 15 15 1005627 203951 0.0000000 8.4763860 8684 3.844220 3
## 25 25 1282886 282124 0.0000000 10.3162200 6183 3.517020 3
## 31 31 993597 211885 0.0000000 10.7761800 2578 3.100689 2
## 64 64 969509 221157 0.0000000 0.8870637 17110 2.378613 4
## 13 13 857843 152513 0.6571813 1.5770020 14186 4.435671 3
## 26 26 898548 211912 0.6571813 20.4353200 9999 4.178195 3
## 75 75 1321870 296826 2.2672760 8.7063660 8966 1.886111 4
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## 1 3 1 1 3.56 3.150000 86.84327
## 4 2 1 1 2.06 4.100000 100.00000
## 8 3 1 1 3.98 3.800000 78.94776
## 15 4 1 1 3.50 3.427778 94.73510
## 25 3 1 1 2.93 3.500000 86.84327
## 31 2 1 1 2.86 3.673333 88.92860
## 64 3 1 1 3.28 3.311111 79.47388
## 13 2 1 1 4.10 3.000000 76.30609
## 26 2 1 1 3.52 3.100000 97.36939
## 75 4 0 1 3.57 3.344445 89.47388
newdata5 <- store.df[order(store.df$CTenure),]
newdata5[1:10,]
## store Sales Profit MTenure CTenure Pop Comp Visibility
## 64 64 969509 221157 0.0000000 0.8870637 17110 2.378613 4
## 37 37 1202917 187765 23.1985000 1.3470230 8870 4.491863 3
## 13 13 857843 152513 0.6571813 1.5770020 14186 4.435671 3
## 38 38 991524 203184 15.6080600 1.5770020 6557 4.225993 3
## 11 11 1583446 389886 44.8197700 2.0369610 21550 3.272398 2
## 68 68 1018195 236339 17.4481600 2.2669400 9018 3.504810 4
## 56 56 916197 189235 4.7974240 2.7268990 13740 4.597269 2
## 14 14 1171491 261571 87.3722600 2.9568790 6898 4.233057 4
## 57 57 699306 122180 24.3485700 2.9568790 3642 2.973376 3
## 23 23 1351972 277414 12.3878700 3.4168380 13797 3.594539 3
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## 64 3 1 1 3.28 3.311111 79.47388
## 37 3 1 1 3.38 4.016667 73.68654
## 13 2 1 1 4.10 3.000000 76.30609
## 38 2 1 1 3.68 4.494444 100.00000
## 11 5 1 1 3.43 3.200000 100.00000
## 68 2 1 1 2.83 3.000000 81.31677
## 56 3 1 0 3.10 3.800000 64.35046
## 14 2 1 1 2.54 3.890000 100.00000
## 57 2 1 1 3.35 2.956667 84.21266
## 23 4 1 1 3.65 3.588889 100.00000
newdata6 <- store.df[order(-store.df$store),]
newdata6[1:10,]
## store Sales Profit MTenure CTenure Pop Comp Visibility
## 75 75 1321870 296826 2.267276 8.706366 8966 1.886111 4
## 74 74 1782957 518998 171.097200 29.519510 10913 2.319850 3
## 73 73 1115450 279193 41.139550 6.406571 6276 4.180132 4
## 72 72 848140 196772 126.474500 27.449690 3151 3.680586 2
## 71 71 977566 198529 43.899720 38.373720 3265 3.856324 2
## 70 70 1207204 254203 14.918020 3.876797 19809 3.122484 3
## 69 69 1574290 375393 44.129730 26.759750 5050 3.949484 3
## 68 68 1018195 236339 17.448160 2.266940 9018 3.504810 4
## 67 67 1228052 362067 5.257451 3.416838 11552 3.583143 3
## 66 66 879581 146058 115.203900 3.876797 1046 6.569790 2
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## 75 4 0 1 3.57 3.344445 89.47388
## 74 4 1 0 3.50 4.405556 94.73878
## 73 3 1 1 3.20 4.083333 85.96640
## 72 1 1 1 3.73 3.416667 73.68654
## 71 1 1 1 3.88 3.466667 79.94253
## 70 4 1 0 3.24 3.538889 78.94407
## 69 3 1 1 3.56 3.940000 92.89294
## 68 2 1 1 2.83 3.000000 81.31677
## 67 3 1 1 3.37 4.150000 97.36939
## 66 3 1 1 4.03 3.673333 80.26675
newdata7 <- store.df[order(-store.df$Sales),]
newdata7[1:10,]
## store Sales Profit MTenure CTenure Pop Comp Visibility
## 9 9 2113089 474725 108.99350 6.061602 26519 2.637630 2
## 30 30 1874873 333607 73.34144 23.425050 1116 3.578323 3
## 7 7 1809256 476355 62.53080 7.326488 17754 3.377900 2
## 44 44 1807740 439781 182.23640 114.151900 20624 3.628561 3
## 74 74 1782957 518998 171.09720 29.519510 10913 2.319850 3
## 18 18 1704826 394039 239.96980 33.774130 3807 3.994713 5
## 6 6 1703140 469050 149.93590 11.351130 16926 3.184613 3
## 47 47 1665657 387853 12.84790 6.636550 23623 2.422707 2
## 2 2 1619874 424007 86.22219 6.636550 8630 4.235555 4
## 45 45 1602362 410149 47.64565 9.166325 17808 3.472609 5
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## 9 4 1 1 3.22 3.583333 100.00000
## 30 2 1 1 3.52 3.473333 100.00000
## 7 5 1 1 3.94 4.100000 81.57837
## 44 4 0 1 4.06 4.172222 86.84327
## 74 4 1 0 3.50 4.405556 94.73878
## 18 3 1 1 3.18 3.866667 97.36939
## 6 4 1 0 3.58 4.605556 94.73510
## 47 5 1 1 4.23 3.950000 99.80105
## 2 3 1 1 3.20 3.556667 94.73510
## 45 3 1 1 3.58 4.622222 100.00000
newdata8 <- store.df[order(-store.df$Profit),]
newdata8[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
newdata9 <- store.df[order(-store.df$MTenure),]
newdata9[1:10,]
## store Sales Profit MTenure CTenure Pop Comp Visibility
## 12 12 1444714 329020 277.9877 6.636550 11160 4.903895 4
## 18 18 1704826 394039 239.9698 33.774130 3807 3.994713 5
## 44 44 1807740 439781 182.2364 114.151900 20624 3.628561 3
## 43 43 1296711 337233 177.5704 5.486653 3495 3.653641 4
## 74 74 1782957 518998 171.0972 29.519510 10913 2.319850 3
## 65 65 1349972 301641 150.2317 23.425050 1075 3.218960 3
## 6 6 1703140 469050 149.9359 11.351130 16926 3.184613 3
## 72 72 848140 196772 126.4745 27.449690 3151 3.680586 2
## 40 40 1042664 222913 122.7943 16.755650 2521 11.127880 3
## 66 66 879581 146058 115.2039 3.876797 1046 6.569790 2
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## 12 4 1 0 3.35 3.238889 100.00000
## 18 3 1 1 3.18 3.866667 97.36939
## 44 4 0 1 4.06 4.172222 86.84327
## 43 3 1 1 3.73 3.608233 94.73510
## 74 4 1 0 3.50 4.405556 94.73878
## 65 1 1 1 3.73 3.440000 63.15673
## 6 4 1 0 3.58 4.605556 94.73510
## 72 1 1 1 3.73 3.416667 73.68654
## 40 4 1 1 3.45 4.194445 78.94776
## 66 3 1 1 4.03 3.673333 80.26675
newdata10 <- store.df[order(-store.df$CTenure),]
newdata10[1:10,]
## store Sales Profit MTenure CTenure Pop Comp Visibility
## 44 44 1807740 439781 182.236400 114.15190 20624 3.628561 3
## 42 42 1273855 264072 2.497289 86.09446 2106 3.231049 3
## 8 8 1378482 361115 0.000000 56.77208 20824 2.895114 4
## 71 71 977566 198529 43.899720 38.37372 3265 3.856324 2
## 18 18 1704826 394039 239.969800 33.77413 3807 3.994713 5
## 74 74 1782957 518998 171.097200 29.51951 10913 2.319850 3
## 72 72 848140 196772 126.474500 27.44969 3151 3.680586 2
## 69 69 1574290 375393 44.129730 26.75975 5050 3.949484 3
## 22 22 1433440 367036 18.368220 25.95483 8280 4.464360 4
## 1 1 1060294 265014 0.000000 24.80493 7535 2.797888 3
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## 44 4 0 1 4.06 4.172222 86.84327
## 42 2 1 1 3.44 3.656667 98.68839
## 8 3 1 1 3.98 3.800000 78.94776
## 71 1 1 1 3.88 3.466667 79.94253
## 18 3 1 1 3.18 3.866667 97.36939
## 74 4 1 0 3.50 4.405556 94.73878
## 72 1 1 1 3.73 3.416667 73.68654
## 69 3 1 1 3.56 3.940000 92.89294
## 22 3 1 1 3.30 3.973333 100.00000
## 1 3 1 1 3.56 3.150000 86.84327
plot(store.df$Profit,store.df$MTenure,
main = "Analysis of profit with respect to MTenure ",
xlab = "Profit of the store",
ylab = "MTenure of the store")
options(digits=2)
cor(store.df$Profit, store.df$MTenure)
## [1] 0.44
cor(store.df$Profit, store.df$CTenure)
## [1] 0.26
cor.test(store.df[,"Profit"], store.df[,"MTenure"])
##
## Pearson's product-moment correlation
##
## data: store.df[, "Profit"] and store.df[, "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
cor.test(store.df[,"Profit"], store.df[,"CTenure"])
##
## Pearson's product-moment correlation
##
## data: store.df[, "Profit"] and store.df[, "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
options(digits=2)
cor(store.df, use="complete.obs", method="kendall")
## store Sales Profit MTenure CTenure Pop Comp Visibility
## store 1.0000 -0.157 -0.141 -0.0105 -0.0062 -0.186 -0.019 -0.0163
## Sales -0.1575 1.000 0.779 0.2562 0.1387 0.200 -0.179 0.1457
## Profit -0.1409 0.779 1.000 0.2467 0.1916 0.230 -0.259 0.1403
## MTenure -0.0105 0.256 0.247 1.0000 0.0965 -0.042 0.121 0.0068
## CTenure -0.0062 0.139 0.192 0.0965 1.0000 -0.128 -0.107 0.0500
## Pop -0.1863 0.200 0.230 -0.0424 -0.1279 1.000 -0.113 0.0118
## Comp -0.0191 -0.179 -0.259 0.1214 -0.1068 -0.113 1.000 0.0670
## Visibility -0.0163 0.146 0.140 0.0068 0.0500 0.012 0.067 1.0000
## PedCount -0.1378 0.315 0.317 -0.0017 -0.0538 0.461 -0.215 -0.1127
## Res -0.0258 -0.134 -0.150 0.0442 -0.1013 -0.170 0.186 0.0162
## Hours24 0.0221 0.073 0.023 -0.0882 0.0215 -0.238 0.102 0.0381
## CrewSkill -0.0319 0.113 0.107 0.1180 0.1675 0.158 -0.046 -0.1783
## MgrSkill -0.0621 0.175 0.149 0.1873 0.0152 0.033 0.170 0.0059
## ServQual -0.2278 0.277 0.251 0.1697 0.0578 0.065 0.059 0.1581
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## store -0.1378 -0.026 0.0221 -0.032 -0.0621 -0.228
## Sales 0.3148 -0.134 0.0732 0.113 0.1755 0.277
## Profit 0.3173 -0.150 0.0235 0.107 0.1495 0.251
## MTenure -0.0017 0.044 -0.0882 0.118 0.1873 0.170
## CTenure -0.0538 -0.101 0.0215 0.167 0.0152 0.058
## Pop 0.4606 -0.170 -0.2375 0.158 0.0332 0.065
## Comp -0.2154 0.186 0.1022 -0.046 0.1704 0.059
## Visibility -0.1127 0.016 0.0381 -0.178 0.0059 0.158
## PedCount 1.0000 -0.255 -0.2850 0.123 0.0490 -0.054
## Res -0.2553 1.000 -0.0891 -0.158 -0.0311 0.088
## Hours24 -0.2850 -0.089 1.0000 0.140 0.0042 0.045
## CrewSkill 0.1229 -0.158 0.1395 1.000 0.0501 -0.013
## MgrSkill 0.0490 -0.031 0.0042 0.050 1.0000 0.241
## ServQual -0.0536 0.088 0.0447 -0.013 0.2407 1.000
library(car)
scatterplotMatrix(store.df[,c("Profit","MTenure","CTenure","Comp","Pop","PedCount")],
spread=FALSE, smoother.args=list(lty=2),
main="Scatter Plot Matrix")
library(corrgram)
corrgram(store.df, order=FALSE,
lower.panel=panel.shade,
upper.panel=panel.pie,
diag.panel=panel.minmax,
text.panel=panel.txt,
main="Corrgram of store.df intercorrelations")
m1 <- lm(Profit ~
MTenure
+ CTenure
+ Pop
+ PedCount
+ Res
+ Visibility
+ Hours24
+ Comp,
data=store.df)
summary(m1)
##
## Call:
## lm(formula = Profit ~ MTenure + CTenure + Pop + PedCount + Res +
## Visibility + Hours24 + Comp, data = store.df)
##
## 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 *
## 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 *
## Visibility 12625.45 9087.62 1.39 0.16941
## Hours24 63233.31 19641.11 3.22 0.00199 **
## Comp -25286.89 5491.94 -4.60 1.9e-05 ***
## ---
## 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
m1$coefficients
## (Intercept) MTenure CTenure Pop PedCount Res
## 7610.0 761.0 945.0 3.7 34087.4 91584.7
## Visibility Hours24 Comp
## 12625.4 63233.3 -25286.9
List the explanatory variable(s) whose beta-coefficients are statistically significant (p < 0.05). Ctenure, Pop, Pedcount, Res, Visibility, Hours24, Comp List the explanatory variable(s) whose beta-coefficients are not statistically significant (p > 0.05). Mtenure
Executive Summary * An increase in MTenure by 1 month, increases Profit by $810.97 * An increase in CTenure by 1 month, increases Profit by $1016.02