Part A Concepts

1 Company example and dummy variables

Question: Pick a company you know as a customer. Name one outcome it might predict and one categorical variable with at least three categories. How many dummy variables are needed, and which category would be the base?

Answer: Starbucks could predict how much a customer spends per order. One categorical variable is order method: in-store, drive-through, or mobile app. This needs two dummy variables. I would choose in-store as the base because it gives a familiar reference for comparing spending through the other methods.

2 Coding Location as a number

Question: A classmate codes Location as Elsewhere = 1, Entrance = 2, Food Court = 3 and uses it as a number in regression. What is wrong with this?

Answer: These locations do not have a natural numerical order or equal spacing. Coding them as 1, 2, and 3 forces the predicted change from Elsewhere to Entrance to equal the change from Entrance to Food Court, so Location should be treated as a factor with dummy variables.

3 Interpreting the Food Court coefficient

Question: What is wrong with saying that the Food Court coefficient of 41.32 means Food Court stores sell $41.32 more per sq ft than the average store? Rewrite it correctly.

Answer: The coefficient compares Food Court stores with the base category, Elsewhere, rather than the average of all stores. Correctly stated: In the location-only model, Food Court stores have predicted sales of $41.32 more per sq ft than stores located Elsewhere.

Part B Simple Regression

Mall <- read.csv("mall_sales_location.csv")
names(Mall) <- c("Sales", "Income", "Competitors", "Visitors", "Location")
summary(lm(Sales ~ Income, data = Mall))
## 
## Call:
## lm(formula = Sales ~ Income, data = Mall)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -152.672  -45.209   -1.222   60.716  181.153 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  97.0724    53.1821   1.825   0.0727 .  
## Income        6.4625     0.8122   7.957 4.24e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 74.87 on 63 degrees of freedom
## Multiple R-squared:  0.5013, Adjusted R-squared:  0.4933 
## F-statistic: 63.32 on 1 and 63 DF,  p-value: 4.238e-11
summary(lm(Sales ~ Competitors, data = Mall))
## 
## Call:
## lm(formula = Sales ~ Competitors, data = Mall)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -221.38  -54.47   -4.84   44.16  322.53 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  502.202     25.444   19.74   <2e-16 ***
## Competitors    4.635      8.747    0.53    0.598    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 105.8 on 63 degrees of freedom
## Multiple R-squared:  0.004438,   Adjusted R-squared:  -0.01136 
## F-statistic: 0.2808 on 1 and 63 DF,  p-value: 0.598

4 Income slope R squared and intercept

Question: Using Sales ~ Income, interpret the slope and R-squared in plain English. Should we interpret the intercept? Why or why not?

Answer: A $1,000 increase in the area’s median income is associated with about $6.46 higher predicted sales per sq ft. Income explains about 50.1% of the variation in sales per sq ft among these stores. The intercept predicts $97.07 per sq ft when median income is $0, but it has little practical meaning because $0 is far outside the observed income range of $48,000 to $105,000.

5 Positive Competitors slope

Question: Using Sales ~ Competitors, the slope is positive. Does this mean more competitors help sales? What might explain it?

Answer: No. The slope of about $4.64 per additional competitor is an association and is not statistically significant (p = 0.598). Higher-income areas may attract both more competitors and higher sales, so income could explain the positive relationship.

Part C Multiple Regression

m0 <- lm(Sales ~ Income + Competitors, data = Mall)
summary(m0)
## 
## Call:
## lm(formula = Sales ~ Income + Competitors, data = Mall)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -136.02  -49.76   11.97   48.47  136.90 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  60.3587    49.2902   1.225 0.225374    
## Income        7.9660     0.8382   9.503 1.03e-13 ***
## Competitors -24.1650     6.3899  -3.782 0.000353 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 68.03 on 62 degrees of freedom
## Multiple R-squared:  0.5947, Adjusted R-squared:  0.5817 
## F-statistic: 45.49 on 2 and 62 DF,  p-value: 6.915e-13
cor(Mall$Income, Mall$Competitors)
## [1] 0.47428

6 Adjusted coefficients

Question: Interpret the Income and Competitors coefficients, stating what is held constant.

Answer: Holding the number of competitors constant, a $1,000 increase in median income is associated with about $7.97 higher predicted sales per sq ft. Holding median income constant, one additional competitor is associated with about $24.17 lower predicted sales per sq ft.

7 Why the Competitors slope changes sign

Question: Why was the Competitors slope positive in Question 5 but negative here? Use the correlation between Income and Competitors.

Answer: Income and Competitors have a positive correlation of about 0.474, meaning higher-income areas tend to have more competitors. The simple regression mixes this income relationship into the Competitors slope. After controlling for income, the Competitors slope changes from +$4.64 to -$24.17 per sq ft, revealing a negative association among stores in areas with the same income.

8 Predicting sales

