Models for individual demand Kathrin Gruber Assistant Professor of - - PowerPoint PPT Presentation

models for individual demand
SMART_READER_LITE
LIVE PREVIEW

Models for individual demand Kathrin Gruber Assistant Professor of - - PowerPoint PPT Presentation

DataCamp Building Response Models in R BUILDING RESPONSE MODELS IN R Models for individual demand Kathrin Gruber Assistant Professor of Econometrics Erasmus University Rotterdam DataCamp Building Response Models in R Customer purchases


slide-1
SLIDE 1

DataCamp Building Response Models in R

Models for individual demand

BUILDING RESPONSE MODELS IN R

Kathrin Gruber

Assistant Professor of Econometrics Erasmus University Rotterdam

slide-2
SLIDE 2

DataCamp Building Response Models in R

Customer purchases

OBS-ervation week. HOUSEHOLDID of the purchase records. LASTPURCHASE recorded of the household.

str(choice.data) 'data.frame': 2798 obs. of 15 variables: $ OBS : int 1 2 3 4 5 6 7 8 9 10 ... $ HOUSEHOLDID : int 1 1 1 1 1 1 1 1 1 1 ... $ LASTPURCHASE : int 0 0 0 0 0 0 0 0 0 0 ... $ BUD : int 1 1 1 1 1 1 1 1 1 1 ... $ HOPPINESS : int 0 0 0 0 0 0 0 0 0 0 ... $ PRICE.BUD : num 0.052 0.052 0.046 0.052 0.046 ... $ PRICE.HOP : num 0.034 0.044 0.048 0.034 0.048 ... $ DISPL.BUD : int 0 0 0 0 0 0 0 0 0 0 ... $ DISPL.HOP : int 0 0 0 0 0 0 0 0 0 1 ... $ FEAT.BUD : int 0 0 1 0 1 0 0 0 0 0 ... $ FEAT.HOP : int 0 0 0 0 0 0 0 0 0 0 ... $ FEATDISPL.BUD: int 0 0 0 0 0 0 0 0 0 0 ... $ FEATDISPL.HOP: int 0 0 0 0 0 0 1 0 0 0 ...

slide-3
SLIDE 3

DataCamp Building Response Models in R

To purchase or not to purchase?

Linear probability model Pr(Purchase = 1) = f(Advertising, Promotion)

slide-4
SLIDE 4

DataCamp Building Response Models in R

Competition

price.ratio <- log(choice.data$PRICE.HOP/choice.data$PRICE.BUD) head(cbind(price.ratio, choice.data$PRICE.BUD, choice.data$PRICE.HOP)) price.ratio [1,] -0.42488315 0.052 0.034 [2,] -0.16705410 0.052 0.044 [3,] 0.04255961 0.046 0.048 [4,] -0.42488315 0.052 0.034 [5,] 0.04255961 0.046 0.048 [6,] -0.44895021 0.047 0.030

slide-5
SLIDE 5

DataCamp Building Response Models in R

A linear probability model for beer demand

probability.model <- lm(HOPPINESS ~ price.ratio, data = choice.data) plot(HOPPINESS ~ price.ratio, data = choice.data) abline(probability.model)

slide-6
SLIDE 6

DataCamp Building Response Models in R

Let's practice!

BUILDING RESPONSE MODELS IN R

slide-7
SLIDE 7

DataCamp Building Response Models in R

Logistic response models

BUILDING RESPONSE MODELS IN R

Kathrin Gruber

Assistant Professor of Econometrics Erasmus University Rotterdam

slide-8
SLIDE 8

DataCamp Building Response Models in R

Logistic response function

Bounds model predictions between 0 and 1. Assumes a curved relationship.

slide-9
SLIDE 9

DataCamp Building Response Models in R

A logistic model for beer demand

logistic.model <- glm(HOPPINESS ~ price.ratio, family = binomial, data = choice.data) coef(logistic.model) (Intercept) price.ratio

  • 3.572678 -6.738768
slide-10
SLIDE 10

DataCamp Building Response Models in R

Bounded predictions

plot(HOPPINESS ~ price.ratio, data = choice.data) curve(predict(logistic.model, data.frame(price.ratio = x), type = "response"), add = TRUE)

slide-11
SLIDE 11

DataCamp Building Response Models in R

Average marginal effects

Nonlinear logistic model: Linear probability model

margins(logistic.model) price.ratio

  • 0.4585

coef(probability.model) (Intercept) price.ratio 0.09700236 -0.29594939

slide-12
SLIDE 12

DataCamp Building Response Models in R

Effect plots

x <- seq(-1.25, 1.25, by = 0.25) cplot(logistic.model, "price.ratio", xvals = x)

slide-13
SLIDE 13

DataCamp Building Response Models in R

Let's practice!

BUILDING RESPONSE MODELS IN R

slide-14
SLIDE 14

DataCamp Building Response Models in R

Probit response models

BUILDING RESPONSE MODELS IN R

Kathrin Gruber

Assistant Professor of Econometrics Erasmus University Rotterdam

slide-15
SLIDE 15

DataCamp Building Response Models in R

Probit response function

Purchase probabilities are latent propensities. Assumes a regression for a continuous, unobservable response variable.

slide-16
SLIDE 16

DataCamp Building Response Models in R

A probit model for beer demand

probit.model <- glm(HOPPINESS ~ price.ratio, family = binomial(link = probit), data = choice.data) coef(probit.model) (Intercept) price.ratio

  • 1.954092 -3.547546
slide-17
SLIDE 17

DataCamp Building Response Models in R

Logistic vs. probit

Rescaling

cbind(coef(logistic.model), coef(probit.model)) [,1] [,2] (Intercept) -3.572678 -1.954092 price.ratio -6.738768 -3.547546 coef(probit.model)*1.6 (Intercept) price.ratio

  • 3.126547 -5.676073
slide-18
SLIDE 18

DataCamp Building Response Models in R

Average marginal effects

Logistic: interpretable log-odds Probit: uninterpretable z-values

margins(logistic.model) price.ratio

  • 0.4585

margins(probit.model) price.ratio

  • 0.4503
slide-19
SLIDE 19

DataCamp Building Response Models in R

Let's practice!

BUILDING RESPONSE MODELS IN R