partial_correlation {netassoc} | R Documentation |
Partial correlation coefficients
Description
Estimates the inverse covariance matrix then uses this matrix to calculate partial correlation coefficents.
Assumes that matrix rows correspond to different variables of interest.
The one exception is if method="correlation"
; see below for details.
Usage
partial_correlation(mat, method, verbose=FALSE)
Arguments
mat |
Input matrix. |
method |
One of the following
|
verbose |
Binary flag determining whether diagnostic output is shown. |
Value
Returns a m x m upper triangular matrix of partial correlation coefficients from an input m x n matrix.
Examples
# load highly collinear economic data time series
data(longley)
longley_ss <- t(longley[,c(1:5,7)]) # put data in correct input format
colors <- colorRampPalette(c("red","white","blue"))(10)
pc_shrinkage <- partial_correlation(longley_ss,method="shrinkage")
image(pc_shrinkage,zlim=c(-1,1),col=colors)