I'm playing with a ggplot2 based correlation matrix, mostly insipred
by this non-ggplot example:
http://addictedtor.free.fr/graphiques/graphcode.php?graph=137
My version is attached, and I'm pretty happy with it. Panels below the
diagonal contain the data and lm fits, panels above the diagonal
contain a text representation of the correlation estimate, colored
reddish if the correlation p-value is less than .05, blueish if the
correlation p-value is greater than .05, and sized proportional to
r^2.
There's only a few tweaks I'd like to make:
(1) Get rid of the standard facet labels, which are redundant to the
diagonal labels
(2) Let the scales vary freely for each panel. Right now I convert the
measures to z-scores, so at least they're on scales that generally fit
together, but if there are large outliers in one panel it would be
nice for that not to affect the scales of the other panels. setting
"scales='free'" in the facet_grid call simply lets each row to vary &
each column to vary, but with a row, y-scale is fixed and within a
column x-axis is fixed.
It might be nice to somehow make var_text_size & cor_text_limits
automatic, but I doubt this is feasible.
I also had a thought: Maybe it would be more useful to plot the
residuals instead of the raw data?
Any input would be greatly appreciated!
Mike
--
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University
Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar
~ Certainty is folly... I think. ~
This will be possible once I've rewritten the layout system.
> (2) Let the scales vary freely for each panel. Right now I convert the
> measures to z-scores, so at least they're on scales that generally fit
> together, but if there are large outliers in one panel it would be
> nice for that not to affect the scales of the other panels. setting
> "scales='free'" in the facet_grid call simply lets each row to vary &
> each column to vary, but with a row, y-scale is fixed and within a
> column x-axis is fixed.
You might be able to do it with facet_grid if you set up the data in
the right way.
> It might be nice to somehow make var_text_size & cor_text_limits
> automatic, but I doubt this is feasible.
>
> I also had a thought: Maybe it would be more useful to plot the
> residuals instead of the raw data?
>
> Any input would be greatly appreciated!
Thanks again for your contribution!
Hadley
Indeed! In fact, the "right way" appears to be the way I set it up in
the first place, I don't know why I raised this. Maybe I simply failed
to try "scales='free'", because it turns out that the standard "let
the x axis vary across columns and let the y axis vary across rows" is
what is necessary for this matrix.
Anyway, attached is the version employing "scales='free'". Since this
makes the z-score approach unnecessary, I removed that step and added
bits that figure out where to put the text so that they're dead center
in the boxes.
All that's left is getting rid of those superfluous panel labels after
Hadley's layout update.