cor.plot {psych} | R Documentation |
Correlation matrices may be shown graphically by using the image function to emphasize structure. This is a particularly useful tool for showing the structure of correlation matrices with a clear structure. Partially meant for the pedagogical value of the graphic for teaching or discussing factor analysis and other multivariate techniques.
cor.plot(r,colors=TRUE, n=51,main=NULL,zlim=c(-1,1),show.legend=TRUE,labels=NULL,n.legend=10,...)
r |
A correlation matrix or the output of |
colors |
Defaults to TRUE and colors use colors from the colorRampPalette from red through white to blue, but colors=FALSE will use a grey scale |
n |
The number of levels of shading to use. Defaults to 51 |
main |
A title. Defaults to "correlation plot" |
zlim |
The range of values to color – defaults to -1 to 1 |
show.legend |
A legend (key) to the colors is shown on the right hand side |
labels |
if NULL, use column and row names, otherwise use labels |
n.legend |
How many categories should be labelled in the legend? |
... |
Other parameters for axis (e.g., cex.axis to change the font size) |
When summarizing the correlations of large data bases or when teaching about factor analysis or cluster analysis, it is useful to graphically display the structure of correlation matrices. This is a simple graphical display using the image function.
The difference of mat.plot with a regular image plot is that the primary diagonal goes from the top left to the lower right. -1 to 1 and the color choice is more reasonable. Setting it as c(0,1) will lead to negative correlations treated as zero. This is advantageous when showing general factor structures, because it makes the 0 white.
The default shows a legend for the color coding on the right hand side of the figure.
Inspired, in part, by a paper by S. Dray (2008) on the number of components problem.
Modified following suggestions by David Condon and Josh Wilt to use a more meaningful color choice ranging from dark red (-1) through white (0) to dark blue (1).
William Revelle
Dray, Stephane (2008) On the number of principal components: A test of dimensionality based on measurements of similarity between matrices. Computational Statistics \& Data Analysis. 52, 4, 2228-2237.
cor.plot(Thurstone,main="9 cognitive variables from Thurstone") #just blue implies positive manifold cor.plot(Thurstone, zlim=c(0,1),main="9 cognitive variables from Thurstone") cor.plot(mat.sort(Thurstone),TRUE,zlim=c(0,1), main="9 cognitive variables from Thurstone (sorted by factor loading) ") simp <- sim.circ(24) cor.plot(cor(simp),main="24 variables in a circumplex")