setwd("C:/Users/lenovo/Desktop/se")
store.df<- read.csv("Store24.csv")
library(psych)
## Warning: package 'psych' was built under R version 3.3.3
describe(store.df[1:11])
## vars n mean sd median trimmed mad
## store 1 75 38.00 21.79 38.00 38.00 28.17
## Sales 2 75 1205413.12 304531.31 1127332.00 1182031.25 288422.04
## Profit 3 75 276313.61 89404.08 265014.00 270260.34 90532.00
## MTenure 4 75 45.30 57.67 24.12 33.58 29.67
## CTenure 5 75 13.93 17.70 7.21 10.60 6.14
## Pop 6 75 9825.59 5911.67 8896.00 9366.07 7266.22
## Comp 7 75 3.79 1.31 3.63 3.66 0.82
## Visibility 8 75 3.08 0.75 3.00 3.07 0.00
## PedCount 9 75 2.96 0.99 3.00 2.97 1.48
## Res 10 75 0.96 0.20 1.00 1.00 0.00
## Hours24 11 75 0.84 0.37 1.00 0.92 0.00
## min max range skew kurtosis se
## store 1.00 75.00 74.00 0.00 -1.25 2.52
## Sales 699306.00 2113089.00 1413783.00 0.71 -0.09 35164.25
## Profit 122180.00 518998.00 396818.00 0.62 -0.21 10323.49
## MTenure 0.00 277.99 277.99 2.01 3.90 6.66
## CTenure 0.89 114.15 113.26 3.52 15.00 2.04
## Pop 1046.00 26519.00 25473.00 0.62 -0.23 682.62
## Comp 1.65 11.13 9.48 2.48 11.31 0.15
## Visibility 2.00 5.00 3.00 0.25 -0.38 0.09
## PedCount 1.00 5.00 4.00 0.00 -0.52 0.11
## Res 0.00 1.00 1.00 -4.60 19.43 0.02
## Hours24 0.00 1.00 1.00 -1.82 1.32 0.04
mean(store.df$Profit)
## [1] 276313.6
mean(store.df$MTenure )
## [1] 45.29644
mean(store.df$CTenure)
## [1] 13.9315
new <- store.df[order(store.df$Profit ),]
print(new[1:10,1:11])
## 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
## 57 2 1 1
## 66 3 1 1
## 41 3 1 1
## 55 3 1 1
## 32 3 1 0
## 13 2 1 1
## 54 2 1 1
## 52 3 1 1
## 61 1 1 1
## 37 3 1 1
new <- store.df[order(-store.df$Profit ),]
print(new[1:10,1:11])
## 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
## 74 4 1 0
## 7 5 1 1
## 9 4 1 1
## 6 4 1 0
## 44 4 0 1
## 2 3 1 1
## 45 3 1 1
## 18 3 1 1
## 11 5 1 1
## 47 5 1 1
library(car)
## Warning: package 'car' was built under R version 3.3.3
##
## Attaching package: 'car'
## The following object is masked from 'package:psych':
##
## logit
scatterplot(x=store.df$MTenure, y=store.df$Profit, main = "Profit VS MTenure" ,xlab = "MTenure", ylab = "Profit",col=" red" )
## Scatter plot Profit vs CTenure
library(car)
scatterplot(x=store.df$CTenure, y=store.df$Profit, main = "Profit VS MTenure" ,xlab = "MTenure", ylab = "Profit",col="red" )
options(digits = 1)
cor(store.df)
## store Sales Profit MTenure CTenure Pop Comp Visibility
## store 1.00 -0.23 -0.20 -0.06 0.020 -0.289 0.03 -0.03
## Sales -0.23 1.00 0.92 0.45 0.254 0.403 -0.24 0.13
## Profit -0.20 0.92 1.00 0.44 0.258 0.431 -0.33 0.14
## MTenure -0.06 0.45 0.44 1.00 0.243 -0.061 0.18 0.16
## CTenure 0.02 0.25 0.26 0.24 1.000 -0.002 -0.07 0.07
## Pop -0.29 0.40 0.43 -0.06 -0.002 1.000 -0.27 -0.05
## Comp 0.03 -0.24 -0.33 0.18 -0.070 -0.268 1.00 0.03
## Visibility -0.03 0.13 0.14 0.16 0.067 -0.050 0.03 1.00
## PedCount -0.22 0.42 0.45 0.06 -0.084 0.608 -0.15 -0.14
## Res -0.03 -0.17 -0.16 -0.06 -0.340 -0.237 0.22 0.02
## Hours24 0.03 0.06 -0.03 -0.17 0.073 -0.222 0.13 0.05
## CrewSkill 0.05 0.16 0.16 0.10 0.257 0.283 -0.04 -0.20
## MgrSkill -0.07 0.31 0.32 0.23 0.124 0.084 0.22 0.07
## ServQual -0.32 0.39 0.36 0.18 0.081 0.124 0.02 0.21
## PedCount Res Hours24 CrewSkill MgrSkill ServQual
## store -0.221 -0.03 0.03 0.05 -0.07 -0.322
## Sales 0.424 -0.17 0.06 0.16 0.31 0.386
## Profit 0.450 -0.16 -0.03 0.16 0.32 0.362
## MTenure 0.062 -0.06 -0.17 0.10 0.23 0.182
## CTenure -0.084 -0.34 0.07 0.26 0.12 0.081
## Pop 0.608 -0.24 -0.22 0.28 0.08 0.124
## Comp -0.146 0.22 0.13 -0.04 0.22 0.018
## Visibility -0.141 0.02 0.05 -0.20 0.07 0.210
## PedCount 1.000 -0.28 -0.28 0.21 0.09 -0.005
## Res -0.284 1.00 -0.09 -0.15 -0.03 0.091
## Hours24 -0.276 -0.09 1.00 0.11 -0.04 0.058
## CrewSkill 0.214 -0.15 0.11 1.00 -0.02 -0.034
## MgrSkill 0.087 -0.03 -0.04 -0.02 1.00 0.357
## ServQual -0.005 0.09 0.06 -0.03 0.36 1.000
options(digits = 2)
cor(store.df$Profit,store.df$MTenure)
## [1] 0.44
options(digits = 2)
cor(store.df$Profit,store.df$CTenure)
## [1] 0.26
library(corrgram)
## Warning: package 'corrgram' was built under R version 3.3.3
corrgram(store.df, lower.panel=panel.shade,
upper.panel=panel.pie, text.panel=panel.txt,
main="Corrgram of Store Variables")
In the decreasing order of correlation value with the profit:
Sales > PedCount > MTenure > Pop > ServQual
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
fit <- lm(store.df$Profit ~ store.df$MTenure + store.df$CTenure
+ store.df$Comp + store.df$Pop
+ store.df$PedCount + store.df$Res
+ store.df$Hours24 + store.df$Visibility,
data=store.df)
summary(fit)
##
## Call:
## lm(formula = store.df$Profit ~ store.df$MTenure + store.df$CTenure +
## store.df$Comp + store.df$Pop + store.df$PedCount + store.df$Res +
## store.df$Hours24 + store.df$Visibility, 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
## store.df$MTenure 760.99 127.09 5.99 9.7e-08 ***
## store.df$CTenure 944.98 421.69 2.24 0.02840 *
## store.df$Comp -25286.89 5491.94 -4.60 1.9e-05 ***
## store.df$Pop 3.67 1.47 2.50 0.01489 *
## store.df$PedCount 34087.36 9073.20 3.76 0.00037 ***
## store.df$Res 91584.68 39231.28 2.33 0.02262 *
## store.df$Hours24 63233.31 19641.11 3.22 0.00199 **
## store.df$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
Explanatory variables that are statistically significant to Profit (i.e. p < 0.05) are:
MTenure,CTenure,Comp,Pop,PedCount,Res,Hours24
Explanatory variable that is statistically insignificant to Profit (i.e. p > 0.05) is: Visibility
fit$coefficients
## (Intercept) store.df$MTenure store.df$CTenure
## 7610.0 761.0 945.0
## store.df$Comp store.df$Pop store.df$PedCount
## -25286.9 3.7 34087.4
## store.df$Res store.df$Hours24 store.df$Visibility
## 91584.7 63233.3 12625.4
1)With one month increase in Manager’s tenure of work experience, a Store is statistically expected to increase it’s profits by 761
2)With one month increase in Crew’s tenure of work experience, a Store is statistically expected to increase it’s profits by 945.
1)Correlation between profit and manager’s tenure is 0.44 while correlation between profit and crew’s tenure is 0.26. This indicates that increase in tenure of Manager will lead to more increase in Profit as comparative to crew.
2)Since the beta value of Manager’s tenure is less than that of Crew’s Tenure. This suggests that both Manager and Crew are assets to the store.
3)Competition affects profit very negatively .With unit increase in competition, Profit decreases by 25286.89.Visibilty does not have much significance as profit decider.