title: How do I extract the Correlation of fixed effects part of the lmer output
body: <p>When you have a multilevel model with lots of factors and interactions the size of the correlation of fixed effects matrix can become quite big and unclear.</p>
  
  <p>I can use the <code>symbolic.cor=T</code> parameter in the print method to make a clearer print of the summary like below:</p>
  
  <pre><code>ratbrain &lt;-
  within(read.delim("http://www-personal.umich.edu/~bwest/rat_brain.dat"),
  {
  treatment &lt;- factor(treatment,
  labels = c("Basal", "Carbachol"))
  region &lt;- factor(region,
  labels = c("BST", "LS", "VDB"))
  })
  
  print(mod&lt;-lmer(activate ~ region * treatment + (0 + treatment | animal),ratbrain),symbolic.cor=T)
  </code></pre>
  
  <p>This plots a somewhat clearer correlation matrix for large matrices. Allthough this example's matrix isn't so big. 
  But it would be nice if I could plot a heatmap of the correlations.<br>
  How do I extract the correlation of fixed effects so I can make this heatmap?</p>
  
  <p><strong>EDIT:</strong>  </p>
  
  <p>Here's the function I created thanks to the answers. </p>
  
  <pre><code>fixeff.plotcorr&lt;-function(mod,...)
  {
    #require(GGally) # contains another correlation plot using ggplot2
    require(lme4)
  
    fixNames&lt;-names(fixef(mod))
  
    # Simon O'Hanlon's answer:
    # so &lt;- summary(mod)
    # df&lt;-as.matrix(so@vcov@factors$correlation) for version lme4&lt;1.0
    # df&lt;-as.matrix(so$vcov@factors$correlation)  # lme4 &gt;= 1.0
  
    df&lt;-as.matrix(cov2cor(vcov(mod))) #Ben Bolker's solution
  
    rownames(df)&lt;-fixNames
    colnames(df)&lt;-abbreviate(fixNames, minlength = 11)
  
    colsc=c(rgb(241, 54, 23, maxColorValue=255), 'white', rgb(0, 61, 104, maxColorValue=255))
    colramp = colorRampPalette(colsc, space='Lab')
    colors = colramp(100)
    cols=colors[((df + 1)/2) * 100]
    # I'm using function my.plotcorr which you can download here:
    # http://hlplab.wordpress.com/2012/03/20/correlation-plot-matrices-using-the-ellipse-library/
    my.plotcorr(df, col=cols, diag='none', upper.panel="number", mar=c(0,0.1,0,0),...)
  
    # Another possibility is the corrplot package:
    # cols &lt;- colorRampPalette(c("#67001F", "#B2182B", "#D6604D", "#F4A582", "#FDDBC7", 
    #                              "#FFFFFF", "#D1E5F0", "#92C5DE", "#4393C3", "#2166AC", "#053061"))
    # require(corrplot,quiet=T)
    # corrplot(df, type="upper", method="number", tl.pos='tl', tl.col='black', tl.cex=0.8, cl.pos='n', col=cols(50))
    # corrplot(df,add=TRUE,  method='ellipse', type='lower', tl.pos='n', tl.col='black', cl.pos='n', col=cols(50), diag=FALSE)
  }
  </code></pre>
  
  <p>You have to download the my.plotcorr function from <a href="http://hlplab.wordpress.com/2012/03/20/correlation-plot-matrices-using-the-ellipse-library/" rel="nofollow noreferrer">here</a>.
  The resulting plot of the example above using command <code>fixeff.plotcorr(mod)</code> now looks like this:
  <img src="https://i.stack.imgur.com/UVHas.png" alt="enter image description here"></p>