DataCamp Building Response Models in R
Models for individual demand
BUILDING RESPONSE MODELS IN R
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
DataCamp Building Response Models in R
BUILDING RESPONSE MODELS IN R
DataCamp Building Response Models in R
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 ...
DataCamp Building Response Models in R
DataCamp Building Response Models in R
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
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
DataCamp Building Response Models in R
BUILDING RESPONSE MODELS IN R
DataCamp Building Response Models in R
DataCamp Building Response Models in R
logistic.model <- glm(HOPPINESS ~ price.ratio, family = binomial, data = choice.data) coef(logistic.model) (Intercept) price.ratio
DataCamp Building Response Models in R
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
margins(logistic.model) price.ratio
coef(probability.model) (Intercept) price.ratio 0.09700236 -0.29594939
DataCamp Building Response Models in R
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
DataCamp Building Response Models in R
BUILDING RESPONSE MODELS IN R
DataCamp Building Response Models in R
DataCamp Building Response Models in R
probit.model <- glm(HOPPINESS ~ price.ratio, family = binomial(link = probit), data = choice.data) coef(probit.model) (Intercept) price.ratio
DataCamp Building Response Models in R
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
DataCamp Building Response Models in R
margins(logistic.model) price.ratio
margins(probit.model) price.ratio
DataCamp Building Response Models in R
BUILDING RESPONSE MODELS IN R