这几个概念不能混淆,估计大部分人都没有完全搞懂这几个概念。

看下这个,非常有用: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的更多相关文章

  1. 三大相关系数: pearson, spearman, kendall(python示例实现)

    三大相关系数:pearson, spearman, kendall 统计学中的三大相关性系数:pearson, spearman, kendall,他们反应的都是两个变量之间变化趋势的方向以及程度,其 ...

  2. Kendall’s tau-b,pearson、spearman三种相关性的区别(有空整理信息检索评价指标)

    同样可参考: http://blog.csdn.net/wsywl/article/details/5889419 http://wenku.baidu.com/link?url=pEBtVQFzTx ...

  3. 相关性分析 -pearson spearman kendall相关系数

    先说独立与相关的关系:对于两个随机变量,独立一定不相关,不相关不一定独立.有这么一种直观的解释(不一定非常准确):独立代表两个随机变量之间没有任何关系,而相关仅仅是指二者之间没有线性关系,所以不难推出 ...

  4. 【转】Pearson,Spearman,Kendall相关系数的具体分析

    测量相关程度的相关系数很多,各种参数的计算方法及特点各异. 连续变量的相关指标: 此时一般用积差相关系数,又称pearson相关系数来表示其相关性的大小,积差相关系数只适用于两变量呈线性相关时.其数值 ...

  5. 统计学三大相关性系数:pearson,spearman,kendall

    目录 person correlation coefficient(皮尔森相关性系数-r) spearman correlation coefficient(斯皮尔曼相关性系数-p) kendall ...

  6. Jaccard similarity(杰卡德相似度)和Abundance correlation(丰度相关性)

    杰卡德距离(Jaccard Distance) 是用来衡量两个集合差异性的一种指标,它是杰卡德相似系数的补集,被定义为1减去Jaccard相似系数.而杰卡德相似系数(Jaccard similarit ...

  7. 【概率论】4-6:协方差和相关性(Covariance and Correlation)

    title: [概率论]4-6:协方差和相关性(Covariance and Correlation) categories: - Mathematic - Probability keywords: ...

  8. 相似性度量(Similarity Measurement)与“距离”(Distance)

    在做分类时常常需要估算不同样本之间的相似性度量(Similarity Measurement),这时通常采用的方法就是计算样本间的“距离”(Distance).采用什么样的方法计算距离是很讲究,甚至关 ...

  9. 机器学习中的相似性度量(Similarity Measurement)

    机器学习中的相似性度量(Similarity Measurement) 在做分类时常常需要估算不同样本之间的相似性度量(Similarity Measurement),这时通常采用的方法就是计算样本间 ...

随机推荐

  1. 线程同步-使用SimaphoreSlim类

    SimaphoreSlim类是作为Semaphore类的轻量级版本的.该类限制了同时访问同一个资源的线程数量. 代码Demo: using System;using System.Threading; ...

  2. 实时分析(在线查询),firehose---clickhouse

    firehose---clickhouse 在Hive中适不适合像传统数据仓库一样利用维度建模hive新功能 Cube, Rollup介绍https://blog.csdn.net/moon_yang ...

  3. Ecplise通过Git将项目提交到GitHub

    一.参考https://blog.csdn.net/bendanany/article/details/78891804 二.注意点: 1.仓库名必须和项目名相同: 2.若提交出现Can't conn ...

  4. 6、Flutter Error waiting for a debug connection: ProcessException: adb did not report f(转)

    1.错误信息 Error waiting for a debug connection: ProcessException: adb did not report forwarded port 2.解 ...

  5. 3、Finished with error: FormatException: Bad UTF-8 encoding 0xc3 (at offset 169)

    这是由于 app 的版本为 release 找不到 keystore 文件, 我们只需要在 app 下的 build.gradle 文件中修改为 signingConfigs.debug 即可: bu ...

  6. bugfree3.0.1-修改“优先级”“严重等级”为中文

    1.进入目录C:\xampp\htdocs\bugfree\protected\models 2.打开文件 Info.php

  7. python_字符串的格式化输出

    name = input("Name:")age = int(input("Age:")) input: 输入的内容默认为字符串格式job = input(&q ...

  8. python常用函数及模块

    原文来源于博客园和CSDN 1.计算函数 abs()--取绝对值 max()--取序列最大值,包括列表.元组 min()--取序列最小值 len()--取长度 divmod(a,b)---取a//b除 ...

  9. 从Joda-Time反观Java语言利弊

    基本上每个企业应用系统都涉及到时间处理.我们知道,以前用java原生的Date+Calendar非常的不方便.后来Joda-Time诞生,这个专门处理日期/时间的库提供了DateTime类型,用它可以 ...

  10. 55.Vue环境搭建

    Vue环境搭建 在搭建过程中出现的错误解决办法  https://www.cnblogs.com/lovebing/p/9488198.html      cross-env使用笔记   cross- ...