Car-Seats Data V5

Apurva, Group 7
6th November, 2017

setwd("~/Downloads/IIM Lucknow/TERM 5/DAM")
library(readr)
Carseats <- read.csv(paste("CarSeatsDataV5.csv", sep=""))
summary(Carseats)
     Sales          CompPrice       Income        Advertising    
 Min.   : 0.000   Min.   : 77   Min.   : 21.00   Min.   : 0.000  
 1st Qu.: 5.390   1st Qu.:115   1st Qu.: 42.75   1st Qu.: 0.000  
 Median : 7.490   Median :125   Median : 69.00   Median : 5.000  
 Mean   : 7.496   Mean   :125   Mean   : 68.66   Mean   : 6.635  
 3rd Qu.: 9.320   3rd Qu.:135   3rd Qu.: 91.00   3rd Qu.:12.000  
 Max.   :16.270   Max.   :175   Max.   :120.00   Max.   :29.000  
   Population        Price          ShelveLoc        Age       
 Min.   : 10.0   Min.   : 24.0   0-Bad   : 96   Min.   :25.00  
 1st Qu.:139.0   1st Qu.:100.0   1-Medium:219   1st Qu.:39.75  
 Median :272.0   Median :117.0   2-Good  : 85   Median :54.50  
 Mean   :264.8   Mean   :115.8                  Mean   :53.32  
 3rd Qu.:398.5   3rd Qu.:131.0                  3rd Qu.:66.00  
 Max.   :509.0   Max.   :191.0                  Max.   :80.00  
   Education    Urban       US         Revenue           Profit     
 Min.   :10.0   No :118   No :142   Min.   :   0.0   Min.   :  0.0  
 1st Qu.:12.0   Yes:282   Yes:258   1st Qu.: 626.6   1st Qu.:125.3  
 Median :14.0                       Median : 824.3   Median :164.9  
 Mean   :13.9                       Mean   : 838.4   Mean   :167.7  
 3rd Qu.:16.0                       3rd Qu.:1021.1   3rd Qu.:204.2  
 Max.   :18.0                       Max.   :1794.3   Max.   :358.9  

Model 0

x <- lm(Profit ~ Advertising, data = Carseats)
summary(x)

Call:
lm(formula = Profit ~ Advertising, data = Carseats)

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

Model 1

x <- lm(Profit ~ ShelveLoc, data = Carseats)
summary(x)

Call:
lm(formula = Profit ~ ShelveLoc, data = Carseats)

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

Model 2

x <- lm(Profit ~ Advertising+ShelveLoc, data = Carseats)
summary(x)

Call:
lm(formula = Profit ~ Advertising + ShelveLoc, data = Carseats)

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 ***
Advertising          2.738      0.328   8.347 1.18e-15 ***
ShelveLoc1-Medium   42.433      5.325   7.968 1.73e-14 ***
ShelveLoc2-Good    109.453      6.489  16.867  < 2e-16 ***
---
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

Model 3

x <- lm(Profit ~ Advertising+ShelveLoc+Advertising:ShelveLoc, data = Carseats)
summary(x)

Call:
lm(formula = Profit ~ Advertising + ShelveLoc + Advertising:ShelveLoc, 
    data = Carseats)

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 ***
Advertising                     1.8390     0.6903   2.664  0.00803 ** 
ShelveLoc1-Medium              34.6937     7.4206   4.675 4.04e-06 ***
ShelveLoc2-Good               103.1563     9.3093  11.081  < 2e-16 ***
Advertising:ShelveLoc1-Medium   1.2276     0.8190   1.499  0.13472    
Advertising:ShelveLoc2-Good     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

Model 4

x <- lm(Profit ~ Advertising + ShelveLoc + CompPrice + Population + Income + Age + Education + Urban + US, data = Carseats)
summary(x)

Call:
lm(formula = Profit ~ Advertising + ShelveLoc + CompPrice + Population + 
    Income + Age + Education + Urban + US, data = Carseats)

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