Announcement

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

  • Ordinal variables

    Hi, I have two ordinal variables. The first takes values from a 3-point scale, the second from a 4-point scale. What is the best way to visualize their relationship?

    I have tried:

    histogram var1, by(var2, col(1)) discrete frequency
    but the graph doesn't seem like a good way to analyze the relationship. Can I plot the mean for one variable over the other?


  • #2
    I personally appreciate the spineplot command contributed to SSC by Nick Cox who however I think favors other graphical commands he has developed.
    Code:
    ssc describe spineplot
    ssc install spineplot
    Here are two examples of spinelplot.
    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . spineplot foreign rep78
    
    . spineplot rep78 foreign
    Click image for larger version

Name:	spineplot.png
Views:	1
Size:	76.1 KB
ID:	1662881

    Click image for larger version

Name:	spineplot2.png
Views:	1
Size:	72.6 KB
ID:	1662882
    Last edited by William Lisowski; 03 May 2022, 17:15.

    Comment


    • #3
      Thanks to William Lisowski for the mention of spineplot --which isbest cited as published through the Stata Journal

      SJ-16-2 gr0031_1 . . . . . . . . . . . . . . . Software update for spineplot
      (help spineplot if installed) . . . . . . . . . . . . . . . N. J. Cox
      Q2/16 SJ 16(2):521--522
      x-axis labels have been improved; references added to help file

      SJ-8-1 gr0031 . . . . . . . . . . . Speaking Stata: Spineplots and their kin
      (help spineplot if installed) . . . . . . . . . . . . . . . N. J. Cox
      Q1/08 SJ 8(1):105--121
      discusses spineplots (mosaic plots), a type of bar chart for
      showing frequencies, proportions, or percentages of cross-
      classified categorical variables

      On occasion spineplot can be exactly right for showing structure in a two-way contingency table, although it is best to put the outcome or response variable -- if there is one -- on the y axis and to arrange a graded series of colours. My thinking is that repair record is possibly a response to (is influenced by) being foreign but not conversely.

      My reservations about spineplot are partly technical and partly a matter of taste. It can be hard work seeing structure if

      1. There are cells with zero or small frequencies.

      2. There are problems showing text labels legibly or agreeably. See examples at https://medium.com/the-stata-guide/s...s-49caa27c5554

      Beyond that. mosaic plots (including much more complicated variants for three-way tables and higher) have been promoted energetically by some authors with examples that seem to me often very confusing to try to understand.
      The principle that all the information is encoded in the plot is admirable but does not stop some results being hard to fathom.

      I tend to recommend

      R1. tabplot from the Stata Journal

      R2. floatplot from SSC

      The command names are search terms for mentions of either command on Statalist: tabplot often and floatplot only a few times.

      R3. quantile or (empirical) (cumulative) distribution function plots, as supported by qplot and distplot (both Stata Journal) using cumulative probabilities in the form

      proportion less than this PLUS (1/2) proportion equal to this (sometimes called ridits (*), although I find the term mid-distribution function more transparent).

      This idea was floated in 2004 in Section 5 of https://journals.sagepub.com/doi/pdf...867X0400400209 and here it is again for the data mentioned.

      Code:
      sysuse auto
      
      set scheme s1color 
      
      * SJ 
      qplot rep78, over(foreign) midpoint recast(connected) name(O1, replace) legend(ring(0) col(1) order(2 1) pos(5))
      
      * ssc install mylabels 
      mylabels .02 .1(.2).9 .98, myscale(logit(@)) local(pla)
      
      qplot rep78, over(foreign) midpoint recast(connected) trscale(logit(@)) xla(`pla') ///
      legend(ring(0) col(1) order(2 1) pos(5)) xtitle(mi0-distribution function (logit scale)) name(O2, replace) 
      
      graph combine O1 O2

      Click image for larger version

Name:	middist.png
Views:	1
Size:	33.5 KB
ID:	1662914

      The order R1 R2 R3 here is roughly in terms of what is easiest to explain to sceptical supervisors and readers and what works reasonably well most of the time.

      On R3 the idea starts with

      * if the predictor has an influence, the quantile traces will differ

      * if we can find simple structure, that is a bonus: if extreme responses are rarer than intermediate responses, the quantile traces will be straightened by something like a logit scale.

      I draw short of saying: run ologit and think of a good way to plot the results.

      (*) Irwin Bross introduced ridits with a tongue in cheek explanation of what the word meant that I found hard to follow but seemed to convince people who quoted it. Decades later he admitted that all along he was naming them for his wife Rida. (This is a true story.)







      Comment


      • #4
        See also a 2021 presentation at https://www.stata.com/meeting/uk21/slides/UK21_Cox.zip

        Comment


        • #5
          Thank you, Nick and William.

          Comment

          Working...
          X