mydata <- read.csv(paste('Store24.csv', sep =""))
Summary
## groupGenericFunction for "Summary" defined from package "base"
##
## function (x, ..., na.rm = FALSE)
## standardGeneric("Summary")
## <bytecode: 0x000000001ae77ab0>
## <environment: 0x000000001926cb88>
## Methods may be defined for arguments: x, na.rm
## Use showMethods("Summary") for currently available ones.
summary(mydata)
## 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(mydata$Profit)
## [1] 276313.6
sd(mydata$Profit)
## [1] 89404.08
mean(mydata$CTenure)
## [1] 13.9315
sd(mydata$CTenure)
## [1] 17.69752
,,,
mean(mydata$MTenure)
## [1] 45.29644
sd(mydata$MTenure)
## [1] 57.67155
attach(mydata)
View(mydata)
newdata <- mydata[order(-store, Sales, Profit, MTenure, CTenure),] #sort by Store, Sales, Profit, MTenure, CTenure (descending)
newdata3 <- mydata[order(-Profit),] #Sort by Profit (ascending)
View(newdata3)
newdata3[1:10,] #See the first 10 rows
## 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
newdata4 <- mydata[order(-Profit),] #Sort by Profit (descending)
View(newdata4)
newdata4[1:10,] #See the first 10 rows
## 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
library(car)
## Warning: package 'car' was built under R version 3.4.3
scatterplot(MTenure,Profit, main="Profit vs MTenure")
Visualising with scatterplot Profit Vs CTenure ========================================================
library(car)
scatterplot(CTenure,Profit, main="Profit vs CTenure")
options(digits = 2)
cor(mydata)
## 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
x <- mydata[,c("Profit")]
y <- mydata[,c("MTenure")]
cor(x,y)
## [1] 0.44
x <- mydata[,c("Profit")]
z <- mydata[,c("CTenure")]
cor(x,z)
## [1] 0.26
library(corrgram)
## Warning: package 'corrgram' was built under R version 3.4.3
corrgram(mydata, order=TRUE, lower.panel=panel.shade,
upper.panel=panel.pie, text.panel=panel.txt,
main="Corrgram of mydata intercorrelations")
There is a negative relation between profit and competition There is a stronger positive relationship between profit and sales There is weaker positive relationship between profit and MTenure There is a positive relationship between profit and CTenure There is a weaker positive relationship between profit and CrewSkill
x <- mydata[,c("Profit")]
y <- mydata[,c("MTenure")]
cor.test(x,y, method = c("pearson"))
##
## Pearson's product-moment correlation
##
## data: x and y
## 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
x <- mydata[,c("Profit")]
z <- mydata[,c("CTenure")]
cor.test(x,z, method = c("pearson"))
##
## Pearson's product-moment correlation
##
## data: x and z
## 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
Run a regression of Profit on {MTenure, CTenure Comp, Pop, PedCount, Res, Hours24, Visibility}
fit <- lm(Profit ~ MTenure + CTenure + Res + Pop + Comp + PedCount + Hours24 + Visibility, data=mydata)
summary(fit)
##
## Call:
## lm(formula = Profit ~ MTenure + CTenure + Res + Pop + Comp +
## PedCount + Hours24 + Visibility, data = mydata)
##
## 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 *
## Res 91584.68 39231.28 2.33 0.02262 *
## Pop 3.67 1.47 2.50 0.01489 *
## Comp -25286.89 5491.94 -4.60 1.9e-05 ***
## PedCount 34087.36 9073.20 3.76 0.00037 ***
## 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
a)It may raise the profits by $760 b)It may raise the profits by $945
Executive Summary
Changes in Managerial or Crew tenure wouldn’t have siginificant effect on the profits of the store with 100% confidence and 99% confidence respectively. If stores are located more near residential area then profits might increase with 99% confidence If stores provide near to or complete 24 hour services then profits can increase with 99% confidence ``Note that theecho = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.