Model extensions part 1: Dummy variables

Building Response Models in R

Kathrin Gruber

Assistant Professor of Econometrics Erasmus University Rotterdam

Dummy variables

Building Response Models in R

Understanding dummy variables

aggregate(log(SALES) ~ DISPLAY, FUN = mean, data = sales.data)
  DISPLAY log(SALES)
1       0   4.194953
2       1   4.657477
Building Response Models in R
dummy.model <- lm(log(SALES) ~ DISPLAY, data = sales.data)
coef(dummy.model)
(Intercept)      DISPLAY  
     4.1950       0.4625
  • Average unit sales for no-DISPLAY
exp(coef(dummy.model)[1])
(Intercept) 
   66.35063
  • Switching from no-DISPLAY to DISPLAY
exp(coef(dummy.model)[2] - 1)
 DISPLAY1 
0.5842211
Building Response Models in R

The effect of multiple dummies on sales (1)

aggregate(log(SALES) ~ DISPLAY + COUPON + DISPLAYCOUPON, FUN = mean, 
          data = sales.data)
  DISPLAY COUPON DISPLAYCOUPON log(SALES)
1       0      0             0   3.797571
2       1      0             0   4.657477
3       0      1             0   5.557327
4       0      0             1   5.946818
Building Response Models in R

The effect of multiple dummies on sales (2)

aggregate(log(SALES) ~ DISPLAY + COUPON + DISPLAYCOUPON, FUN = mean, 
          data = sales.data)
  DISPLAY COUPON DISPLAYCOUPON log(SALES)
1       0      0             0   3.797571
2       1      0             0   4.657477
3       0      1             0   5.557327
4       0      0             1   5.946818
dummy.model <- lm(log(SALES) ~ DISPLAY + COUPON + DISPLAYCOUPON, 
                  data = sales.data)

coef(dummy.model)
  (Intercept)        DISPLAY         COUPON  DISPLAYCOUPON  
       3.7976         0.8599         1.7598         2.1492
Building Response Models in R

What about price?

lm(update(dummy.model, . ~ . + PRICE), data = sales.data)
Call:
lm(formula = update(dummy.model, . ~ . + PRICE), data = sales.data)

Coefficients:
  (Intercept)        DISPLAY         COUPON  DISPLAYCOUPON          PRICE  
       3.4310         0.8747         1.7646         2.1630         0.3123
Building Response Models in R

Let's practice!

Building Response Models in R

Preparing Video For Download...