Question: Predict sales per sq ft for a store in an area with $80K median income and 2 competitors. Show the calculation.

Answer: Income is measured in thousands of dollars, so I use 80:

Predicted Sales = 60.35867 + 7.96598(80) - 24.16503(2) = $649.31 per sq ft.

predict(m0, newdata = data.frame(Income = 80, Competitors = 2))
##       1 
## 649.307

Part D Indicator Variables

Mall$Location <- factor(Mall$Location)
aggregate(Sales ~ Location, data = Mall, FUN = mean)
##     Location    Sales
## 1  Elsewhere 482.6818
## 2   Entrance 535.0455
## 3 Food Court 524.0000
m1 <- lm(Sales ~ Location, data = Mall)
summary(m1)
## 
## Call:
## lm(formula = Sales ~ Location, data = Mall)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -178.682  -60.000   -5.682   41.955  315.000 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)          482.68      22.24  21.704   <2e-16 ***
## LocationEntrance      52.36      31.45   1.665    0.101    
## LocationFood Court    41.32      31.82   1.298    0.199    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 104.3 on 62 degrees of freedom
## Multiple R-squared:  0.0472, Adjusted R-squared:  0.01646 
## F-statistic: 1.536 on 2 and 62 DF,  p-value: 0.2234
TukeyHSD(aov(Sales ~ Location, data = Mall))
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Sales ~ Location, data = Mall)
## 
## $Location
##                           diff       lwr       upr     p adj
## Entrance-Elsewhere    52.36364 -23.15971 127.88698 0.2268094
## Food Court-Elsewhere  41.31818 -35.09896 117.73533 0.4014950
## Food Court-Entrance  -11.04545 -87.46260  65.37169 0.9358241
m2 <- lm(Sales ~ Income + Competitors + Location, data = Mall)
summary(m2)
## 
## Call:
## lm(formula = Sales ~ Income + Competitors + Location, data = Mall)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -111.667  -54.018   -3.873   52.305  100.801 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         15.2039    47.4245   0.321  0.74963    
## Income               8.1517     0.7791  10.463 3.74e-15 ***
## Competitors        -24.9447     5.9439  -4.197 9.09e-05 ***
## LocationEntrance    66.8367    19.0287   3.512  0.00085 ***
## LocationFood Court  38.6912    19.2349   2.012  0.04877 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 62.93 on 60 degrees of freedom
## Multiple R-squared:  0.6644, Adjusted R-squared:  0.642 
## F-statistic: 29.69 on 4 and 60 DF,  p-value: 1.249e-13

9 Base category location coefficient and significance

Question: Using m1, identify the base category and explain the Entrance coefficient in two sentences. Based on the F-test, is there evidence that location affects sales? Is the Entrance versus Food Court difference significant in the Tukey output?

Answer: Elsewhere is the base category because it is the first factor level alphabetically and has no separate coefficient.

Entrance stores have predicted sales of $52.36 more per sq ft than stores located Elsewhere. This comparison uses location alone and does not account for differences in income or competitors.

The overall F-test has F = 1.536 and p = 0.223, so there is insufficient evidence of differences in mean sales across locations at the 5% level. The Tukey-adjusted p-value for Entrance versus Food Court is about 0.936, so that difference is also not statistically significant.

10 Comparing m1 and m2

Question: What happened to the Entrance coefficient and its p-value? Why might adding Income and Competitors make the effect of location easier to see?

Answer: The Entrance coefficient increases from $52.36 in m1 to $66.84 in m2, and its p-value falls from about 0.101 to 0.000850. Adding Income and Competitors accounts for other sources of sales variation, making the location comparison more precise. In m2, the Entrance coefficient compares stores with the same median income and number of competitors; it remains an association rather than proof of a causal effect.

11 Entrance rent decision

Question: An Entrance spot costs $40 more per sq ft per year than Elsewhere. Gross margin is 50%. Using m2, should the chain pay for the Entrance spot? Show the calculation.

Answer: No, based on the model’s point estimate and assuming Sales represents annual sales per sq ft.

  • Predicted additional sales: $66.84 per sq ft per year.
  • Additional gross profit: $66.83667 × 50% = $33.42 per sq ft per year.
  • Net benefit after extra rent: $33.42 - $40 = -$6.58 per sq ft per year.

The predicted additional gross profit does not cover the extra rent. The Entrance location would need at least $40 / 0.50 = $80 more annual sales per sq ft to break even.

entrance_premium <- unname(coef(m2)["LocationEntrance"])
c(additional_sales = entrance_premium,
  additional_gross_profit = entrance_premium * 0.50,
  extra_rent = 40,
  net_benefit = entrance_premium * 0.50 - 40,
  break_even_sales_increase = 40 / 0.50)
##          additional_sales   additional_gross_profit                extra_rent 
##                 66.836667                 33.418334                 40.000000 
##               net_benefit break_even_sales_increase 
##                 -6.581666                 80.000000