View source: R/partial_correlation.R
partial_correlation | R Documentation |
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.
partial_correlation(mat, method, verbose=FALSE)
mat |
Input matrix. |
method |
One of the following
|
verbose |
Binary flag determining whether diagnostic output is shown. |
Returns a m x m upper triangular matrix of partial correlation coefficients from an input m x n matrix.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.