请选择 进入手机版 | 继续访问电脑版
楼主: dimxu
8818 14

[原创博文] 关于距离矩阵,用于proc cluster [推广有奖]

  • 4关注
  • 1粉丝

讲师

12%

还不是VIP/贵宾

-

威望
0
论坛币
109572 个
通用积分
0.0400
学术水平
2 点
热心指数
3 点
信用等级
2 点
经验
8719 点
帖子
239
精华
0
在线时间
553 小时
注册时间
2005-10-12
最后登录
2024-3-24

dimxu 在职认证  发表于 2012-4-9 22:07:23 |显示全部楼层 |坛友微信交流群
200论坛币
现在有一组数据需要进行聚类分析,要先计算出距离矩阵。

我现在需要的距离矩阵需要满足 dij = sqrt(2*(1-cij))
其中dij是距离矩阵中的元素;
cij表示数据集中两个变量间的相关系数,来自于通过数据集不同变量间计算corr 矩阵中的对应元素。

比如 数据集A:

x    y    z                                                                                x    y    z
1    4    5                可以计算得到一个corr矩阵                  x   1   *   *
3    1    2             ===================>            y   *    1    *
5    3    8                                                                           z    *   *     1

现在我要计算这个距离矩阵用于proc cluster,但是我不知道这个距离矩阵该怎么算比较好,如果用proc corr + proc iml 算效率会不会很差,因为我要算几百次这样的聚类。

好像proc distance能算这个矩阵,但是我不确定能不能直接用这个距离关系。
补充: 大家有没有别的方法可以计算出按照上述关系进行的聚类分析?

本人是初学者,希望各位高手多多帮忙。

谢谢

关键词:Cluster 距离矩阵 ROC CLU Distance 元素

回帖推荐

jason_huo 发表于6楼  查看完整内容

要看呢具体做什么吧,如果你只关心结果而不是其中的算法,那样就用proc stdize对变量进行标准化,然后用proc cluster进行聚类,出来的结果就会准确。关于cluster中的method选择,可以参考下面的文档。如果你的数据量比较大的话,建议使用proc fastclus PROC CLUSTER METHOD=name ; The PROC CLUSTER statement starts the CLUSTER procedure, specifies a clustering method, and optionally specifies details for cluste ...

本帖被以下文库推荐

dimxu 在职认证  发表于 2012-4-10 17:13:01 |显示全部楼层 |坛友微信交流群
大家帮帮忙啊....真的不知道该怎么算...

使用道具

jason_huo 发表于 2012-4-10 18:24:32 |显示全部楼层 |坛友微信交流群
用proc stdize对数据进行标准化,然后再跑proc cluster就可以了

使用道具

jason_huo 发表于 2012-4-10 18:25:34 |显示全部楼层 |坛友微信交流群
而且proc cluster可以选择不同的method,已经包括你所说的corr矩阵的问题

使用道具

dimxu 在职认证  发表于 2012-4-10 19:07:03 |显示全部楼层 |坛友微信交流群
jason_huo 发表于 2012-4-10 18:25
而且proc cluster可以选择不同的method,已经包括你所说的corr矩阵的问题
高人能讲的具体点吗 我是个初学者,不是太了解这些过程。
十分感谢

使用道具

jason_huo 发表于 2012-4-10 19:16:15 |显示全部楼层 |坛友微信交流群
dimxu 发表于 2012-4-10 19:07
高人能讲的具体点吗 我是个初学者,不是太了解这些过程。
十分感谢
要看呢具体做什么吧,如果你只关心结果而不是其中的算法,那样就用proc stdize对变量进行标准化,然后用proc cluster进行聚类,出来的结果就会准确。关于cluster中的method选择,可以参考下面的文档。如果你的数据量比较大的话,建议使用proc fastclus

PROC CLUSTER METHOD=name <options> ;
The PROC CLUSTER statement starts the CLUSTER procedure, specifies a clustering method, and optionally specifies details for clustering methods, data sets, data processing, and displayed output.

The METHOD= specification determines the clustering method used by the procedure. Any one of the following 11 methods can be specified for name:


