Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Visualizing Independence Using Association Plots

    Dear Stata users,
    I am looking for a command in Stata to draw association plots, as introduced by Cohen (1980) and extended by Meyer, Zeileis, and Hornik (e.g., in the R package vcd). These plots visualize the residuals from a chi-squared test of independence in a two-way contingency table. Each cell is represented by a rectangle whose height is proportional to the (signed) Pearson residual and width to the square root of the expected count, so the area reflects the raw residual. Color shading is often used to highlight residuals exceeding certain thresholds (e.g., |r| > 2).
    These plots are useful for identifying which cells drive a significant chi-squared statistic and for exploring patterns of deviation from independence.
    Does Stata have a native or user-written command that can produce such plots? Any pointers would be greatly appreciated.
    Best regards
    Attached Files

  • #2
    I am not aware of any implementation. It's programmable in Stata but a quick guess is that you would need to loop over bars with different widths inside the code.

    It's a clever idea: coding width and height of bars and colour of bar so that three (or four!) variables are shown directly or indirectly. Speaking for myself only, the design is more complicated than I've wanted to try to support.

    Comment


    • #3
      Dear Nick Cox Thank you for your thoughtful and constructive comments. You are right that the implementation in Stata would require looping over bars with different widths and carefully managing colors — which is indeed more involved than a typical twoway graph. What I find interesting is that the idea itself is not new: it goes back to Cohen (1980) and was later formalized in the extended association plot framework by Meyer, Zeileis, and Hornik. Their work shows how the design can be made robust and interpretable, especially through color shading of residuals.

      Comment

      Working...
      X