Title: | Partial and Semi-Partial (Part) Correlation |
---|---|
Description: | Calculates partial and semi-partial (part) correlations along with p-value. |
Authors: | Seongho Kim |
Maintainer: | Seongho Kim <[email protected]> |
License: | GPL-2 |
Version: | 1.1 |
Built: | 2024-12-04 07:09:31 UTC |
Source: | CRAN |
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 <[email protected]>
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.
# 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)])
# 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)])
The function pcor
can calculate the pairwise partial 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.
pcor(x, method = c("pearson", "kendall", "spearman"))
pcor(x, method = c("pearson", "kendall", "spearman"))
x |
a matrix or data fram. |
method |
a character string indicating which partial correlation coefficient is to be computed. One of "pearson" (default), "kendall", or "spearman" can be abbreviated. |
Partial correlation is the correlation of two variables while controlling for a third or more other variables. 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.
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 |
Missing values are not allowed.
Seongho Kim <[email protected]>
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.
# 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)
# 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)
The function pcor.test
can calculate the pairwise partial correlations between two variables. In addition, it gives us the p value as well as statistic.
pcor.test(x, y, z, method = c("pearson", "kendall", "spearman"))
pcor.test(x, y, z, method = c("pearson", "kendall", "spearman"))
x |
a numeric vector. |
y |
a numeric vector. |
z |
a numeric vector. |
method |
a character string indicating which partial correlation coefficient is to be computed. One of "pearson" (default), "kendall", or "spearman" can be abbreviated. |
Partial correlation is the correlation of two variables while controlling for a third 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.
estimate |
the partial correlation coefficient between two variables |
p.value |
the p value of the test |
statistic |
the value of the test statistic |
n |
the number of samples |
gn |
the number of given variables |
method |
the correlation method used |
Missing values are not allowed
Seongho Kim <[email protected]>
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.
# 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 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)])
# 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 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)])
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.
spcor(x, method = c("pearson", "kendall", "spearman"))
spcor(x, method = c("pearson", "kendall", "spearman"))
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. |
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.
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 |
Missing values are not allowed.
Seongho Kim <[email protected]>
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.
# 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)
# 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)
The function spcor.test
can calculate the pairwise semi-partial (part) correlations between two variables. In addition, it gives us the p value as well as statistic.
spcor.test(x, y, z, method = c("pearson", "kendall", "spearman"))
spcor.test(x, y, z, method = c("pearson", "kendall", "spearman"))
x |
a numeric vector. |
y |
a numeric vector. |
z |
a numeric vector. |
method |
a character string indicating which partial correlation coefficient is to be computed. One of "pearson" (default), "kendall", or "spearman" can be abbreviated. |
Semi-partial correlation is the correlation of two variables with variation from a third variable 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.
estimate |
the semi-partial (part) correlation coefficient between two variables |
p.value |
the p value of the test |
statistic |
the value of the test statistic |
n |
the number of samples |
gn |
the number of given variables |
method |
the correlation method used |
Missing values are not allowed
Seongho Kim <[email protected]>
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.
# 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 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)])
# 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 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)])