gpt4 book ai didi

r - R 中的偏相关

转载 作者:行者123 更新时间:2023-12-02 04:55:56 25 4
gpt4 key购买 nike

我正在尝试计算 R 中的部分相关性。我有两个要比较的数据集,目前只有一个受控变量。 (将来这会改变)

我在网上尝试自己解决这个问题,但很难理解我所查看的网站上使用的术语。有人可以解释一下我将如何做到这一点并也许提供一个简单的例子吗?

数据采用以下形式:

                Project.Name Bugs.Project Changes.Project Orgs.Project
1 platform_external_svox 4 161 2
3 platform_packages_apps_Nfc 13 223 2
5 platform_system_media 36 307 2
7 platform_external_mtpd 2 30 2
9 platform_bionic 42 1061 4

我希望 Bugs.Project 和 Orgs.Project 之间的相关性与 Changes.Project 作为受控变量。我已经下载了ppcor库,因为它看起来具有我需要的功能。但是,我不确定如何使用它。如何将数据添加到矩阵并使用 pcor功能?

这是我一直在尝试的:

y.data <- data.frame(
bpp=c(projRelateBugsOrgs[2]),
opp=c(projRelateBugsOrgs[4]),
cpp=c(projRelateBugsOrgs[3])
)

test <- pcor(y.data)

我只是使用了我找到的一个示例,并尝试使用我的数据来代替他们的数据。我不明白我的输出。

看起来像这样:

$estimate
Bugs.Project Orgs.Project Changes.Project
Bugs.Project 1.0000000 0.3935535 0.9749296
Orgs.Project 0.3935535 1.0000000 -0.1800788
Changes.Project 0.9749296 -0.1800788 1.0000000

$p.value
Bugs.Project Orgs.Project Changes.Project
Bugs.Project 0.00000e+00 2.09795e-07 0.0000000
Orgs.Project 2.09795e-07 0.00000e+00 0.0264442
Changes.Project 0.00000e+00 2.64442e-02 0.0000000

$statistic
Bugs.Project Orgs.Project Changes.Project
Bugs.Project 0.000000 5.190442 53.122165
Orgs.Project 5.190442 0.000000 -2.219625
Changes.Project 53.122165 -2.219625 0.000000

$n
[1] 150

$gp
[1] 1

$method
[1] "pearson"

我想我想要从 $estimate 表中得到一些东西,但我不太确定它给了我什么,

最佳答案

从值部分的 help('pcor') 读取

Value

estimate a matrix of the partial correlation coefficient between two variables

p.value a matrix of the p value of the test

statistic a matrix of the value of the test statistic

n the number of samples

gn the number of given variables

method the correlation method used

详细信息部分给出

Details

Partial correlation is the correlation of two variables while controlling for a third or more other variables.

为了你的结果

$estimate
Bugs.Project Orgs.Project Changes.Project
Bugs.Project 1.0000000 0.3935535 0.9749296
Orgs.Project 0.3935535 1.0000000 -0.1800788
Changes.Project 0.9749296 -0.1800788 1.0000000

Changes.ProjectOrgs.Project 的部分相关性为 -0.1800788。这是 Changes.ProjectOrgs.Project 控制 Bugs.Project

的相关性

Changes.ProjectBugs.Project 的部分相关性为 0.9747296。这是 Changes.ProjectBugs.Project 控制 Orgs.Project

的相关性

Orgs.ProjectBugs.Project 的部分相关性为 0.3935535。这是 Orgs.ProjectBugs.Project 控制 Changes.Project

的相关性

您可以从

获得相同的信息(如果您只对第三种情况感兴趣)
pcor.test(y.data$Orgs.Project, y.data$Bugs.Project, y.data$Changes.Project)

关于r - R 中的偏相关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14250792/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com