Partial correlation between two variables given a correlation matrix {corrfuns} | R Documentation |
Partial correlation between two variables when a correlation matrix is given
Description
Partial correlation between two variables when a correlation matrix is given.
Usage
partialcor(R, indx, indy, indz, n)
Arguments
R |
A correlation matrix. |
indx |
The index of the first variable whose conditional correlation is to estimated. |
indy |
The index of the second variable whose conditional correlation is to estimated. |
indz |
The index of the conditioning variables. |
n |
The sample size of the data from which the correlation matrix was computed. |
Details
Suppose you want to calculate the correlation coefficient between two variables controlling for the effect of (or conditioning on) one or more other variables. So you cant to calculate , where
is a matrix, since it does not have to be just one variable. Using the correlation matrix
we can do the following:
The is the correlation between variables
and
,
and
denote the correlations between
&
and
&
,
, with
denoting the correlation sub-matrix of variables
and
denotes the element in the
-th row and
-th column of matrix
. The
denotes the cardinality of
, i.e. the number of variables.
Value
The partial correlation coefficient and the p-value for the test of zero partial correlation.
Author(s)
Michail Tsagris
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.
See Also
Examples
r <- cor(iris[, 1:4])
partialcor(r, 1, 2, 3:4, 150)