Shikhar Kohli (PGP32117)
6th Nov, 2017
setwd('~/code/DAM')
store.df <- read.csv('datasets/CarSeatsDataV5.csv')
attach(store.df)
fit1 <- lm(Profit ~ Advertising)
summary(fit1)
Call:
lm(formula = Profit ~ Advertising)
Residuals:
Min 1Q Median 3Q Max
-171.85 -34.38 -3.78 35.97 168.85
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 147.3290 4.0320 36.540 < 2e-16 ***
Advertising 3.0660 0.4295 7.139 4.49e-12 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 57.05 on 398 degrees of freedom
Multiple R-squared: 0.1135, Adjusted R-squared: 0.1113
F-statistic: 50.97 on 1 and 398 DF, p-value: 4.493e-12
fit2 <- lm(Profit ~ ShelveLoc, data = store.df)
summary(fit2)
Call:
lm(formula = Profit ~ ShelveLoc, data = store.df)
Residuals:
Min 1Q Median 3Q Max
-163.350 -33.330 -1.365 31.033 153.050
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 120.041 4.808 24.97 < 2e-16 ***
ShelveLoc1-Medium 43.309 5.767 7.51 3.93e-13 ***
ShelveLoc2-Good 112.558 7.016 16.04 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 47.11 on 397 degrees of freedom
Multiple R-squared: 0.3971, Adjusted R-squared: 0.394
F-statistic: 130.7 on 2 and 397 DF, p-value: < 2.2e-16
plot(Profit, ShelveLoc)
fit3 <- lm(Profit ~ ShelveLoc + Advertising, data = store.df)
summary(fit3)
Call:
lm(formula = Profit ~ ShelveLoc + Advertising, data = store.df)
Residuals:
Min 1Q Median 3Q Max
-145.446 -25.160 0.039 24.796 104.054
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 103.014 4.886 21.085 < 2e-16 ***
ShelveLoc1-Medium 42.433 5.325 7.968 1.73e-14 ***
ShelveLoc2-Good 109.453 6.489 16.867 < 2e-16 ***
Advertising 2.738 0.328 8.347 1.18e-15 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 43.5 on 396 degrees of freedom
Multiple R-squared: 0.4873, Adjusted R-squared: 0.4834
F-statistic: 125.4 on 3 and 396 DF, p-value: < 2.2e-16
fit4 <- lm(Profit ~ ShelveLoc * Advertising, data = store.df)
summary(fit4)
Call:
lm(formula = Profit ~ ShelveLoc * Advertising, data = store.df)
Residuals:
Min 1Q Median 3Q Max
-143.299 -24.554 1.032 24.480 106.201
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 108.6051 6.1743 17.590 < 2e-16 ***
ShelveLoc1-Medium 34.6937 7.4206 4.675 4.04e-06 ***
ShelveLoc2-Good 103.1563 9.3093 11.081 < 2e-16 ***
Advertising 1.8390 0.6903 2.664 0.00803 **
ShelveLoc1-Medium:Advertising 1.2276 0.8190 1.499 0.13472
ShelveLoc2-Good:Advertising 0.9950 0.9812 1.014 0.31118
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 43.48 on 394 degrees of freedom
Multiple R-squared: 0.4902, Adjusted R-squared: 0.4837
F-statistic: 75.77 on 5 and 394 DF, p-value: < 2.2e-16
fit5 <- lm(Profit ~ Advertising + ShelveLoc + CompPrice + Population + Income + Age + Education + Urban + US, data = store.df)
summary(fit5)
Call:
lm(formula = Profit ~ Advertising + ShelveLoc + CompPrice + Population +
Income + Age + Education + Urban + US, data = store.df)
Residuals:
Min 1Q Median 3Q Max
-159.654 -17.856 2.075 20.401 68.740
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -60.136334 18.171281 -3.309 0.00102 **
Advertising 2.959638 0.334864 8.838 < 2e-16 ***
ShelveLoc1-Medium 44.625673 3.797403 11.752 < 2e-16 ***
ShelveLoc2-Good 109.212841 4.608355 23.699 < 2e-16 ***
CompPrice 1.563453 0.101946 15.336 < 2e-16 ***
Population 0.005803 0.011149 0.521 0.60299
Income 0.370657 0.055560 6.671 8.73e-11 ***
Age -0.952238 0.095685 -9.952 < 2e-16 ***
Education -0.679343 0.593883 -1.144 0.25337
UrbanYes 2.981043 3.402003 0.876 0.38143
USYes -5.783463 4.511614 -1.282 0.20064
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 30.69 on 389 degrees of freedom
Multiple R-squared: 0.7493, Adjusted R-squared: 0.7429
F-statistic: 116.3 on 10 and 389 DF, p-value: < 2.2e-16