您好,欢迎访问三七文档
例题1:下表是我国16个地区农民在1982年支出情况的抽样调查数据的汇总资料,每个地区都调查了反映每人平均生活消费支出情况的六个指标。试利用调查资料对16个地区进行分类。地区食品衣着燃料住房生活用品及其他文化生活服务支出北京190.3343.779.7360.5449.019.04天津135.236.410.4744.1636.493.94河北95.2122.839.322.4422.812.8山西104.7825.116.49.8918.173.25内蒙古128.4127.638.9412.5823.993.27辽宁145.6832.8317.1927.2939.093.47吉林159.3733.3818.3711.8125.295.52黑龙江116.2229.5713.2413.7621.756.04上海221.1138.6412.53115.6550.825.89江苏144.9829.1211.6742.627.35.74浙江169.9232.7512.7247.1234.355安徽153.1123.0915.6223.5418.186.39福建144.9221.2616.9619.5221.756.73江西140.5121.517.6419.1915.974.94山东115.8430.2612.233.6133.773.85河南101.1823.268.4620.220.54.3下面用统计学软件SAS(StatisticalAnalysisSystem)datadfdf;inputcity$x1x2x3x4x5x6;cards;beijing190.3343.779.7360.5449.019.04tianjing135.2036.4010.4744.1636.493.94hebei95.2122.839.3022.4422.812.80shanxi104.7825.116.409.8918.173.25neimenggu128.4127.638.9412.5823.993.27liaoning145.6832.8317.1927.2939.093.47jilin159.3733.3818.3711.8125.295.22heilongjiang116.2229.5713.2413.7621.756.04shanghai221.1138.6412.53115.6550.825.89jiangsu144.9829.1211.6742.6027.305.74zhejiang169.9232.7512.7247.1234.355.00anhui153.1123.0915.6223.5418.186.39fujian144.9221.2616.9619.5221.756.73jiangxi140.5421.5017.6419.1915.974.94shandong115.8430.2612.2033.6133.773.85henan101.1823.268.4620.2020.504.30;run;procclusterdata=dfdfstdouttree=treemethod=avepesudorsq;idcity;run;/*ward离差平方和法war;类平均法ave;重心法cen;最长距离法com;中间距离法med;最短距离法sin;密度估计法den;极大似然法eml;可变类平均fle;相似分析法mcq;两阶段密度估计two;*/proctreedata=treeout=newgraphicshorizontal;idcity;run;ClusterHistoryNormRMSNCLClustersJoined---FREQSPRSQRSQPSFPST2Dist15anhuifujian20.00250.99828.7.0.19314hebeihenan20.00550.99219.1.0.286913CL14shanxi30.00680.98516.71.20.311612CL15jiangxi30.00990.97514.440.348111jiangsuzhejiang20.00890.96614.4.0.36610CL13neimengg40.01060.95614.41.70.36929tianjingshandong20.00920.94715.5.0.37118CL9CL1140.02370.92313.72.60.49577liaoningjilin20.01890.90414.1.0.53296heilongjCL1240.02670.87714.34.30.54635CL8CL760.05280.82412.93.50.66814CL5CL6100.12690.6989.26.60.78233CL4CL10140.19550.5026.67.80.87512beijingshanghai20.05620.44611.3.0.91841CL2CL3160.44580.11.31.5454cityneimenggshanxihenanhebeijiangxifujiananhuiheilongjjilinliaoningzhejiangjiangsushandongtianjingshanghaibeijingAverageDistanceBetweenClusters0.00.20.40.60.81.01.21.41.6(1)2R统计量(列标题为RSQ)用于评价每次合并成NCL个类时的聚类效果。现考察2R的值随NCL的变化。比如,在分为四个类之前(4NCL)的并类过程中2R的减少是逐渐的,改变不大;当分为四个类时的240.697R,而下一次合并后分为三个类时23R下降较多(230.502R),由此可以通过对2R统计量的变化分析可得出分为四个类是较合适的。(2)半偏2NCLR(列标题为SPRSQ)得到。根据半偏2NCLR的值是上一步骤21NCLR与该步骤2NCLR的差值,故某步骤的半偏2NCLR值越大,说明上一步骤合并的效果越好,此例半偏2NCLR最大和次大分别为1,34NCL和,说明根据半偏2R准则分为两个类,四个类和五个类是较合适的。(3)伪F统计量(列标题为PSF)用于评价分为NCL个类的聚类效果。伪NCLF值越大表示这些观测样品可以显著地分为NCL个类。此例中伪NCLF最大和次大分别为52NCL和(当6NCL〈),说明根据伪F准则分为五个类或两个类较合适的。(4)伪2t统计量(列标题为2PST)用以评价此步骤合并的效果。由该统计量的定义知,伪2t大表明上一次合并的两个类是很分开的,也就是上依次聚类的效果是好的。此例子中2t最大和次大分别为1,34NCL和,说明根据伪2t准则分为两个类,四个类和五个类是较合适的。综合分析,认为采用类平均法分类,将16个地区分为两个类或五个类较合适。分为五个类的结果为:{北京},{上海},{天津、山东、江苏、浙江、辽宁、吉林},{黑龙江、安徽、福建、江西},{河北、河南、山西、内蒙};若分为两类,{北京,上海},{天津、山东、江苏、浙江、辽宁、吉林,黑龙江、安徽、福建、江西,河北、河南、山西、内蒙}。类别第一类第二类第三类第四类第五类该类所包含的区域河北河南山西内蒙黑龙江安徽福建江西天津山东江苏浙江辽宁吉林北京上海食品平均消费107.395138.698145.165190.33221.11衣着平均24.70823.85532.45743.7738.64消费燃料平均消费8.27515.86513.8709.7312.53住房平均消费16.27819.00034.43160.54115.65生活用品以及其他平均消费21.36819.41332.71549.0150.82文化生活服务支出平均消费3.4056.0254.5379.045.89例题2:对305名女中学生测量八个体型指标:1x:身高5x:体重2x:手臂长6x:颈围3x上肢长7x:胸围4x:下肢长8x:胸宽相关矩阵如下表。我们用相关系数来度量各对变量之间的相似性。相应于最长距离法,类与类之间的相似系数定义为两类变量间的最小相关系数,每次聚类时合并两个相似系数最大的类。1x2x3x4x5x6x7x8x1x1.0002x0.8461.0003x0.8050.8811.0004x0.8590.8260.8011.0005x0.4730.3760.3800.4361.0006x0.3980.3260.3190.3290.7621.0007x0.3010.2770.2370.3270.7300.5831.0008x0.3820.4150.3450.3650.6290.5770.5391.000/*用变量聚类过程varclus对变量进行分类*/datajlfx(type=corr);inputidx1x2x3x4x5x6x7x8;_type_='corr';cards;11.000.......20.8461.000......30.8050.8811.000.....40.8590.8260.8011.000....50.4730.3760.3800.4361.000...60.3980.3260.3190.3290.7621.000..70.3010.2770.2370.3270.7300.5831.000.80.3820.4150.3450.3650.6290.5770.5391.000;run;procvarclusdata=jlfxmaxc=8outtree=tree;varx1x2x3x4x5x6x7x8;run;proctreedata=tree;run;NumberofClusters86420NameofVariableorClusterx5x6x7x8x1x4x2x3
本文标题:(6)聚类分析例子
链接地址:https://www.777doc.com/doc-6329635 .html