partial.r: Find the partial correlations for a set (x) of variables with...

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

Description

A straightforward application of matrix algebra to remove the effect of the variables in the y set from the x set. Input may be either a data matrix or a correlation matrix. Variables in x and y are specified by location. If x and y are not specified, then the effect of all variables are partialled from all the other correlations.

Usage

1
partial.r(data, x, y,use="pairwise",method="pearson")

Arguments

data

A data or correlation matrix

x

The variable names or locations associated with the X set.

y

The variable names or locations associated with the Y set

use

How should we treat missing data? The default is pairwise complete.

method

Which method of correlation should we use, the default is pearson.

Details

There are two ways to use partial.r. One is to find the complete partial correlation matrix (that is, partial all the other variables out of each variable). This may be done by simply specify the raw data or correlation matrix. (In the case of raw data, correlations will be found according to use and method.) In this case, just specify the data matrix. .

The second usage is to partial a set of variables(y) out of another set (x). It is sometimes convenient to partial the effect of a number of variables (e.g., sex, age, education) out of the correlations of another set of variables. This could be done laboriously by finding the residuals of various multiple correlations, and then correlating these residuals. The matrix algebra alternative is to do it directly. To find the confidence intervals and "significance" of the correlations, use the corr.p function with n = n - s where s is the numer of covariates.

Value

The matrix of partial correlations.

Author(s)

William Revelle

References

Revelle, W. (in prep) An introduction to psychometric theory with applications in R. To be published by Springer. (working draft available at http://personality-project.org/r/book/

See Also

setCor for a similar application for regression. lowerMat to neatly show a correlation matrix, and corr.p to find the confidence intervals of a correlation.

Examples

1
2
3
4
5
6
7
8
jen <- make.hierarchical()    #make up a correlation matrix 
lowerMat(jen[1:5,1:5])
par.r <- partial.r(jen,c(1,3,5),c(2,4))
lowerMat(par.r)
cp <- corr.p(par.r,n=98)  #assumes the jen data based upon n =100.
print(cp,short=FALSE)  #show the confidence intervals as well
 #partial all from all correlations.
lowerMat(partial.r(jen)) 

psych documentation built on Sept. 9, 2017, 5:05 p.m.