Description Details Author(s) References Examples
Calculates parital and semi-partial (part) correlations along with p value.
Package: | ppcor |
Type: | Package |
Version: | 1.0 |
Date: | 2011-06-14 |
License: | GPL-2 |
Seongho Kim <biostatistician.kim@gmail.com>
Kim, S. (2015) ppcor: An R Package for a Fast Calculation to Semi-partial Correlation Coefficients. Communications for Statistical Applications and Methods, 22(6), 665-674.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # data
y.data <- data.frame(
hl=c(7,15,19,15,21,22,57,15,20,18),
disp=c(0.000,0.964,0.000,0.000,0.921,0.000,0.000,1.006,0.000,1.011),
deg=c(9,2,3,4,1,3,1,3,6,1),
BC=c(1.78e-02,1.05e-06,1.37e-05,7.18e-03,0.00e+00,0.00e+00,0.00e+00
,4.48e-03,2.10e-06,0.00e+00)
)
# partial correlation
pcor(y.data)
# partial correlation between "hl" and "disp" given "deg" and "BC"
pcor.test(y.data$hl,y.data$disp,y.data[,c("deg","BC")])
pcor.test(y.data[,1],y.data[,2],y.data[,c(3:4)])
pcor.test(y.data[,1],y.data[,2],y.data[,-c(1:2)])
# semi-partial (part) correlation
spcor(y.data)
# semi-partial (part) correlation between "hl" and "disp" given "deg" and "BC"
spcor.test(y.data$hl,y.data$disp,y.data[,c("deg","BC")])
spcor.test(y.data[,1],y.data[,2],y.data[,c(3:4)])
spcor.test(y.data[,1],y.data[,2],y.data[,-c(1:2)])
|
Loading required package: MASS
$estimate
hl disp deg BC
hl 1.0000000 -0.6720863 -0.6161163 0.1148459
disp -0.6720863 1.0000000 -0.7215522 0.2855420
deg -0.6161163 -0.7215522 1.0000000 0.6940953
BC 0.1148459 0.2855420 0.6940953 1.0000000
$p.value
hl disp deg BC
hl 0.00000000 0.06789202 0.10383620 0.78654997
disp 0.06789202 0.00000000 0.04332869 0.49299871
deg 0.10383620 0.04332869 0.00000000 0.05615021
BC 0.78654997 0.49299871 0.05615021 0.00000000
$statistic
hl disp deg BC
hl 0.0000000 -2.2232666 -1.916030 0.2831875
disp -2.2232666 0.0000000 -2.552768 0.7298173
deg -1.9160295 -2.5527682 0.000000 2.3617433
BC 0.2831875 0.7298173 2.361743 0.0000000
$n
[1] 10
$gp
[1] 2
$method
[1] "pearson"
estimate p.value statistic n gp Method
1 -0.6720863 0.06789202 -2.223267 10 2 pearson
estimate p.value statistic n gp Method
1 -0.6720863 0.06789202 -2.223267 10 2 pearson
estimate p.value statistic n gp Method
1 -0.6720863 0.06789202 -2.223267 10 2 pearson
$estimate
hl disp deg BC
hl 1.0000000 -0.5791734 -0.4991364 0.07377194
disp -0.5505041 1.0000000 -0.6320921 0.18071040
deg -0.3180603 -0.4237587 1.0000000 0.39204867
BC 0.0669124 0.1724434 0.5580398 1.00000000
$p.value
hl disp deg BC
hl 0.0000000 0.1324601 0.2079431 0.8621787
disp 0.1573861 0.0000000 0.0926718 0.6684724
deg 0.4426360 0.2954469 0.0000000 0.3367589
BC 0.8749132 0.6830213 0.1506047 0.0000000
$statistic
hl disp deg BC
hl 0.0000000 -1.7402746 -1.410960 0.1811974
disp -1.6152392 0.0000000 -1.998086 0.4500579
deg -0.8217590 -1.1459717 0.000000 1.0438882
BC 0.1642694 0.4288224 1.647252 0.0000000
$n
[1] 10
$gp
[1] 2
$method
[1] "pearson"
estimate p.value statistic n gp Method
1 -0.5791734 0.1324601 -1.740275 10 2 pearson
estimate p.value statistic n gp Method
1 -0.5791734 0.1324601 -1.740275 10 2 pearson
estimate p.value statistic n gp Method
1 -0.5791734 0.1324601 -1.740275 10 2 pearson
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.