spcor: Semi-partial (part) correlation

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/ppcor_v1.01.R

Description

The function spcor can calculate the pairwise semi-partial (part) correlations for each pair of variables given others. In addition, it gives us the p value as well as statistic for each pair of variables.

Usage

1
spcor(x, method = c("pearson", "kendall", "spearman"))

Arguments

x

a matrix or data fram.

method

a character string indicating which semi-partial (part) correlation coefficient is to be computed. One of "pearson" (default), "kendall", or "spearman" can be abbreviated.

Details

Semi-partial correlation is the correlation of two variables with variation from a third or more other variables removed only from the second variable. When the determinant of variance-covariance matrix is numerically zero, Moore-Penrose generalized matrix inverse is used. In this case, no p-value and statistic will be provided if the number of variables are greater than or equal to the sample size.

Value

estimate

a matrix of the semi-partial (part) 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

Note

Missing values are not allowed.

Author(s)

Seongho Kim <biostatistician.kim@gmail.com>

References

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.

See Also

spcor.test, pcor, pcor.test

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 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)
			)

# semi-partial (part) correlation
spcor(y.data) 

Example output

Loading required package: MASS
$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"

ppcor documentation built on May 2, 2019, 1:44 p.m.