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 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 ... OBS -ervation week. HOUSEHOLDID of the purchase records. LASTPURCHASE recorded of the household.
DataCamp Building Response Models in R To purchase or not to purchase? Linear probability model Pr ( Purchase = 1) = f ( Advertising, Promotion )
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
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)
DataCamp Building Response Models in R BUILDING RESPONSE MODELS IN R Let's practice!
DataCamp Building Response Models in R BUILDING RESPONSE MODELS IN R Logistic response models Kathrin Gruber Assistant Professor of Econometrics Erasmus University Rotterdam
DataCamp Building Response Models in R Logistic response function Bounds model predictions between 0 and 1. Assumes a curved relationship.
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
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)
DataCamp Building Response Models in R Average marginal effects Nonlinear logistic model: margins(logistic.model) price.ratio -0.4585 Linear probability model coef(probability.model) (Intercept) price.ratio 0.09700236 -0.29594939
DataCamp Building Response Models in R Effect plots x <- seq(-1.25, 1.25, by = 0.25) cplot(logistic.model, "price.ratio", xvals = x)
DataCamp Building Response Models in R BUILDING RESPONSE MODELS IN R Let's practice!
DataCamp Building Response Models in R BUILDING RESPONSE MODELS IN R Probit response models Kathrin Gruber Assistant Professor of Econometrics Erasmus University Rotterdam
DataCamp Building Response Models in R Probit response function Purchase probabilities are latent propensities . Assumes a regression for a continuous, unobservable response variable.
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
DataCamp Building Response Models in R Logistic vs. probit cbind(coef(logistic.model), coef(probit.model)) [,1] [,2] (Intercept) -3.572678 -1.954092 price.ratio -6.738768 -3.547546 Rescaling coef(probit.model)*1.6 (Intercept) price.ratio -3.126547 -5.676073
DataCamp Building Response Models in R Average marginal effects Logistic : interpretable log-odds margins(logistic.model) price.ratio -0.4585 Probit : uninterpretable z-values margins(probit.model) price.ratio -0.4503
DataCamp Building Response Models in R BUILDING RESPONSE MODELS IN R Let's practice!
Recommend
More recommend