R中阈值的相关计算
我想计算 R 中的相关性。但是我有很多缺失值。因此,我想在相关矩阵中只承认根据至少 10 对值计算得出的相关性。 如何进行?
编辑: 请注意,相关矩阵是由具有相同个体(行)的两个大矩阵 X 和 Y 生成的。
I would like to compute correlations in R. However I have a lot of missing values. So, I would like to admit in the correlations matrix only correlations that were calculated from at least 10 pairs of values.
How to proceed?
Edit:
please note that correlation matrix is generated from two big matrices X and Y having same individuals (rows).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我们生成一些示例数据:
接下来,我们循环遍历
x
矩阵进行比较以检测 NA:矩阵
m
现在包含每个列对的比较次数。现在转换m
矩阵以准备子集化:接下来我们根据
m
计算所有列对和子集的相关性:First we generate some example data:
Next we loop through the
x
matrix doing a comparsion to detect NA's:The matrix
m
now contains the number of comparison for each column pair. Now convert them
matrix in preparation of subsetting:Next we work out the correlation for all column pairs and subset according to
m
: