I would like to draw a correlation matrix graph, similar to what is output with corrplot
.
However, I estimated my correlation matrix using a multivariate mixed model with MCMCglmm
(because I wanted to account for a few fixed effects and some missing data points) so I would like to be able to input my own correlation matrix estimates (and associated confidence intervals) for corrplot
to use. As far as I can tell, corrplot
estimates the correlation matrix for you from your data - which I do not want it to do.
As an alternative to corrplot
, I know I can build a correlation heatmap using ggplot
and geom_tile
. But I really like the 'ellipse' option that comes with corrplot
.
library(reshape2)
library(corrplot)
library(ggplot2)
#my correlation matrix looks something like this
car.cor <- cor(mtcars)
melted_cormat <- melt(car.cor)
melted_cormat$upper <- melted_cormat$value+0.10
melted_cormat$lower <- melted_cormat$value-0.10
# with corrplot
car.cor <- cor(mtcars)
corrplot.mixed(car.cor, upper = "ellipse")
# with ggplot and geom_tile
ggplot(data = melted_cormat, aes(x=Var1, y=Var2, fill=value)) +
geom_tile()
So my questions are - how can I input my own correlation matrix for corrplot
to use, or alternatively, how can I get the nice little ellipses using ggplot
?