zf
Chapter 7 Discriminant Analysis
(判别分析)
2011-10-16 2
cxt
Presentation Outline
? 1,What is discriminant analysis?
? 2,Two populations discriminant analysis
? 3,More than two populations discriminant analysis
- distance discriminant analysis
- Bayes discriminant analysis
- Fisher discriminant analysis
- variable selection discriminant analysis
(forward discriminant analysis)
( backward discriminant analysis)
(stepwise discriminant analysis)
2011-10-16 3
cxt
7.1 what is discriminant analysis?
什么是判别分析?
? Discriminant analysis is a multivariate technique that can be
used to build rules according to other samples having classify
information that can classify a new thing into the appropriate
population,
? Discriminant Analysis Idea & Purpose
Discriminant analysis (both for discrimination and classification)
is a statistical technique to organize and optimize,
? the description of differences among objects that belong to
different groups or classes,and
? the assignment of objects of unknown class to existing
classes,
2011-10-16 4
cxt
? Thus,there are two related activities or concepts in
discrimination and classification,
? Descriptive discrimination focuses on finding a few
dimensions that combine the originally measured variables
and that separate the classes or collections as much as
possible,
? Optimal assignment of new objects,whose real group
membership is not known,into one of the existing groups
or classes,
? The basic objective of discriminant analysis,
produce a rule or a classification scheme that will
enable a researcher to predict the population from which an
observation is most likely to have come,
2011-10-16 5
cxt
? 判别分析
根据已知对象的某些观测指标和所属类别来判断未知对象所属
类别的一种统计学方法。
? 判别分析的基本思想
1、是根据已掌握的、历史上若干样本的 p个指标数据及所属类
别的信息,总结出该事物分类的规律性,建立判别公式和判别准
则。
2、根据总结出来的判别公式和判别准则,判别未知类别的样本
点所属的类别。
判别分析的目的,识别一个个体所属类别
2011-10-16 6
cxt
? Applications Discriminant Analysis (判别分
析的应用:无处不在 )
? The marketing manager of a consumer packaged goods
firm is interested in identifying salient attributes that
successfully differentiate between purchasers and
nonpurchasers of brands,and employing this
information to predict purchase intentions of potential
customers
? we consider a bank officer who wishes to decide
whether the applicant?s characteristics are more like
those of persons in the past who repaid loans
successfully than like those of persons who defaulted,
2011-10-16 7
cxt
? For example,we may want to determine what
characteristics best discriminate between good and
bad credit card customers,
? For example,a student applying to go to college
may have to be classified as likely to succeed or
likely to fail based on the characteristics of
students who did succeed or fail in the past,
2011-10-16 8
cxt
? 经济学,
? 例 1:中小企业的破产模型
为了研究中小企业的破产模型,选定 4个经济指标,
X1总负债率(现金收益 /总负债)
X2收益性指标(纯收入 /总财产)
X3短期支付能力(流动资产 /流动负债)
X4生产效率性指标(流动资产 /纯销售额)
对 17个破产企业( 1类)和 21个正常运行企业( 2类)进
行了调查,得如下资料,
2011-10-16 9
cxt
总负债率
收益性指标
短期支付能力
生产效率指标
类别
-.45
-.41
1.09
.45
1
-.56
-.31
1.51
.16
1
,06
.02
1.01
.40
1
-.07
-.09
1.45
.26
1
-.10
-.09
1.56
.67
1
-.14
-.07
.71
.28
1
-.23
-.30
.22
.18
1
,07
.02
1.31
.25
1
,01
.00
2.15
.70
1
-.28
-.23
1.19
.66
1
,15
.05
1.88
.27
1
,37
.11
1.99
.38
1
-.08
-.08
1.51
.42
1
,05
.03
1.68
.95
1
,01
.00
1.26
.60
1
,12
.11
1.14
.17
1
-.28
-.27
1.27
.51
1
,51
.10
2.49
.54
2
,08
.02
2.01
.53
2
2011-10-16 10
cxt
.38
.11
3.27
.55
2
,19
.05
2.25
.33
2
,32
.07
4.24
.63
2
,31
.05
4.45
.69
2
,12
.05
2.52
.69
2
-.02
.02
2.05
.35
2
,22
.08
2.35
.40
2
,17
.07
1.80
.52
2
,15
.05
2.17
.55
2
-.10
-1.01
2.50
.58
2
,14
-.03
.46
.26
2
,14
.07
2.61
.52
2
-.33
-.09
3.01
.47
2
,48
.09
1.24
.18
2
,56
.11
4.29
.45
2
,20
.08
1.99
.30
2
,47
.14
2.92
.45
2
,17
.04
2.45
.14
2
,58
.04
5.06
.13
2
,04
.01
1.50
.71
待判
-.06
-.06
1.37
.40
待判
2011-10-16 11
cxt
,07
-.01
1.37
.34
待判
-.13
-.14
1.42
.44
待判
,15
.06
2.23
.56
待判
,16
.05
2.31
.20
待判
,29
.06
1.84
.38
待判
,54
.11
2.33
.48
待判
2011-10-16 12
cxt
企业
序号
判别
类型
判别函数
得分
判别为 1的
概率
判别的为 2
概率
1
1
-.56509
.69479
.30521
2
1
-.89817
.80234
.19766
3
1
-.59642
.70620
.29380
4
1
-1.02182
.83420
.16580
5
2
.25719
.35312
.64688
6
2
.34253
.32005
.67995
7
2
.27925
.34442
.65558
8
2
1.24010
.09012
.90988
2011-10-16 13
cxt
? 例 5:根据信息基础设施的发展状况,对世界 20
个国家和地区进行分类。
考察指标有 6个,
1,X1,每千居民拥有固定电话数目
2,X2,每千人拥有移动电话数目
3,X3,高峰时期每三分钟国际电话的成本
4,X4,每千人拥有电脑的数目
5,X5,每千人中电脑使用率
6,X6,每千人中开通互联网的人数
2011-10-16 14
cxt
? 分析结果:将 20个国家分为两类
第 1类(基础设施落后),巴西、墨西哥、波兰、
匈牙利、智利、俄罗斯、泰国、印度、马来西亚
第 2类(基础设施发达),瑞典、丹麦、美国、
中国台湾、韩国、日本、德国、法国、新加坡、英
国、瑞士
? 如果:我们想知道我国基础设施发展属于哪一类型?
运用判别分析
依据,20个国家的分类信息构建判别函数
2011-10-16 15
cxt
? 例:股票持有者根据股票近期的变化情况判断此种
股票价格下一周是上升还是下跌?
? 刑事学,
例,Smith先生被指控偷了邻居家的鸡。但 Smith先生
宣称他家冰箱里的鸡是野鸡。
如何判定,
Smith先生究竟是否偷了邻居的鸡呢??
2011-10-16 16
cxt
? 医学,
例:在医学诊断中,一个病人肺部有阴影,
医生要判断他患的是肺结核、肺部良性肿瘤
还是肺癌?
肺结核病人、肺部良性肿瘤病人、肺癌病
人组成三个总体,病人来自其中一个总体,
可通过病人的指标(阴影大小、边缘是否光
滑等)用判别分析判断他来自哪个总体(即
判断他患的什么病?)
2011-10-16 17
cxt
? Discriminant Analysis Procedure,
? Obtain a random sample of objects from each class (these are
objects whose membership is known) This is known as the,training”
or,learning” sample,
? Submit the training sample to a Discriminant Analysis and obtain a
set of discriminant functions,These functions are used implicitly by for
example SPSS or SAS,so you do not need to see or know them,The
information on these functions is stored in a dataset that is created
within the program,
? The same procedure allows a true validation of the classification
functions by using a file that contains objects of known membership to
be classified using only the information on the variables and the
classification functions developed with the,training” or,learning”
sample,
2011-10-16 18
cxt
? the difference (or correlation) between discriminant
analysis and cluster analysis,
discriminant analysis classify new sample,in which we
initially know how many distinct groups exist and we have
data that are known to come from each of these distinct
group,
cluster analysis involves techniques that produce
classifications from data that are initially unclassified,
2011-10-16 19
cxt
? 判别分析与聚类分析的比较,
(1)判别分析是在已知研究对象分成若干类型并已取得各种类
型的一批已知样本的观测数据,在此基础上根据某些准则建
立判别式,然后对未知类型的样本进行判别分类。
(2)聚类分析则是对研究对象的类型未知的情况下,对其进行
分类的方法。
(3)判别分析和聚类分析往往联合使用。当总体分类不清楚
时,先用聚类分析对一批样本进行分类,再用判别分析构建
判别式对新样本进行判别。
2011-10-16 20
cxt
? Compared Discriminant analysis with regression analysis,
Discriminant analysis is similar to regression analysis
except that the dependent variable is categorical rather than
continuous,
In regression analysis,we want to be able to predict
the value of a variable of interest based on a set of predictor
variables,
In discriminant analysis,we want to be able to predict
class membership of an individual observation based on a
set of predictor variables,
2011-10-16 21
cxt
? 判别分析与回归分析
( 1)判别分析类似于回归分析,只是判
别分析中因变量是反映分类情况的属性变量。
( 2)回归分析是依据一系列的解释变量
预测我们感兴趣的某变量取值
( 3)判别分析则是依据一系列的解释变
量预测个体分组情况。
2011-10-16 22
cxt
We will know certain things about samples such as
X1,X2…..Xp variables and classify
information,
? (1)can this knowledge be used to construct a
rule that classify new sample?
? (2)what is the rule and can the rule be used to
classify new sample?
? (3)what are the chances of making mistakes
when using the rule?
2011-10-16 23
cxt
? the type of discriminant analysis
(1) two-groups discriminant analysis
multiple-groups discriminant analysis
(2) linear discriminant analysis
nonlinear discriminant analysis
(3) stepwise discriminant analysis
backward discriminant analysis
forward discriminant analysis
(4) distance discriminant analysis
Fisher discriminant analysis
Bayes discriminant analysis
2011-10-16 24
cxt
? 4、判别分析类型及方法
( 1)按判别的组数来分,有两组判别分析和多组判别
分析
( 2)按区分不同总体所用的数学模型来分,有线性判
别和非线性判别
( 3)按判别对所处理的变量方法不同有逐步判别、向
后判别、向前判别。
( 4)按判别准则来分,有费歇尔判别准则、贝叶斯判别
准则等
2011-10-16 25
cxt
? This chapter,we will learn these methods of
discriminant analysis,
? 本章介绍的主要判别分析方法,
距离判别
贝叶斯 (Bayes)判别
费歇尔 (Fisher)判别
逐步判别
2011-10-16 26
cxt
7.2 Distance discriminant analysis(距离判别 )
? Basic idea(基本思想 ),
即:首先根据已知分类的数据,分别计算各类的重
心即各组(类)的均值,判别的准则是对任给样品,计
算它到各类平均数的距离,哪个距离最小就将它判归哪
个 类。
(一) Two-population两个总体的距离判别法
1,Covariance matrices is equal方差相等
先考虑两个总体的情况,设有两个协差阵 ?相同
的 p维正态总体,对给定的样本 Y,判别一个样本 Y
到底是来自哪一个总体,一个最直观的想法是计算 Y
到两个总体的距离。故我们用马氏距离来给定判别
规则,有,
2011-10-16 27
cxt
? ? ? ?
? ? ? ?
?
?
?
?
?
?
??
??
),(),( 2212
1
2
2
2
2
2
2
1
2
1
GydGyd
GdGdG
GdGdG
如待判,
,,如,
,,,如,
yyy
yyy
2011-10-16 28
cxt
)()()()(
),(),(
1
1
12
1
2
1
2
2
2
???? ????????
?
?? yyyy
yy
??
GdGd
22211 yyy ??? 12 ??? ?????? ???
????? ? )(2 21 ??1y )()( 212 ???? ???? ? 11
)(]2 )([2 21121y ???? ?????? ?
2
21 ??? ??令 ),,,()(
21 ????? ? paaa ?211 ???
)2( 1111 ??? ??? ????????? 11 yyy
2011-10-16 29
cxt
? 则前面的判别法则表示为
?
?
?
?
?
?
??
??
0)(
0
0
2
1
YW
WG
WG
如待判,
。)(如,
,)(如,
yy
yy )???? ?????? yyy ()()(W )()(
111 ppp yaya ?? ????? ?
μαyα ????
当 和 ?已知时, 是一个已知的 p
维向量, W( y) 是 y的线性函数, 称为线性判别函数 。 ?
称为判别系数 。 用线性判别函数进行判别分析非常直观,
使用起来最方便, 在实际中的应用也最广泛 。
21 ??,)( 211 ??? ??? ?
2011-10-16 30
cxt
例 在企业的考核中,可以根据企业的生产经营情况
把企业分为优秀企业和一般企业。考核企业经营状
况的指标有,
资金利润率 =利润总额 /资金占用总额
劳动生产率 =总产值 /职工平均人数
产品净值率 =净产值 /总产值
三个指标的均值向量和协方差矩阵如下。现有
二个企业,观测值分别为
( 7.8,39.1,9.6)和( 8.1,34.2,6.9),
问这两个企业应该属于哪一类?
2011-10-16 31
cxt
变量 均值向量 协方差矩阵
优秀 一般
资金利润率 13.5 5.4 68.39 40.24 21.41
劳动生产率 40.7 29.8 40.24 54.58 11.67
产品净值率 10.7 6.2 21.41 11.67 7.90
2011-10-16 32
cxt
? 线性判别函数,
1 2 30, 6 0 5 8 1 0, 2 5 3 6 2 1, 8 3 6 7 9 1 8, 7 3 5 9y x x x? ? ? ? ?
1 0, 6 0 5 8 1 7, 8 0, 2 5 3 6 2 3 9, 1 1, 8 3 6 7 9 9, 6 1 8, 7 3 5 9 64, 0 8 9 2 0y ? ? ? ? ? ? ? ???
2 0, 6 0 5 8 1 8, 1 0, 2 5 3 6 2 3 4, 2 1, 8 3 6 7 9 6, 9 1 8, 7 3 5 9 6
2, 2 9 5 6 0
y ? ? ? ? ? ? ? ?
? ? ?
2011-10-16 33
cxt
? 2,Covariance matrices is not equal总体不等
? ? ? ?
? ? ? ?
?
?
?
?
?
?
??
??
),(),( 2212
1
2
2
2
2
2
2
1
2
1
GydGyd
GdGdG
GdGdG
如待判,
,,如,
,,,如,
yyy
yyy
)()()()(
),(),(
1
1
112
1
22
1
2
2
2
???? ??????????
?
?? yyyy
yy GdGd
2011-10-16 34
cxt
? (二) Multiple-population多总体的距离判别法
1,Covariance matrices is equal协方差阵相等
设有个 K总体,分别有均值向量 (i=1,2,…,k)和协方差
阵 Σi= Σ,又设 Y是一个待判样品。则 Y与各总体的距
离为(即判别函数):(与两个总体类似)
上式中的第一项 Y? Σ -1Y与 i无关,则舍去,得一个等价的函数
iu
)()(),( 12 iiiGd ?? ????? ? yyy
iii ??? ?????????? ??? 12 11 yyy
iiii Yg ??? ???????? ?? 12)( 1y
2011-10-16 35
cxt
? 将上式中提 -2,得
则距离判别法的判别函数为,
)5.0(2)( 1 iiii Yg ??? ???????? ?? 1y
)5.0()( 1 iiii Yf ??? ??????? ?? 1y令
likil Gyxfyf ?? ??,则)(m a x)( 1
最大)5.0()( 1 iiii Yf ??? ??????? ?? 1y
注,这与前面所提出的距离判别是等价的,
?????? ? 最小)()(),( 122 iiiGd ?? yyy
)5.0()( 1 iiii Yf ??? ??????? ?? 1y令
判别规则为
2011-10-16 36
cxt
2,Covariance matrices is not equal协方差阵不等
设有个 K总体,分别有均值向量 (i=1,2,…,k)和协方
差阵不等,又设 Y是一个待判样品。则 Y与各总体的距
离为(即判别函数):(与两个总体类似)
iu
2011-10-16 37
cxt
? 距离判别法的优缺点,
该方法简单实用,但没有考虑到每个总体出现
的机会大小,即先验概率,没有考虑到错判的损失。
贝叶斯判别法 正是为了解决这两个问题提出的
判别分析方法。
2011-10-16 38
cxt
7.3 Bayes discriminant analysis
? Bayes discriminant analysis idea,
choose G1 if P(G1/x)>P(G2/x) and choose G2
otherwise; choose G1 if the probabilities of
misclassification C((G1/x)<C(G2/x),and choose G2
otherwise,
2011-10-16 39
cxt
? The posterior probability rule,select the maximum
posterior probability,then discriminate x who comes
from the population,
? For example,There are three population, and
A sample we don?t know it comes from which group,
The prior probability of populations are
and the density functions are,
now we use these information to discriminate comes from
which group,
3G1G 2G
0x
,30.0,65.0,05.0 321 ??? qqq
10.0)( 01 ?xf 63.0)( 02 ?xf 4.2)( 03 ?xf
0x
2011-10-16 40
cxt
004.01 3 4 5.1 005.04.230.063.065.010.005.0 10.005.0
)(
)()(
3
1
0
011
01 ???????
???
?
?i
ii xfq
xfqxGP
3 6 1.01 3 4 5.1 4 0 9 5.04.230.063.065.010.005.0 63.065.0
)(
)()(
3
1
0
022
02 ???????
???
?
?i
ii xfq
xfqxGP
6 3 5.01 3 4 5.1 72.04.230.063.065.010.005.0 4.230.0
)(
)()(
3
1
0
033
03 ???????
???
?
?i
ii xfq
xfqxGP
2011-10-16 41
cxt
7.3贝叶斯 (Bayes)判别
? 贝叶斯判别法,
是通过计算被判样本 x属于 k个总体的条件概率 P( n/x),n=1,2…,.k,
比较 k个概率的大小, 将样本判归为来自出现概率最大的总体 ( 或归
属于错判概率最小的总体 ) 的判别方法 。
? 一, 最大后验概率准则
例,办公室新来了一个雇员小王, 小王是好人还是坏人大家都
在猜测 。 按人们主观意识, 一个人是好人或坏人的概率均为 0.5。
坏人总是要做坏事, 好人总是做好事, 偶尔也会做一件坏事,
一般好人做好事的概率为 0.9,坏人做好事的概率为 0.2,一天,
小王做了一件好事, 小王是好人的概率有多大, 你现在把小王
判为何种人 。
2011-10-16 42
cxt
? ? ? ?
? ? )/()()/(
/
/(
坏人做好事坏人好人做好事好人
好人做好事好人
做好事)好人
PPPP
PP
P
?
?
82.02.05.09.05.0 9.05.0 ???? ??
2011-10-16 43
cxt
? ? ? ?
? ? )/()()/(
/
/(
坏人做好事坏人好人做好事好人
坏人做好事坏人
做好事)坏人
PPPP
PP
P
?
?
Bayes判别 既要考虑到各个总体出现的先验概率,又要考虑到错判
造成的损失 。 Bayes公式,
)()|(
)()|()|(
ii
ii
i BPBAP
BPBAPABP
??
2011-10-16 44
cxt
设有总体, 具有概率密度函数 。 并且
根据以往的统计分析, 知道 出现的概率为 。 即当样本 发生时,
求他属于某类的概率 。 由贝叶斯公式计算后验概率, 有,
则 判给 。 在正态的假定下, 为正态分布的密度函数 。
判别准则 1:后验概率最大 即判断 x来自后验概率最大的总体
),,2,1( kiG i ??iG
iG
)(xfi
iq 0x
)(
)()|(
0
00 xfq xfqxGP
jj
iii ??
判别规则,)(
)()|(
0
0
0 xfq
xfqxGP
jj
ll
l ?? )(
)(
0
0
1m ax xfq
xfq
jj
ii
ki ?
?
??
0x lG )(xfi
2011-10-16 45
cxt
? Minimum ECM rule,(P232-233)
Let and be the probability density for x for the
populations (group 1=region R1 ) and (group 2=region
R2),
The meaning of this is that the of classifying in group 2 given
that it in fact comes from group 1 is
and similarly the probability of classifying in group 1 given
that it in fact comes from group 2 is
2011-10-16 46
cxt
? Let be the prior probability of and be the prior
probability of,where, Then the overall
probabilities of correctly or incorrectly classifying objects
can be derived as the product of the prior and conditional
classification probabilities,
2011-10-16 47
cxt
? The Bayes rule is,
choose if,and
choose otherwise,1
? )1/2()()2/1()( 1122 cxfpcxfp ?
2?
2011-10-16 48
cxt
上式左边表示 x0在第一类的概率密度与在第二类的概率密度相减。它
大于等于某数,可看作 x0在第一类的概率密度大于在第二类的概率密
度,故将 x0判别到 。
上式右边表示 x0来自 错判至 的可能损失与 x0来自 错判至
的可能损失之差,小于某正数,表示 x0来自 错判至 的可能损失
较小,故将 x0判别到
1?
2? 1?
1?2?
2?1?
1?
2011-10-16 49
cxt
2011-10-16 50
cxt
? 二、最小平均误判准则,错判损失最小概念作判别函数
【 定义 】 (平均错判损失)
用 P(j/i)表示将来自总体 Gi的样品错判到总体 Gj的条件概率。
????
jD
iij dxxfGDXPijp )()/()/( ji?
C(j/i)表示相应错判所造成的损失 。
则平均错判损失为,
? ?
? ?
? k
i ij
i ijPijCqE C M
1
)/()/(
使 ECM最小的分划,是 Bayes判别分析的解。
2011-10-16 51
cxt
? 【 定理 】
? ?kiq i,,3,2,1,??若总体 G1,G2,?, Gk的先验概率为
? ?)(xfi ? ?)/( ijC且相应的密度函数为,损失为
则划分的 Bayes解为
? ? kihhD jkjii,,3,2,1,)(mi n)(| 1 ???? ?? xxx
其中 ???
k
i iij
fijCqh
1
)()/()( xx
2011-10-16 52
cxt
含义是:当抽取了一个未知总体的样品值 x,要判别它属于那个总
体,只要先计算出 k个按先验概率加权的误判平均损失
?
?
? k
i iij
fijCqh
1
)()/()( xx
然后比较其大小,选取其中最小的,则判定样品属于该总体。
2011-10-16 53
cxt
? 例:设先验概率、误判损失及概率密度如下,
判别为
G1 G2 G3
G1 C ( 1 / 1 ) = 0 C ( 2 / 1 ) = 2 0 C ( 3 / 1 ) = 8 0
G2 C ( 1 / 2 ) = 4 0 0 C ( 2 / 2 ) = 0 C ( 3 / 2 ) = 2 0 0



G3 C ( 1 / 3 ) = 1 0 0 C ( 2 / 3 ) = 5 0 0 C ( 3 / 3 ) = 0
先验概率 P 1 = 0, 5 5 P 2 = 0, 1 5 P 3 = 0, 3 0
概率密度 f 1 = 0, 4 6 f 2 = 1, 5 F 3 = 0, 7 0
2011-10-16 54
cxt
试用贝叶斯判别法将样本 x0判到 G1,G2,G3中的一个。考虑与
不考虑误判损失的结果如何?
1、考虑误判损失,
误判到 G1的平均损失为
ECM1= 0.55*0.46*0+0.15*1.5*400+0.30*0.70*100=
误判到 G2的平均损失为
ECM2= 0.55*0.46*20+0.15*1.5*0+0.30*0.70*50=
误判到 G3的平均损失为
ECM3= 0.55*0.46*80+0.15*1.5*200+0.30*0.70*0=
其中 ECM2最小,故将 x0判别到 G2。
2011-10-16 55
cxt
2、不考虑误判损失,
将 x0判别到 G1的条件概率为,
P( G1/x0) =(0.55*0.46)/(0.55*0.46+0.15*1.5+0.30*0.70)=
将 x0判别到 G2的条件概率为,
P( G2/x0) =(0.15*1.5)/(0.55*0.46+0.15*1.5+0.30*0.70)=
将 x0判别到 G3的条件概率为,
P( G3/x0) =(0.30*0.70)/(0.55*0.46+0.15*1.5+0.30*0.70)=
其中 P( G1/x0) 取值最大,故将 x0判别到 G1。
2011-10-16 56
cxt
例:下表是某金融机构客户的个人资料,这些资料对一个金融机构来
说,对于客户信用度的了解至关重要,因为利用这些资料,可以
挖掘出许多的信息,建立客户的信用度评价体系。所选变量为,
x1,月收入
x2,月生活费支出
x3,虚拟变量,住房的所有权,自己的为, 1”,租用的, 0”
x4,目前工作的年限
x5,前一个工作的年限
x6,目前住所的年限
x7,前一个住所的年限
X8,家庭赡养的人口数
X9,信用程度,,5” 的信用度最高,,1” 的信用度最低。
2011-10-16 57
cxt
L o a n Y r s a t Y r s a t Y r s a t Y r s a t
R e c o r d M o n t h l y M o n t h l y H o m e P r e s e n t P r e v i o u s P r e s e n t P r e v i o u s N o, o f
N u m b e r I n c o m e E x p e n s e s O w n e r? J o b J o b A d d r e s s A d d r e s s D e p e n d, O u t p u t
1 3000 1500 0 2 8 6 2 5 3
2 850 425 1 3 3 25 25 1 3
3 1000 3000 0 0, 1 0, 3 0, 1 0, 3 4 1
4 9000 2250 1 8 4 5 3 2 5
5 4000 1000 1 3 5 3 2 1 4
6 3500 2500 0 0, 5 0, 5 0, 5 2 1 1
7 2200 1200 1 6 3 1 4 1 3
8 4500 3500 0 8 2 10 1 5 2
9 1200 1000 0 0, 5 0, 5 1 0, 5 3 1
10 800 800 0 0, 1 1 5 1 3 1
11 7500 3000 1 10 3 10 3 4 5
12 3000 1000 1 20 5 15 10 1 5
13 2500 700 1 10 5 15 5 3 5
14 3000 2600 1 6 1 3 4 2 2
15 7000 3700 1 10 4 10 1 4 4
16 3000 2800 0 1 2 3 4 3 1
17 4500 1500 1 6 4 4 9 3 4
2011-10-16 58
cxt
原始类 判类 后验概率 1 后验概率 2 后验概率 3 后验概率 4 后验概率 5
5 5 0 0 0.00001 0 0.99999
1 1 0.87079 0.00529 0.12379 0.00014 0
4 4 0.03952 0.01605 0.14635 0.78714 0.01095
2 2 0.04827 0.91002 0.03611 0.0056 0
1 3 0.381 0.19853 0.41076 0.0097 0.00001
1 3 0.2292 0.10883 0.63483 0.02681 0.00032
1 1 0.6492 0.21128 0.13896 0.00056 0
5 5 0.00014 0.00006 0.00206 0.23391 0.76384
3 3 0.18884 0.00616 0.8049 0.0001 0
3 3 0.09624 0.00172 0.90169 0.00033 0.00003
4 4 0.00891 0.30299 0.01216 0.6759 0.00004
1 1 0.79619 0.00328 0.20027 0.0002 0.00006
3 3 0.26354 0.01066 0.68458 0.03975 0.00147
2 2 0.08262 0.83204 0.01982 0.06552 0
4 4 0.00002 0.00116 0.00006 0.99813 0.00062
3 3 0.11507 0.01651 0.36721 0.29397 0.20724
3 1 0.67184 0.23902 0.0888 0.00034 0
2011-10-16 59
cxt
7.4 Fisher discriminant analysis
? The idea is to transform the multivariate x to univariate
observations y such that the y?s derived from
populations and are separated as much as
possible
? Linear combinations with no assumption of normality
? Implicitly the population covariances are assumed
equal because a pooled estimate of the common
covariance matrix is used
? Fisher?s method corresponds to a special case of
minimum ECM
2011-10-16 60
cxt
2011-10-16 61
cxt
7.4费歇尔 (Fisher)判别
? 所谓 Fisher判别法, 就是用投影的方法将 k个不同总体在 p维空间
上的点尽可能分散, 同一总体内的各样本点尽可能的集中 。 用 方
差分析的思想则可构建一个较好区分各个总体的线性判别法
例:考虑只有两个 ( 预测 ) 变量的判别分析问题 。 假定这里只有两类 。 数
据中的每个观测值是二维空间的一个点 。 见图 ( 下一张幻灯片 ) 。
? 这里只有两种已知类型的训练样本 。 其中一类有 38个点 ( 用, o”表
示 ), 另一类有 44个点 ( 用, *” 表示 ) 。 按照原来的变量 ( 横坐标和
纵坐标 ), 很难将这两种点分开 。
? 于是就寻找一个方向, 也就是图上的虚线方向, 沿着这个方向朝和这
个虚线垂直的一条直线进行投影会使得这两类分得最清楚 。 可以看出,
如果向其他方向投影, 判别效果不会比这个好 。
? 有了投影之后, 再用前面讲到的距离远近的方法来得到判别准则 。 这
种首先进行投影的判别方法就是 Fisher判别法 。
2011-10-16 62
cxt
-4 -2 0 2 4 6
-4
-3
-2
-1
0
1
2
3
2011-10-16 63
cxt
? 一、两个总体的费歇( Fisher) 判别法
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
? ?
?
?
?
?
?
?
X不能使总体单位
尽可能分开的方向
u能使总体单位
尽可能分开的方向
?
?
旋转坐标轴至总体单位尽可能分开的方向,此时分类变量
被简化为一个
2011-10-16 64
cxt
? ( 一)费歇判别的基本思想
设有 A,B两个总体,分别有 个历史样本数据,每个样本
有 P个观测指标,每个样本可看作 P维空间中的一点。
Fisher借助于方差分析的思想构造一个线性判别函数,
其中,判别系数 的选择应使得 y值满足,
(1)A类和 B类的样本点群尽可能远离;
(2)同一类的样本点尽可能集中。
pp XCXCXCY ???? ?2211
pCCC,,,21 ?
21 nn和
2011-10-16 65
cxt
),,2,1()m i n (
),,2,1()m i n (
)m a x (
2
2
2
bbbi
aaai
ba
niyy
niyy
yy
BAF i s h e r
?
?
??
??
?

量集中,即
应该尽;而同一总体的投影点分散,即
的头影点应尽量、的思想:不同总体由
.
)()(
)(
),,,(
1
2
1
2
2
21
准则要求取最大值就满足则只要
构造统计量
F i s h e rF
yyyy
yy
cccF
ba n
i
bbi
n
i
aai
ba
m
??
??
???
?
??
2011-10-16 66
cxt
),,2,1(0
.)(
,,,,
),,,(
2211
21
21
mi
c
F
xcxcxcXy
ccc
cccF
i
mm
m
m
?
?
?
?
??
?
?
????
为此,只需要令
:从而可以得出判别函数的值
的最大值点确定出参数求
2011-10-16 67
cxt
)()()()(
)(
1
)(
1
11
21
21
2211
22222121
11212111
BlB l i
n
i
BjB j iAlA l i
n
i
AjA j ijl
iBniBiB
b
Bi
iAniAiA
a
Ai
BiAii
mmmmmm
mm
mm
xxxxxxxxs
xxx
n
x
xxx
n
x
xxd
dcscscs
dcscscs
dcscscs
ba
b
a
??????
????
????
??
?
?
?
?
?
?
?
????
????
????
??
??
?
?
?
???????????
?
?
其中
2011-10-16 68
cxt
? (二) Fisher两类判别的计算步骤,
1、输入历史数据,计算 和
2,计算
3、解方程组,求出,建立判别函数
4、对新样本作判别
( 1)将新样本 p个观测值带入判别函数,求出 y值
( 2)确定临界值
分别将两类总体样本的判别函数之均值
求加权平均值 作为临界值。
)(AX? )(BX?
.2,1,,pksd kk ??
dsc? dsc 1??
mm xcxcxcXy ???? ?2211)(
)()(,BA yy
21
)2(2)1(1
0 nn
ynyny
?
??
2011-10-16 69
cxt
? 5、作出判别
(1)
(2)
)()( BA yy ?假定
时,不确定;=
类;时,判新样本属
类;时,判新样本属
yy
Byy
Ayy
0
0
0
?
?
)()( BA yy ?假定
时,不确定;=
类;时,判新样本属
类;时,判新样本属
yy
Ayy
Byy
0
0
0
?
?
2011-10-16 70
cxt
? (三 )判别效果的检验,
1、总体差异的显著性检验。
2、各判别变量的重要性检验。
2011-10-16 71
cxt
? 二、多个总体的 Fisher判别法
(一 ) 判别函数
Fisher判别法实际上是致力于寻找一个最能反映组和
组之间差异的投影方向, 即 寻 找 线 性 判 别 函
数, 设有 个总
体, 分别有均值向量,,…,
和协方差阵,分别各总体中得到样品,
pp xcxcxY ??? ?11)( k
kGGG,,,21 ? 1?? 2?? k??
k??,,1 ?
)1()1(1
1,,nXX ?
)2()2(1
2,,nXX ?
)()(1,,knk
kXX ?
?
2011-10-16 72
cxt
nnnn k ???? ?21
?
?
? in
t
i
t
i
i XnX 1
)(1第 i个总体的样本均值向量
?
?
? k
i
ii XnnX
1
1综合的样本均值向量
?? ???? int iitiiti XXXXV 1 )()( ))((
第 i个总体样本组内离差平方和
kVVVE ???? ?21
综合的组内离差平方和
2011-10-16 73
cxt
组间离差平方和 ?
? ????
k
i iii XXXXnB 1 ))((
? ?? ? ?????? i ini nt itiitiitiy YYYYYYV 1 1 )()(2)( ))(()( CVC i??
? ?? ? ????? ki ki iiy ECCCVCVE 1 10
2
0
11
( ) ( ) ( )
ink
i i i i i
ii
B n Y Y n Y Y Y Y C B C
??
??? ? ? ? ? ???
pp xcxcxY ??? ?11)(因为
2011-10-16 74
cxt
如果判别分析是有效的, 则所有的样品的线性组
合 满足组内离差平方和小,
而组间离差平方和大 。 则
pp xcxcxY ??? ?11)(
ma x)(
0
02 ?
?
???
ECC
BCC
E
BC?
。最大的特征根相对于的最大值是 1
0
02 )( ?EB
ECC
BCC
E
BC
?
????
1? ),,( 1111 ?? pccC ?
pp xcxcxY 11111 ??)(? ??? ?
而 所对应的特征向量即 。
Fisher样品判别函数是
2011-10-16 75
cxt
? 然而,如果组数 k太大,讨论的指标太多,则一个
判别函数是不够的,这时需要寻找第二个,甚至第
三个线性判别函数
其特征向量构成第二个判别函数的系数。
类推得到 m(m<k)个线性函数。
第二大的特征根相对于的最大值是 EBECC BCCEBC ?????
0
02 )(
),,( 2122 ?? pccC ?
pp xcxcxY 21122 ??)(? ??? ?
2011-10-16 76
cxt
? 关于需要几个判别函数得问题,需要累计判
别效率达到 85%以上,即有
设 为 B相对于 E得特征根,则
2 0
0
() B C BCC E C EC?? ? ? ?
12 p? ? ?? ? ?L
12
12
85%k
p
? ? ?
? ? ?
? ? ? ?
? ? ?
L
L
2011-10-16 77
cxt
? 以 m个线性判别函数得到的函数值为新的变
量,再进行距离判别。
? 判别规则,

设 Yi(X)为第 i个线性判别函数,, ),,2,1( mi ??
?? ?? ri kiik xyxyGxd 1 2))()((),(
),(m i n),( 1 kkjt GxdGxd ???tGx?
2011-10-16 78
cxt
7.5 select variables变量选择判别法
? stepwise selection discriminant analysis
? backward selection discriminant analysis
? forward selection discriminant analysis
2011-10-16 79
cxt
? Forward selection discriminant analysis,
the forward selection procedure begins by choosing the
variable that is expected to be the best discriminate among all
of the available variables.the variables that produces the
largest F value in a one-way analysis of variance(ANOVA) is
the first variable selected,
then choosing a second variables is considered,The second
variable that produces the largest F value in a one-way of
covariance(ANCOVA) using the first variable selected as a
covariate is statistically significant,
then choosing a third variable…..the forward procedure
stops when none of the remaining variables is statistically
significant,
2011-10-16 80
cxt
? Backward selection discriminant analysis,
the backward selection begins by including all prospective
variables as discriminators,after which it removes the variable
that seems to be the least useful for discriminating.if all
variables are statistically significant at a chosen significance
level,the procedure stops; but if some variables are not
statistically significant then the produce removes the variable
that is least significant,
if a variable is removes,then looks for a second variable to
remove……when all remaining variables are statistically
significant,the backward procedure stops,
2011-10-16 81
cxt
? Stepwise selection discriminant analysis,
this method selects variables for inclusion within each step,
at each step,before choosing a new variable to include,it
checks to see if all of the variables previously selected remain
significant,If a variable may seem very useful early,but after
a few additional variables are include,one selected earlier
may no longer be useful.the method would remove such a
variable,
……
when no other variables meet the criteria for entry or when
the variable to be included next is one that was just removed,
the procedure stops,
2011-10-16 82
cxt
向后剔除 开始时,所有变量都在模型中。每一步,
在 Wilks的统计量的准则下对模型中判别能力贡献
最小的变量剔除。当所有余下的变量都达到留在模
型中的标准时,向后剔除过程停止。
向前选入 开始时模型中没有变量。每一步,Wilks
的统计量最小者,进入模型。当不再有未被选入的
变量小于选入的临界值时,向前选入过程停止。
2011-10-16 83
cxt
逐步选择 开始时如同向前选择一样, 模型中没有变
量, 每一步都被检查 。 如果在 Wilks的准则下统计
量对模型的判别能力贡献最小的变量达不到留在模
型中的标准, 它就被剔除 。 否则, 不在模型中对模
型的判别能力贡献最大的变量被选入模型 。 当模型
中的所有变量都达到留在模型中的标准而没有其他
变量能达到进入模型的标准, 逐步选择过程停止 。
2011-10-16 84
cxt
逐步判别法采用有进有出的算法,即每一步都进行
检验。首先,将判别能力最强的变量引进判别函数,
而对较早进入判别函数的变量,随着其他变量的进
入,其显著性可能发生变化,如果其判别能力不强
了,则删除。
2011-10-16 85
cxt
7.6 Estimate the probabilities of correct classifications
( 判别效果检验)
Three basic methods:( Page 220)
1,Resubstitution estimates,
the method is to apply a discriminant rule to the data used to
develop the rule and observe how often the rule correctly
classifies these observations,
the biggest drawback,it overestimates the probabilities of
correct classification,although for extremely large sample sizes
the bias is not too bad,
2011-10-16 86
cxt
2,Estimates from holdout data,
a holdout data set is one for which we know where the
observations should be classified,but the holdout data are not
used to develop the discriminant rule,Then a discriminant rule
developed from other data can be applied to the holdout set to
see how well observations in the holdout data set are classified
according to the rule,And produce unbiased estimates of
probabilities of correct classification,
the biggest drawback,we may not actually be getting the
?best? possible discrimination rule because all the data are not
being used to obtain the rule,
2011-10-16 87
cxt
3,Cross-validation estimates:(p221)
2011-10-16 88
cxt
判别分析的 SPSS操作,
? 例 1,企图用一套打分体系来描绘企业的状况。该体系对每
个企业的一些指标(变量)进行评分。这些指标包括:企业
规模 (is),服务 (se),雇员工资比例 (sa),利润增长 (prr)、
市场份额 (ms),市场份额增长 (msr),流动资金比例 (cp)、
资金周转速度 (cs)等等。另外,有一些企业已经被某杂志划
分为上升企业、稳定企业和下降企业。
? 我们希望根据这些企业的上述变量的打分和它们已知的类别
( 三个类别之一,group-1代表上升, group-2代表稳定,
group-3代表下降 ) 找出一个分类标准, 以对没有被该刊物
分类的企业进行分类 。
? 该数据有 90个企业 ( 90个观测值 ), 其中 30个属于上升型,
30个属于稳定型, 30个属于下降型 。 这个数据就是一个, 训
练样本, 。
2011-10-16 89
cxt
2011-10-16 90
cxt
? 利用 SPSS软件的逐步判别法淘汰了不显著的流动资金
比例 (cp),还剩下七个变量 is,se,sa,prr,ms,
msr,cs,得 到 两 个 典 则 判 别 函 数 ( Canonical
Discriminant Function Coefficients),
? 0.035IS+3.283SE+0.037SA-0.007PRR+0.068MS-0.023MSR-
0.385CS-3.166
? 0.005IS+0.567SE+0.041SA+0.012PRR+0.048MS+0.044MSR-
0.159CS-4.384
? 这两个函数实际上是由 Fisher判别法得到的向两个
方向的投影 。 这两个典则判别函数的系数是下面的
SPSS输出得到的,
2011-10-16 91
cxt
C a n on i c a l D i s c r i m i n a n t F u n c t i on C oe f f i c i e n t s
,0 3 5, 0 0 5
3, 2 8 3, 5 6 7
,0 3 7, 0 4 1
-, 0 0 7, 0 1 2
,0 6 8, 0 4 8
-, 0 2 3, 0 4 4
-, 3 8 5 -, 1 5 9
- 3, 1 6 6 - 4, 3 8 4
I S 企业规模
S E 服务
S A 雇员工资比例
P R R 利润增长
M S 市场份额
M S R 市场份额增长
C S 资金周转速度
(C o n s t a n t )
1 2
F u n ct io n
U n s t a n d a r d iz e d co e f f i ci e n t s
根据这两个函数,从任何一个观测值(每个观测值都有
7个变量值)都可以算出两个数。把这两个数目当成该
观测值的坐标,这样数据中的 150个观测值就是二维平
面上的 150个点。它们的点图在下面图中。
2011-10-16 92
cxt
C a n o n i c a l D is c r im i n an t F u n c t io n s
F u n ct io n 1
100- 1 0
F
u
n
ct
io
n
2
4
3
2
1
0
-1
-2
-3
G R O U P
G r o u p C e n t r o i d s
3
2
1
3
2
1
2011-10-16 93
cxt
? 从上图可以看出,第一个投影(相应于来自于第一个
典则判别函数横坐标值)已经能够很好地分辨出三个
企业类型了。这两个典则判别函数并不是平等的。其
实一个函数就已经能够把这三类分清楚了。 SPSS的一
个输出就给出了这些判别函数(投影)的重要程度,
E i g e n v a l u e s
2 6, 6 7 3
a
9 9, 0 9 9, 0, 9 8 2
,2 6 2
a
1, 0 1 0 0, 0, 4 5 6
F u n c t i o n
1
2
E i g e n v a l u e % o f V a r i a n c e C u m u l a t i v e %
C a n o n i c a l
C o r r e l a t i o n
F i r s t 2 c a n o n i c a l d i s c r i m i n a n t f u n c t i o n s w e r e u s e d i n t h e
a n a l y s i s,
a,
2011-10-16 94
cxt
? 投影的重要性是和特征值的贡献率有关。该表说明第
一个函数的贡献率已经是 99%了,而第二个只有 1%。
当然,二维图要容易看一些。投影之后,再根据各点
的位臵远近算出具体的判别公式( SPSS输出),
C l a s s i f i c a t i o n F u n c t i o n C o e f f i c i e n t s
,1 1 8, 3 3 8, 5 5 4
,7 7 0 2 1, 3 2 9 4 1, 6 1 6
,3 4 5, 5 4 2, 8 1 1
,0 8 6, 0 2 9 -, 0 0 1
,3 5 5, 7 4 3 1, 2 0 3
,3 6 8, 1 7 3, 0 8 1
7, 5 3 1 5, 2 2 0 2, 7 4 2
- 5 7, 5 2 1 - 5 3, 7 0 4 - 9 6, 0 8 4
IS
SE
SA
P R R
MS
M S R
CS
( C o n s t a n t )
1, 0 0 2, 0 0 3, 0 0
G R O U P
F i s h e r ' s l i n e a r d i s c r i m i n a n t f u n c t i o n s
2011-10-16 95
cxt
? 该表给出了三个线性分类函数的系数。把每个观测点
带入三个函数,就可以得到分别代表三类的三个值,
哪个值最大,该点就属于相应的那一类。 计算机软件
的选项可以把这些训练数据的每一个点按照这里的分
类法分到某一类。当然,我们一开始就知道这些训练
数据的各个观测值的归属,但即使是这些训练样本的
观测值(企业)按照这里推导出的分类函数来分类,
也不一定全都能够正确划分。
2011-10-16 96
cxt
C l a s s i f i c a t i o n R e s u l t s
b,c
30 0 0 30
0 30 0 30
0 0 30 30
1 0 0, 0,0,0 1 0 0, 0
.0 1 0 0, 0,0 1 0 0, 0
.0,0 1 0 0, 0 1 0 0, 0
30 0 0 30
0 30 0 30
0 0 30 30
1 0 0, 0,0,0 1 0 0, 0
.0 1 0 0, 0,0 1 0 0, 0
.0,0 1 0 0, 0 1 0 0, 0
G R O U P
1, 0 0
2, 0 0
3, 0 0
1, 0 0
2, 0 0
3, 0 0
1, 0 0
2, 0 0
3, 0 0
1, 0 0
2, 0 0
3, 0 0
C o u n t
%
C o u n t
%
O r i g i n a l
C r o s s - v a l i d a t e d
a
1, 0 0 2, 0 0 3, 0 0
P r e d i c t e d G r o u p M e m b e r s h i p
T o t a l
C r o s s v a l i d a t i o n i s d o n e o n l y f o r t h o s e c a s e s i n t h e a n a l y s i s, I n c r o s s
v a l i d a t i o n,e a c h c a s e i s c l a s s i f i e d b y t h e f u n c t i o n s d e r i v e d f r o m a l l
c a s e s o t h e r t h a n t h a t c a s e,
a,
1 0 0, 0 % o f o r i g i n a l g r o u p e d c a s e s c o r r e c t l y c l a s s i f i e d,b,
1 0 0, 0 % o f c r o s s - v a l i d a t e d g r o u p e d c a s e s c o r r e c t l y c l a s s i f i e d,c,
2011-10-16 97
cxt
操作步骤,
? 执 行 菜 单 命 令, 单击 [ Analyze],[Classify]、
[Discriminant]
2011-10-16 98
cxt
2011-10-16 99
cxt
? ⑴ 指定分组变量及其取值范围 。
将分组变量从源变量窗口通过选择箭头选到分组变量
窗口, Grouping variable”。 并从, Define Range”按钮定
义分组变量的取值范围, 给定最小值 Minimum和最大值
Maximum。
? ⑵ 指定判别函数中的自变量 。
将自变量从源变量窗口通过选择箭头选到自变量窗口 。
? ⑶ 选择使用自变量的方法 。
对于选定的自变量可以全部应用到判别函数中去, 这是系
统默认的使用全部自变量法, Enter independent together”。
如果要对变量进行筛选检验, 将使用选项逐步进入法, Use stepwise method”。 使用该方法后, 按钮, Method”将被激活
2011-10-16 100
cxt
2011-10-16 101
cxt
2011-10-16 102
cxt
? ⑷ 统计量, 矩阵和函数系数的计算
按钮, Statistics”将打开统计计算窗口 。
计算各类别及总体
各变量均值、标准差
输出单变量
方差分析结果
各类协方差矩阵
相等的检验
计算判别函数系数
Fisher判别系数
非标准化 判别系数
组内相关矩阵
合并组内协方差矩阵
组间协方差矩阵
总协方差矩阵
2011-10-16 103
cxt
2011-10-16 104
cxt
2011-10-16 105
cxt
? ⑸分类方式和判别结果
单击按钮, Classify”将设臵分类所依据的判别先验概率
和协方差矩阵,以及输出图形和显示结果
先验概率的设定
各类取相等先验概率
根据各类样本个数
计算先验概率
输出分析结果
输出各样本的分类结果
如判别得分、判别类等
交叉检验结果
将缺失值用均值替代
选择分类使用
的协方差阵
组内协方差阵
分组协方差阵
作图
生成一张包括
各类的散点图
分类显示
各个类的散点图
分界图,将坐标平面划分为
不同的区域,每个区域将代表一个类
2011-10-16 106
cxt
2011-10-16 107
cxt
2011-10-16 108
cxt
? ⑹在 SPSS数据文件中生成新变量
单击, SAVE”按钮,保存预测的组别,判别得分和各组成员的事后概率
建立一个标明每个样本
所属的类别的变量
生成一个判别得分变量
样本属于某类的概率
2011-10-16 109
cxt
2011-10-16 110
cxt
? 例 2:研究某年全国各地区农民家庭收支的分布规律,
根据抽样调查资料进行分类,共抽取 28个省、市、自
治区的六个指标数据。先采用聚类分析,将 28个省、
市、自治区分为三组。北京、上海、广州 3个城市属于
待判样本。(数据家庭收支,sav)
2011-10-16 111
cxt
? 例 3:为研究某地区人口死亡状况,已按某种方法将 15
个已知样本单位分为三组,选择判别变量为 2个,55岁
组死亡概率 q55和 80岁组死亡概率 q80。 建立判别函数,
判定另外 4个待判样本属于何组。数据见死亡率 1.sav
2011-10-16 112
cxt
? 例 4:为研究某地区人口死亡状况,已按某种方法将 15
个已知样本点分为三组,选择判别变量为 6个,0岁组
死亡概率 q0,1岁组死亡概率 q1,10岁组死亡概率 q10,55
岁组死亡概率 q55,80岁死亡概率 q80,平均预期寿命
e0。 建立判别函数以便在人寿保险中应用。试用逐步
判别法建立判别函数,判定另外 4个待判样本点属于何
组。数据见死亡率 2.sav
2011-10-16 113
cxt
? 例 5:鸢尾花数据 (花瓣,花萼的长宽 ) 5个变量,花瓣长
(slen),花瓣宽 (swid),花萼长 (plen),花萼宽 (pwid),分
类号 (1:Setosa,2:Versicolor,3:Virginica)(data14-04)
2011-10-16 114
cxt
? Statistics→Classify →Discriminant,
? Variables,independent (slen,swid,plen,pwid)
Grouping(spno) Define range(min-1,max-3)
? Classify,prior probability(All group equal) use
covariance matrix (Within-groups) Plots (Combined-
groups,Separate-groups,Territorial map) Display
(Summary table)
? Statistics,Descriptive (Means) Function
Coefficients (Fisher’s,Unstandardized) Matrix
(Within-groups correlation,Within-groups covariance,
Separate-groups covariance,Total covariance)
? Save,(Predicted group membership,Discriminant
Scores,Probability of group membership)
2011-10-16 115
cxt
鸢尾花数据 (数据分析过程简明表 )
A n a l y s i s C a s e P r o c e s s i n g S u m m a r y
1 5 0 1 0 0, 0
0,0
0,0
0,0
0,0
1 5 0 1 0 0, 0
U n w e i g h t e d C a s e s
V a l i d
M i s s i n g o r o u t - o f - r a n g e
g r o u p c o d e s
A t l e a s t o n e m i s s i n g
d i s c r i m i n a t i n g v a r i a b l e
B o t h m i s s i n g o r
o u t - o f - r a n g e g r o u p
c o d e s a n d a t l e a s t o n e
m i s s i n g d i s c r i m i n a t i n g
v a r i a b l e
T o t a l
E x c l u d e d
T o t a l
N P e r c e n t
2011-10-16 116
cxt
鸢尾花数据 (原始数据的描述 )
G r o u p S t a t i s t i c s
5 0, 0 6 3, 5 2 5 50 5 0, 0 0 0
3 4, 2 8 3, 7 9 1 50 5 0, 0 0 0
1 4, 6 2 1, 7 3 7 50 5 0, 0 0 0
2, 4 6 1, 0 5 4 50 5 0, 0 0 0
5 9, 3 6 5, 1 6 2 50 5 0, 0 0 0
2 7, 6 6 3, 1 4 7 50 5 0, 0 0 0
4 2, 6 0 4, 6 9 9 50 5 0, 0 0 0
1 3, 2 6 1, 9 7 8 50 5 0, 0 0 0
6 6, 3 8 7, 1 2 8 50 5 0, 0 0 0
2 9, 8 2 3, 2 1 8 50 5 0, 0 0 0
5 5, 6 0 5, 5 4 0 50 5 0, 0 0 0
2 0, 2 6 2, 7 4 7 50 5 0, 0 0 0
5 8, 6 0 8, 6 3 3 1 5 0 1 5 0, 0 0 0
3 0, 5 9 4, 3 6 3 1 5 0 1 5 0, 0 0 0
3 7, 6 1 1 7, 6 8 2 1 5 0 1 5 0, 0 0 0
1 1, 9 9 7, 6 2 2 1 5 0 1 5 0, 0 0 0
花萼长
花萼宽
花瓣长
花瓣宽
花萼长
花萼宽
花瓣长
花瓣宽
花萼长
花萼宽
花瓣长
花瓣宽
花萼长
花萼宽
花瓣长
花瓣宽
分类
刚毛鸢尾花
变色鸢尾花
佛吉尼亚鸢尾花
T o t a l
M e a n
S t d,
D e v i a t i o n U n w e i g h t e d W e i g h t e d
V a l i d N ( l i s t w i s e )
2011-10-16 117
cxt
鸢尾花数据 (合并类内相关阵和协方差阵 )
P o o l e d W i t h i n - G r o u p s M a t r i c e s
a
2 9, 9 6 0 8, 7 6 7 1 6, 1 2 9 4, 3 4 0
8, 7 6 7 1 1, 5 4 2 5, 0 3 3 3, 1 4 5
1 6, 1 2 9 5, 0 3 3 1 8, 5 9 7 4, 2 8 7
4, 3 4 0 3, 1 4 5 4, 2 8 7 4, 1 8 8
1, 0 0 0, 4 7 1, 6 8 3, 3 8 7
,4 7 1 1, 0 0 0, 3 4 4, 4 5 2
,6 8 3, 3 4 4 1, 0 0 0, 4 8 6
,3 8 7, 4 5 2, 4 8 6 1, 0 0 0
花萼长
花萼宽
花瓣长
花瓣宽
花萼长
花萼宽
花瓣长
花瓣宽
C o v a r i a n c e
C o r r e l a t i o n
花萼长 花萼宽 花瓣长 花瓣宽
T h e c o v a r i a n c e m a t r i x h a s 1 4 7 d e g r e e s o f f r e e d o m,a,
2011-10-16 118
cxt
鸢尾花数据 (总协方差阵 )
C o v a r i a n c e M a t r i c e s
a
1 2, 4 2 5 9, 9 2 2 1, 6 3 6 1, 0 3 3
9, 9 2 2 1 4, 3 6 9 1, 1 7 0, 9 3 0
1, 6 3 6 1, 1 7 0 3, 0 1 6, 6 0 7
1, 0 3 3, 9 3 0, 6 0 7 1, 1 1 1
2 6, 6 4 3 8, 2 8 8 1 8, 2 9 0 5, 5 7 8
8, 2 8 8 9, 9 0 2 8, 1 2 7 4, 0 4 9
1 8, 2 9 0 8, 1 2 7 2 2, 0 8 2 7, 3 1 0
5, 5 7 8 4, 0 4 9 7, 3 1 0 3, 9 1 1
5 0, 8 1 2 8, 0 9 0 2 8, 4 6 1 6, 4 0 9
8, 0 9 0 1 0, 3 5 5 5, 8 0 4 4, 4 5 6
2 8, 4 6 1 5, 8 0 4 3 0, 6 9 4 4, 9 4 3
6, 4 0 9 4, 4 5 6 4, 9 4 3 7, 5 4 3
7 4, 5 3 7 - 4, 6 8 3 1 3 0, 0 3 6 5 3, 5 0 7
- 4, 6 8 3 1 9, 0 3 6 - 3 3, 0 5 6 - 1 2, 0 8 3
1 3 0, 0 3 6 - 3 3, 0 5 6 3 1 2, 6 7 0 1 2 9, 8 0 3
5 3, 5 0 7 - 1 2, 0 8 3 1 2 9, 8 0 3 5 8, 1 0 1
花萼长
花萼宽
花瓣长
花瓣宽
花萼长
花萼宽
花瓣长
花瓣宽
花萼长
花萼宽
花瓣长
花瓣宽
花萼长
花萼宽
花瓣长
花瓣宽
分类
刚毛鸢尾花
变色鸢尾花
佛吉尼亚鸢尾花
T o t a l
花萼长 花萼宽 花瓣长 花瓣宽
T h e t o t a l c o v a r i a n c e m a t r i x h a s 1 4 9 d e g r e e s o f f r e e d o m,a,
2011-10-16 119
cxt
鸢尾花数据 (特征值表 )
? Eigenvalue:用于分析的前两个典则判别函数的特征值,
是组间平方和与组内平方和之比值, 最大特征值与组均值最
大的向量对应,第二大特征值对应着次大的组均值向量
典则相关系数 (canonical correlation):是组间平方和
与总平方和之比的平方根,被平方的是由组间差异解释的变
异总和的比,
E i g e n v a l u e s
3 0, 4 1 9
a
9 9, 0 9 9, 0, 9 8 4
,2 9 3
a
1, 0 1 0 0, 0, 4 7 6
F u n c t i o n
1
2
E i g e n v a l u e % o f V a r i a n c e C u m u l a t i v e %
C a n o n i c a l
C o r r e l a t i o n
F i r s t 2 c a n o n i c a l d i s c r i m i n a n t f u n c t i o n s w e r e u s e d i n t h e
a n a l y s i s,
a,
2011-10-16 120
cxt
鸢尾花数据 (Wilks’ Lambda统计量 )
? 检验的零假设是各组变量均值相等, Lambda接近
0表示组均值不同,接近 1表示组均值没有不同,
Chi-square是 lambda的卡方转换,用于确定其
显著性,
W i l k s ' L a m b d a
,0 2 5 5 3 8, 9 5 0 8, 0 0 0
,7 7 4 3 7, 3 5 1 3, 0 0 0
T e s t o f F u n c t i o n ( s )
1 t h r o u g h 2
2
W i l k s ' L a m b d a C h i - s q u a r e df S i g,
2011-10-16 121
cxt
鸢尾花数据 (有关判别函数的输出 )
1 1 2 3 4
2 1 2 3 4
0, 3 4 6 0, 5 2 5 0, 8 4 6 0, 6 1 3
0, 0 3 9 0, 7 4 2 0, 3 8 6 0, 5 5 5
y x x x x
y x x x x
? ? ? ? ?
? ? ? ?
S t a n d a r d i z e d C a n o n i c a l D i s c r i m i n a n t
F u n c t i o n C o e f f i c i e n t s
-, 3 4 6, 0 3 9
-, 5 2 5, 7 4 2
,8 4 6 -, 3 8 6
,6 1 3, 5 5 5
花萼长
花萼宽
花瓣长
花瓣宽
1 2
F u n c t i o n
标准化的典型判别函数
系数 (使用时必须用标
准化的自变量 )
2011-10-16 122
cxt
C a n o n i c a l D i s c r i m i n a n t F u n c t i o n C o e f f i c i e n t s
-, 0 6 3, 0 0 7
-, 1 5 5, 2 1 8
,1 9 6 -, 0 8 9
,2 9 9, 2 7 1
- 2, 5 2 6 - 6, 9 8 7
花萼长
花萼宽
花瓣长
花瓣宽
( C o n s t a n t )
1 2
F u n c t i o n
U n s t a n d a r d i z e d c o e f f i c i e n t s
典型判别函数系数
1 1 2 3 4
2 1 2 3 4
0, 0 6 3 0, 1 5 5 0, 1 9 6 0, 2 9 9 2, 5 2 6
0, 0 0 7 0, 2 1 8 0, 0 8 9 0, 2 7 1 6, 9 4 8
y x x x x
y x x x x
? ? ? ? ? ?
? ? ? ? ?
2011-10-16 123
cxt
? 类均值 (重心 )处的典则判别函数值
F u n c t i o n s a t G r o u p C e n t r o i d s
- 7, 3 9 2, 2 1 9
1, 7 6 3 -, 7 3 7
5, 6 2 9, 5 1 8
分类
刚毛鸢尾花
变色鸢尾花
佛吉尼亚鸢尾花
1 2
F u n c t i o n
U n s t a n d a r d i z e d c a n o n i c a l d i s c r i m i n a n t
f u n c t i o n s e v a l u a t e d a t g r o u p m e a n s
2011-10-16 124
cxt
鸢尾花数据 (用判别函数对观测量分类结果 )
C l a s s i f i c a t i o n P r o c e s s i n g S u m m a r y
1 5 0
0
0
1 5 0
P r o c e s s e d
M i s s i n g o r o u t - o f - r a n g e
g r o u p c o d e s
A t l e a s t o n e m i s s i n g
d i s c r i m i n a t i n g v a r i a b l e
E x c l u d e d
U s e d i n O u t p u t
P r i o r P r o b a b i l i t i e s f o r G r o u p s
,3 3 3 50 5 0, 0 0 0
,3 3 3 50 5 0, 0 0 0
,3 3 3 50 5 0, 0 0 0
1, 0 0 0 1 5 0 1 5 0, 0 0 0
分类
刚毛鸢尾花
变色鸢尾花
佛吉尼亚鸢尾花
T o t a l
P r i o r U n w e i g h t e d W e i g h t e d
C a s e s U s e d i n A n a l y s i s
先验概率
C l a s s i f i c a t i o n F u n c t i o n C o e f f i c i e n t s
1, 6 8 7 1, 1 0 1, 8 6 5
2, 6 9 5 1, 0 7 0, 7 4 7
-, 8 8 0 1, 0 0 1 1, 6 4 7
- 2, 2 8 4, 1 9 7 1, 6 9 5
- 8 0, 2 6 8 - 7 1, 1 9 6 - 1 0 3, 8 9 0
花萼长
花萼宽
花瓣长
花瓣宽
( C o n s t a n t )
刚毛鸢尾花 变色鸢尾花
佛吉尼亚
鸢尾花
分类
F i s h e r ' s l i n e a r d i s c r i m i n a n t f u n c t i o n s
费歇判别函数系数
把自变量代入三个
式子,哪个大归谁,
2011-10-16 125
cxt
Territory Map(区域图 )
Canonical Discriminate Function 1 Versus
Canonical Discriminate
Function 2三种 鸢尾花 的典
型变量值把一个典型变
量组成的坐标平面分成
三个区域, *为中心坐标,
Territorial Map
Canonical Discriminant
Function 2
-12.0 -8.0 -4.0,0 4.0 8.0 12.0
趄蝌蝌蝌蝌趄蝌蝌蝌蝌趄蝌蝌蝌蝌趄蝌蝌蝌蝌趄蝌蝌蝌蝌趄蝌蝌蝌蝌
12.0 12 23
12 23
12 23
12 23
12 23
12 23
8.0 12 23
12 23
12 23
12 23
12 23
12 23
4.0 12 23
12 23
12 23
12 23
12 23
12 23 *
,0 * 12 23
12 * 23
12 23
12 23
12 23
12 23
-4.0 12 23
12 23
12 23
12 23
12 23
12 23
-8.0 12 23
12 23
12 23
12 23
12 23
12 23
-12.0 12 23
趄蝌蝌蝌蝌趄蝌蝌蝌蝌趄蝌蝌蝌蝌趄蝌蝌蝌蝌趄蝌蝌蝌蝌趄蝌蝌蝌蝌
-12.0 -8.0 -4.0,0 4.0 8.0 12.0
Canonical Discriminant Function 1
Symbols used in territorial map
Symbol Group Label
------ ----- --------------------
1 1 刚毛鸢尾花
2 2 变色鸢尾花
3 3 佛吉尼亚鸢尾花
* Indicates a group centroid
2011-10-16 126
cxt
Canonical Discriminant Functions
Function 1
100-10
Function 2
3
2
1
0
-1
-2
-3
2? àà
Group Centroids
2e ?a ?á ?? e°?2 ?¨
±? é? e°?2 ?¨
?? ?? e°?2 ?¨
2e ?a ?á ?? e°?2 ?¨
±? é? e°?2 ?¨
?? ?? e°?2 ?¨
2011-10-16 127
cxt
Canonical Discriminant Functions
2? àà = ? ? ?? e°?2 ?¨
Function 1
-5-6-7-8-9-10
Function 2
3
2
1
0
-1
-2
-3
Group Centroid
Group Centroid
?? ?? e°?2 ?¨
2011-10-16 128
cxt
Canonical Discriminant Functions
2? àà = ± ? é? e°?2 ?¨
Function 1
543210-1
Function 2
2
1
0
-1
-2
-3
Group Centroid
Group Centroid
±? é? e°?2 ?¨
2011-10-16 129
cxt
Canonical Discriminant Functions
2? àà = 2 e ?a ?á ?? e°?2 ?¨
Function 1
109876543
Function 2
3
2
1
0
-1
-2
-3
Group Centroid
Group Centroid
2e ?a ?á ?? e°?2 ?¨
2011-10-16 130
cxt
鸢尾花数据 (预测分类结果小结 )
C l a s s i f i c a t i o n R e s u l t s
a
50 0 0 50
0 48 2 50
0 1 49 50
1 0 0, 0,0,0 1 0 0, 0
.0 9 6, 0 4, 0 1 0 0, 0
.0 2, 0 9 8, 0 1 0 0, 0
分类
刚毛鸢尾花
变色鸢尾花
佛吉尼亚鸢尾花
刚毛鸢尾花
变色鸢尾花
佛吉尼亚鸢尾花
C o u n t
%
O r i g i n a l
刚毛鸢尾花 变色鸢尾花
佛吉尼亚
鸢尾花
P r e d i c t e d G r o u p M e m b e r s h i p
T o t a l
9 8, 0 % o f o r i g i n a l g r o u p e d c a s e s c o r r e c t l y c l a s s i f i e d,a,
可以看出错判率