离散选择模型
主讲教师 陈锟
学习资料
Kenneth Train
学习资料
学习资料
R 统计软件
为何要采用离散选择模型
Discrete Choice Model
当被解释变量Y,是一个分类变量,而非连续变量时,我们应当选用DCM来构建因果关系。而不能选用LRM(Linear Regression Model)。
为何要采用离散选择模型
LRM处理分类结果变量时,会出现什么问题?
离散选择模型的分类
根据随机误差项的分布假定,分为Logit和Probit模型
根据Y的取值水平,分为二元模型和多元模型
拓展模型:Nested Logit; Mixed Logit
二元Logit模型的推导
选用Logistic分布的理由?
IIA与红蓝汽车问题
离散选择模型的作用
识别关键影响因素
衡量关键影响因素的作用
预测选择的概率
离散选择模型的应用
我们已经学会了什么?
我们可以用SPSS进行描述性统计、均值比较。
我们可以用SPSS进行二元logit模型分析,研究影响消费者选择的因素。
But SPSS is not good enough, we need another weapons.
Why not SPSS?
盗版
模型滞后
“傻瓜”软件
Why R?
It is free
Tiny and powerful
Updated packages
Build your own model: Bayesian statistics and marketing
It is up to you whether to choose SPSS or R. But I would highly recommend R for advanced users. It is worth of the investment and you are gonna fall in love with it.
Who is using R?
Where to get R?
Top statisticians
西南交通大学周庭锐教授
北京大学光华管理学院
R related books
What R can do for us?
矩阵计算
描述性统计
常有的统计模型:方差分析、回归、logit、聚类分析、判别分析、因子分析、生存分析等等。
前沿的统计模型:现代贝叶斯方法、MCMC
Graphics
初识R
example(lm)
demo(persp)
demo(graphics)
描述性统计与回归分析
105
99
15
79
75
14
129
118
13
132
120
12
114
106
11
107
101
10
93
85
9
99
94
8
112
105
7
84
79
6
82
77
5
125
115
4
110
103
3
94
92
2
98
95
1
相对销售额
相对促销费用
省编号
R操作
1、直接输入数据
>p<-c(95,92,103,115,77,79,105,94,85,101,106,120,118,75,99)
>mean(p)
>sd(p)
>s<-c(98,94,110,125,82,84,112,99,93,107,114,132,129,79,105)
>mean(s)
>sd(s)
>plot(p,s)
><-lm(s~p)
>summary()
2、从文本文件中读入数据
将工作目录指定到存放的位置或者在函数中添加路径。
>ex1<("C:\\",head=TRUE)
>names(ex1)
>ex1
>ex1[1:5,]
>attach(ex1)
>plot(s~p)
><-lm(s~p)
>summary()
>abline(lm(s~p))
回归分析完成了吗?
模型诊断。《应用商务统计》p12-p14。
异方差
正态性
多重共线性(数据矩阵是否满秩)
外生性
par(mfrow=c(2,2))
plot(,which=c(1:4))
二元logit
1、将excel数据转化为txt文本文件
2、读入数据
cc=("C:/",header=T)
cc
str(cc)
cc[1:5,]
3、描述性统计
>boxplot(sex~plan,data=cc,main="sex")
> boxplot(province~plan,data=cc,main="province")
>boxplot(limit~plan,data=cc,main="limit")
>boxplot(cost~plan,data=cc,main="cost")
boxplot(premium~plan,data=cc,main="premium")
4、模型运算
glm1=glm(plan~sex+province+limit+cost+premium,family=binomial(link=logit),data=cc)
> summary(glm1)
5、模型整体检验
>glm0=glm(plan~1,family=binomial(link=logit),data=cc)
> summary(glm0)
anova(glm0, glm1)
1-pchisq(,5)
6、模型预测
某个未知choice的消费者的购买概率是多少?
plan等于多少?
plan预测对了吗?
p=predict(glm1,cc)
p=exp(p)/(1+exp(p))
cc[1:5,]
cc$pred=1*(p>)
table(cc[,c(4,8)])