相似性 similarity | Pearson | Spearman | p-value | 相关性 correlation | 距离 distance | distance measure
这几个概念不能混淆,估计大部分人都没有完全搞懂这几个概念。
看下这个,非常有用:Interpret the key results for Correlation
euclidean | maximum | manhattan | canberra | binary | minkowski
初级
先演示一下相关性:
a <- c(1,2,3,4)
b <- c(2,4,6,8)
c <- data.frame(x=a,y=b)
plot(c)
cor(t(c))

> cor(t(c))
[,1] [,2] [,3] [,4]
[1,] 1 1 1 1
[2,] 1 1 1 1
[3,] 1 1 1 1
[4,] 1 1 1 1
初步结论:
1. 相关性是用来度量两个变量之间的线性关系的;
2. 如果在不同的sample中,x随着y的增大而增大,那么x和y就是正相关,反之则是负相关;
接下来求距离:
> dist(c, method = "euclidean")
1 2 3
2 2.236068
3 4.472136 2.236068
4 6.708204 4.472136 2.236068
> sqrt(2^2+1^2)
[1] 2.236068
初步结论:
1. 距离是在特定的坐标体系中,两点之间的距离求解;
2. 距离可以用来表征相似度,比如1和2就比1和4更相似;
3. 欧氏距离就是我们最常见的几何距离,比较直观;
那么什么时候求相关性,什么时候求相似度呢?
基因表达当然要求相关性了,共表达都是在求相关性,就是基因A和B会在不同样本间同增同减,所以相关性是对变量而言的,暂时还没听说对样品求相关性,没有意义,总不能说在这些基因中,某些样本的表达同增同减吧。
那么样本最常见的应该是求相似度了,我想知道样本A是和样本B更相似,还是和样本C更相似,在共同的基因坐标下求个距离就知道了。
进阶
1. 不同的求相关性的方法有何差异?
2. 不同的距离计算的方法有何差异?
3. 相关性分析有哪些局限性?
简单介绍一下pearson和spearman的区别
x=(1:100)
y=exp(x)
cor(x,y,method = "pearson") # 0.25
cor(x,y,method = "spearman") # 1
plot(x,y)

结论:
pearson判断的是线性相关性,
而spearman还可以判断非线性的。monotonic relationship,更专业的说是单调性。
参考:Correlation (Pearson, Kendall, Spearman)
outlier对相关性的影响

x = 1:100
y = 1:100
cor(x,y,method = "pearson") # 1
y[100] <- 1000
cor(x,y,method = "pearson") # 0.448793
cor(x,y,method = "spearman") # 1 y[99] <- 0
cor(x,y,method = "spearman") # 0.9417822

结论:
单个的outlier对pearson的影响非常大,但是对spearman的影响则比较小。
皮尔逊相关系数 其实是衡量 两个变量线性相关程度大小的指标,但它的值的大小并不能完全地反映两个变量的真实关系。
只有当两个变量的标准差都不为零,相关系数才有意义。
Pearson, Kendall, Spearman三种相关性的差异
distance measure
euclidean | maximum | manhattan | canberra | binary | minkowski
k-NN 4: which distance function?
distance measure euclidean
euclidean:
Usual distance between the two vectors (2 norm aka L_2), sqrt(sum((x_i - y_i)^2)).
maximum:
Maximum distance between two components of x and y (supremum norm)
manhattan:
Absolute distance between the two vectors (1 norm aka L_1).
canberra:
sum(|x_i - y_i| / (|x_i| + |y_i|)). Terms with zero numerator and denominator are omitted from the sum and treated as if the values were missing.
This is intended for non-negative values (e.g., counts), in which case the denominator can be written in various equivalent ways; Originally, R used x_i + y_i, then from 1998 to 2017, |x_i + y_i|, and then the correct |x_i| + |y_i|.
binary:
(aka asymmetric binary): The vectors are regarded as binary bits, so non-zero elements are ‘on’ and zero elements are ‘off’. The distance is the proportion of bits in which only one is on amongst those in which at least one is on.
minkowski:
The p norm, the pth root of the sum of the pth powers of the differences of the components.

