多元统计与程序设计》课程实验报告
项目名称:
学生姓名:
学生学号:
指导教师:
完成日期:
1 实验内容
2 模型建立与求解 2.1聚类分析的形成思路
2.2.1类平均法
2.2.2谱系图的形成
2.3.快速聚类法 (以上内容见课本) 3 实验数据与实验结果
3.1实验数据
设有20个土壤样品分别对5个变量的观测数据如表5.16所示,试利用 聚类法对其进行样品聚类分析
样品号 含沙量1X 淤泥含量2X 粘土含量3X 有机物4X PH 值5X 1 77.3 13.0 9.7 1.5 6.4 2 82.5 10.0 7.5 1.5 6.5 3 66.9 20.0 12.5 2.3 7.0 4 47.2 33.3 19.0 2.8 5.8 5 65.3 20.5 14.2 1.9 6.9 6 83.3 10.0 6.7 2.2 7.0 7 81.6 12.7 5.7 2.9 6.7 8 47.8 36.5 15.7 2.3 7.2 9 48.6 37.1 14.3 2.1 7.2 10 61.6 25.5 12.6 1.9 7.3 11 58.6 26.5 14.9 2.4 6.7 12 69.3 22.3 8.4 4.0 7.0 13 61.8 30.8 7.4 2.7 6.4 14 67.7 25.3 7.0 4.8 7.3 15 57.2 31.2 11.6 2.4 6.3 16 67.2 22.7 10.1 33.3 6.2 17 59.2 31.2 9.6 2.4 6.0 18
80.2
13.2
6.6
2.0
5.8
19 82.2 11.1 6.7 2.2 7.2 20
69.7
20.7
9.6
3.1
5.9
3.2实验过程及结果 Case Processing Summary(a)
Cases
Valid Missing Total N Percent N Percent N Percent 20 100.0% 0 .0% 20 100.0%
a Squared Euclidean Distance used
上表是接近度矩阵,计算距离使用的是平方欧氏距离,所以样品间距离越大,样品越相异,由表中矩阵可以看出样品8号和样品9号的距离是最小的,因此它们最先聚为一类。
Average Linkage (Between Groups)
Agglomeration Schedule
Stage Cluster Combined
Coefficient
s Stage Cluster First
Appears
Next Stage
Cluster 1 Cluster 2
Cluster 1 Cluster 2 1
8
9
.153
16
2 6 19 .17
3 0 0 8 3 3 5 .273 0 0 7
4 2 7 .524 0 0 8
5 12 14 .624 0 0 13
6 15 1
7 .656 0 0 9 7 3 10 1.061 3 0 10
8 2 6 1.120 4 2 11
9 13 15 1.240 0 6 15 10 3 11 1.522 7 0 13 11 1 2 2.008 0 8 14 12 18 20 2.223 0 0 14 13 3 12 3.519 10 5 15 14 1 18 4.926 11 12 17 15 3 13 5.014 13 9 16 16 3 8 6.646 15 1 17 17 1 3 10.557 14 16 18 18 1 4 17.079 17 0 19 19 1
16
24.533
18
上表是反应每一阶段聚类的结果,可见第一阶段时第8个样品和第9个样品聚为一类。
聚合系数随分类数变化曲线
0510152025
300
5
1015
20
分类数
聚合系数
系列1
从上曲线可以看出当分类数为4或5时,曲线变得平缓。
Dendrogram
{16},第二类{4},第三类{1,2,6,7,18,19,20},剩下的为第四类。
上图是冰柱图,我们把它分成四类,每个样品后边有一列X,如果个数少于4,那么它与前面多于4个X的样品聚为一类,由上图很容易看出分类结果。
Quick Cluster
Initial Cluster Centers
Cluster
1 2 3 4
含沙量69.3 83.3 67.2 47.8 淤泥含
量
22 10 23 37 粘土含
量
8.4 6.7 10.1 15.7 有机物 4.0 2.2 33.3 2.3 PH值7.0 7.0 6.2 7.2
Iteration History(a)
Iterat ion
Change in Cluster Centers 1 2 3 4
1 6.015 2.765 .000 3.210
2 .000 .000 .000 .000
a Convergence achieved due to no or small change in cluster centers. The maximum absolute coordinate change for any center is .000. The current iteration is 2. The minimum distance between initial centers is 18.799.
Cluster Membership
Case
Number 样品号Cluster Distanc
e
1 1
2 4.869
2 2 2 2.224
3 3 1 5.677
4 4 4 5.115
5 5 1 5.662
6 6 2 2.765
7 7 2 2.019
8 8 4 3.210
9 9 4 3.215
10 10 1 3.683
11 11 1 7.433
12 12 1 6.015
13 13 1 7.384
14 14 1 5.351
15 15 4 8.530
16 16 3 .000
17 17 1 8.429
18 18 2 2.065 19 19 2 1.393 20 20 1 6.774
上表是样品的分类情况,快速聚类法将样品分为这样四类:第一类{3,5,10,11,12,13,14,17,20},第二类{1,2,6,7,18,19},第三类{16},第四类{4,8,9,15}。
Final Cluster Centers
Cluster
1 2 3 4 含沙量 64.5 81.2 67.2 50.2 淤泥含
量
25 12 23 35
粘土含
量
10.7 7.2 10.1 15.2
有机物 2.8 2.1 33.3 2.4 PH 值 6.7 6.6 6.2 6.6
Distances between Final Cluster Centers
Clust er 1 2 3 4 1 21.547 30.669 17.854 2 21.547 36.093 39.327 3 30.669 36.093 37.541 4 17.854 39.327 37.541 ANOVA
Cluster Error F Sig. Mean Square df Mean
Square df 含沙量 797.706 3 14.693 16 54.291 .000 淤泥含
量
442.583 3 11.208 16 39.489 .000
粘土含
量
51.435 3 6.682 16 7.697 .002
有机物 301.257 3 .585 16 515.244 .000 PH 值 .088 3 .301 16 .293 .830 The F tests should be used only for descriptive purposes because the clusters have been chosen to maximize the differences among cases in
different clusters. The observed significance levels are not corrected for this and thus cannot be interpreted as tests of the hypothesis that the cluster means are equal.
上表是方差分析表,从中可以看出,有4个变量对分类贡献显著。
Number of Cases in each Cluster
Clust er 1 9.000
2 6.000
3 1.000
4 4.000
Valid 20.000
Missing .000
用系统聚类法,分为4类,结果如下:
第一类{16},
第二类{4},
第三类{1,2,6,7,18,19,20},
剩下的为第四类。
用快速聚类法将样品分为这样四类:
第一类{3,5,10,11,12,13,14,17,20},
第二类{1,2,6,7,18,19},
第三类{16},
第四类{4,8,9,15}。
用两种方法得出的分类结果稍有不同,这时需要综合考虑分类问题本身的知识来决定归为哪一类会好些。