Choice Modeling for Marketing in R
Elea McDonnell Feit
Assistant Professor of Marketing, Drexel University
To fit a linear regression model:
my_model <- lm(y ~ x1 + x2 + x3, data = lm_data)
summary(my_model)
lm_data
data frame
y | x1 | x2 | x3 |
---|---|---|---|
3 | 2 | 7 | 2 |
1 | 1 | 7 | 8 |
3 | 2 | 4 | 6 |
library(mlogit)
mymodel <- mlogit(choice ~ feature1 + feature2 + feature3,
data = choice_data)
choice_data
ques | alt | choice | feature1 | feature2 | feature3 |
---|---|---|---|---|---|
1 | 1 | 1 | low | high | low |
1 | 2 | 0 | low | high | high |
1 | 3 | 0 | high | high | low |
2 | 1 | 0 | high | low | high |
2 | 2 | 1 | high | high | low |
2 | 3 | 0 | low | low | low |
summary(mymodel)
...
Coefficients :
Estimate Std. Error t-value Pr(>|t|)
feature1low -0.0322059 0.0740839 -0.4347 0.6638
feature2low 0.4546283 0.0727445 6.2497 4.114e-10 ***
feature3low -1.2926911 0.0648649 -19.9290 < 2.2e-16 ***
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
...
Choice Modeling for Marketing in R