待续~
相似性 similarity | Pearson | Spearman | p-value | 相关性 correlation | 距离 distance | distance measure的更多相关文章
- 三大相关系数: pearson, spearman, kendall(python示例实现)
三大相关系数:pearson, spearman, kendall 统计学中的三大相关性系数:pearson, spearman, kendall,他们反应的都是两个变量之间变化趋势的方向以及程度,其 ...
- Kendall’s tau-b,pearson、spearman三种相关性的区别(有空整理信息检索评价指标)
同样可参考: http://blog.csdn.net/wsywl/article/details/5889419 http://wenku.baidu.com/link?url=pEBtVQFzTx ...
- 相关性分析 -pearson spearman kendall相关系数
先说独立与相关的关系:对于两个随机变量,独立一定不相关,不相关不一定独立.有这么一种直观的解释(不一定非常准确):独立代表两个随机变量之间没有任何关系,而相关仅仅是指二者之间没有线性关系,所以不难推出 ...
- 【转】Pearson,Spearman,Kendall相关系数的具体分析
测量相关程度的相关系数很多,各种参数的计算方法及特点各异. 连续变量的相关指标: 此时一般用积差相关系数,又称pearson相关系数来表示其相关性的大小,积差相关系数只适用于两变量呈线性相关时.其数值 ...
- 统计学三大相关性系数:pearson,spearman,kendall
目录 person correlation coefficient(皮尔森相关性系数-r) spearman correlation coefficient(斯皮尔曼相关性系数-p) kendall ...
- Jaccard similarity(杰卡德相似度)和Abundance correlation(丰度相关性)
杰卡德距离(Jaccard Distance) 是用来衡量两个集合差异性的一种指标,它是杰卡德相似系数的补集,被定义为1减去Jaccard相似系数.而杰卡德相似系数(Jaccard similarit ...
- 【概率论】4-6:协方差和相关性(Covariance and Correlation)
title: [概率论]4-6:协方差和相关性(Covariance and Correlation) categories: - Mathematic - Probability keywords: ...
- 相似性度量(Similarity Measurement)与“距离”(Distance)
在做分类时常常需要估算不同样本之间的相似性度量(Similarity Measurement),这时通常采用的方法就是计算样本间的“距离”(Distance).采用什么样的方法计算距离是很讲究,甚至关 ...
- 机器学习中的相似性度量(Similarity Measurement)
机器学习中的相似性度量(Similarity Measurement) 在做分类时常常需要估算不同样本之间的相似性度量(Similarity Measurement),这时通常采用的方法就是计算样本间 ...
随机推荐
- Intro to Mongoid
Mongoid: object-document-mapper(ODM) Mongoid Configuration: rails g mongoid:config Document: Documen ...
- (备忘)怎么去除WinRAR弹窗广告?
1.在WinRAR的安装目录下新建一个记事本,命名为“rarreg.key”. 2.打开记事本,将一下内容复制进去. RAR registration data Federal Agency for ...
- Mac开发工具汇总
1: Json Parser Mac版 http://www.pc6.com/mac/180470.html
- 【Java】NO.120.JDK.1.JDK8.1.001-【Java8实战】
Style:Mac Series:Java Since:2018-09-26 End:2018-09-26 Total Hours:1 Degree Of Diffculty:5 Degree Of ...
- NIO学习资料
五大IO模型 https://jiges.github.io/2018/02/07/%E4%BA%94%E5%A4%A7IO%E6%A8%A1%E5%9E%8B/ Getting started wi ...
- CentOS 7静默安装Oracle 11g R2数据库软件
之前安装Oracle 11g R2数据库软件都是建立在图形界面上的,不过现在大部分服务器上都没有安装图形界面.图形界面安装较为方便,安装选项清晰,步骤明确,但Oracle还支持另一种安装方式,就是通过 ...
- 【2】Kali之情报搜集技术
渗透测试中情报搜集需要完成两项重要任务: 1.通过信息搜集工作,确定渗透测试目标范围. 2.通过情报信息搜集,发现渗透测试目标的安全漏洞与脆弱点,为后续的渗透攻击提供基础. 通过DNS和IP地址挖掘目 ...
- Future 示例
public static Object send(RequestClient request) future.channel().writeAndFlush(JSONObject.toJSONStr ...
- oracle group by placement可能导致错误结果的bug
Last week I’ve mentioned on Twitter that we ran into wrong result bug. We found workaround quickly b ...
- 【题解】Luogu P2763 试题库问题
原题传送门 这题很简单啊 从源点向k类题目分别连流量为所需数量的边 从每道题向汇点连一条流量为1的边(每题只能用1次) 从类型向对应的题目连一条流量为1的边 跑一遍最大流 如果最大流小于所需题目数量, ...