12
$\begingroup$

This is a mosaic plot of contingency table dataset HairEyeColor described here.

enter image description here

How do I interpret the colors representing residuals? What is the difference between high and positive Pearson's residuals (shown in blue) versus low and negative ones shown in red?

$\endgroup$
1
  • $\begingroup$ Is there a way t change colors following the next criteria: if more than expected is for good, then cells with cases over expected should be colored in green if less than expected is for good, then cells with cases below expected should be colored in green $\endgroup$ – Ovidio Carlos Molina Chapa Nov 21 '20 at 18:19
15
$\begingroup$

The colors represent the level of the residual for that cell / combination of levels. The legend is presented at the plot's right. More specifically, blue means there are more observations in that cell than would be expected under the null model (independence). Red means there are fewer observations than would have been expected. You can read this as showing you which cells are contributing to the significance of the chi-squared test result. For more information, it may help to read the Residual-based Shadings in vcd vignette (pdf) from the vcd package.

$\endgroup$
3
  • 2
    $\begingroup$ In this case the null model (independence) is used but one could also employ other log-linear models for the contingency table. In a well-fitting model, the residuals should be small, i.e., there should be less/no color. More details are explained in Zeileis, Meyer, Hornik (2007). "Residual-Based Shadings for Visualizing (Conditional) Independence." Journal of Computational and Graphical Statistics, 16(3), 507–525 to which the above-mentioned vignette is a companion. A preprint version is also on my web page and referred to in the vignette. $\endgroup$ – Achim Zeileis Apr 23 '15 at 15:33
  • $\begingroup$ @AchimZeileis, I have that paper as well--it's nice. I just thought I'd reference the vignette as the plot was done in R. Feel free to contribute your own (no doubt better...) answer. Welcome to CV, btw. $\endgroup$ – gung - Reinstate Monica Apr 23 '15 at 15:50
  • 1
    $\begingroup$ I think your answer is fine (+1ed it already) and I just wanted to mention the possibility of using other models (beyond simple independence) and the journal paper. The latter because I realized from your link that the journal paper is not mentioned in the vignette (only the working paper version) which I will have to fix for the next release. $\endgroup$ – Achim Zeileis Apr 23 '15 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.