AVERAGE  |  AVE
requests average linkage (group average, unweighted pair-group method using arithmetic averages, UPGMA). Distance data are squared unless you specify the NOSQUARE option.


CENTROID  |  CEN
requests the centroid method (unweighted pair-group method using centroids, UPGMC, centroid sorting, weighted-group method). Distance data are squared unless you specify the NOSQUARE option.


COMPLETE  |  COM
requests complete linkage (furthest neighbor, maximum method, diameter method, rank order typal analysis). To reduce distortion of clusters by outliers, the TRIM= option is recommended.


DENSITY  |  DEN
requests density linkage, which is a class of clustering methods using nonparametric probability density estimation. You must also specify either the K=, R=, or HYBRID option to indicate the type of density estimation to be used. See also the MODE= and DIM= options in this section.


EML
requests maximum-likelihood hierarchical clustering for mixtures of spherical multivariate normal distributions with equal variances but possibly unequal mixing proportions. Use METHOD=EML only with coordinate data. See the PENALTY= option for details. The NONORM option does not affect the reported likelihood values but does affect other unrelated criteria. The EML method is much slower than the other methods in the CLUSTER procedure.


FLEXIBLE  |  FLE
requests the Lance-Williams flexible-beta method. See the BETA= option in this section.


MCQUITTY  |  MCQ
requests McQuitty’s similarity analysis (weighted average linkage, weighted pair-group method using arithmetic averages, WPGMA).


MEDIAN  |  MED
requests Gower’s median method (weighted pair-group method using centroids, WPGMC). Distance data are squared unless you specify the NOSQUARE option.


SINGLE  |  SIN
requests single linkage (nearest neighbor, minimum method, connectedness method, elementary linkage analysis, or dendritic method). To reduce chaining, you can use the TRIM= option with METHOD=SINGLE.


TWOSTAGE  |  TWO
requests two-stage density linkage. You must also specify the K=, R=, or HYBRID option to indicate the type of density estimation to be used. See also the MODE= and DIM= options in this section.


WARD  |  WAR
requests Ward’s minimum-variance method (error sum of squares, trace W). Distance data are squared unless you specify the NOSQUARE option. To reduce distortion by outliers, the TRIM= option is recommended. See the NONORM option.


已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

使用道具

dimxu 在职认证  发表于 2012-4-10 19:34:47 |显示全部楼层 |坛友微信交流群
jason_huo 发表于 2012-4-10 19:16
要看呢具体做什么吧,如果你只关心结果而不是其中的算法,那样就用proc stdize对变量进行标准化,然后用p ...
我主要关心的是如何能构造出距离矩阵 dij = sqrt(2*(1-cij))

然后用proc cluster 或者 proc fastclus进行聚类分析。我对proc cluster的理解很有限,proc stdize没接触过...请问能不能帮忙写个满足我需求的大致过程,让我学习下。

十分感谢。

使用道具

jason_huo 发表于 2012-4-10 19:46:27 |显示全部楼层 |坛友微信交流群
dimxu 发表于 2012-4-10 19:34
我主要关心的是如何能构造出距离矩阵 dij = sqrt(2*(1-cij))

然后用proc cluster 或者 proc fastclus进 ...
问题是:你算出距离矩阵后,想把它变成是cluster的输入吗(proc cluster data=距离矩阵)?

使用道具

dimxu 在职认证  发表于 2012-4-10 19:54:50 |显示全部楼层 |坛友微信交流群
jason_huo 发表于 2012-4-10 19:46
问题是:你算出距离矩阵后,想把它变成是cluster的输入吗(proc cluster data=距离矩阵)?
对的,把距离矩阵输入到proc cluster里面做聚类分析。
最初的数据应该是几个变量,然后每个变量下面有一些观测。

使用道具

jason_huo 发表于 2012-4-11 17:05:02 |显示全部楼层 |坛友微信交流群
dimxu 发表于 2012-4-10 19:54
对的,把距离矩阵输入到proc cluster里面做聚类分析。
最初的数据应该是几个变量,然后每个变量下面有一 ...
何必呢?一般的分群模型的做法不是这么做的,cluster本身会帮你算距离矩阵的,不需要自己另外算

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-3-28 17:58