Announcement

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

  • Combining Graphs using distplot

    Dear Statalist,

    I was hoping to get some help on graph output. So I am reading this paper that shows what looks like a semi outdated code to draw up some graphs. I have done my best to replicate it, but cannot get the plots to stack on top of one another like in the example.


    Code:
    distplot dist_ind [w=s_o_freq], recast(connected) ylabel(, angle(h)) midpoint by(stazi_ind) l2(logit scale) reverse trscale(logit(@)) legend(col(1) position(5) ring(0))
    Last edited by Clark Banach; 31 Aug 2021, 17:18.

  • #2
    Please read and act on https://www.statalist.org/forums/help#stata especially 12.1 What to say about your commands and your problem

    and https://www.statalist.org/forums/help#references How should I give literature references?

    distplot is now from the Stata Journal.

    A search in an up-to-date Stata yields


    SJ-19-1 gr41_5 . . . . . . . . . . . . . . . . . Software update for distplot
    (help distplot if installed) . . . . . . . . . . . . . . . N. J. Cox
    Q1/19 SJ 19(1):260
    changes include better handling of the by() option calls;
    simpler default y-axis titles; more detailed discussion of
    exactly what is plotted; and more information on ridits

    SJ-10-1 gr41_4 . . . . . . . . . . . . . . . . . Software update for distplot
    (help distplot if installed) . . . . . . . . . . . . . . . N. J. Cox
    Q1/10 SJ 10(1):164
    new reverse(ge) option specifies plotting probabilities or
    frequencies greater than or equal to any data value

    SJ-5-3 gr0018 . . . . . . . . . . Speaking Stata: The protean quantile plot
    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
    Q3/05 SJ 5(3):442--460 (see gr41_3 and gr42_3 for commands)
    discusses quantile and distribution plots as used in
    the analysis of species abundance data in ecology

    SJ-5-3 gr41_3 . . . . . . . . . . . . . . . . . Software update for distplot
    (help distplot if installed) . . . . . . . . . . . . . . . N. J. Cox
    Q3/05 SJ 5(3):471
    simplified syntax; both by() and over() are now allowed

    SJ-4-2 gr0004 . Speaking Stata: Graphing categorical and compositional data
    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
    Q2/04 SJ 4(2):190--215 (no commands)
    discusses graphical possibilities for categorical and
    compositional data

    SJ-4-1 gr0003 . . . . . . . . . . . . Speaking Stata: Graphing distributions
    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
    Q1/04 SJ 4(1):66--88 (no commands)
    a review of official and user-written commands for
    graphing univariate distributions; includes tricks
    beyond what is obviously and readily available

    SJ-3-4 gr41_2 . . . . . . . . . . . . . . . . . Software update for distplot
    (help distplot if installed) . . . . . . . . . . . . . . . N. J. Cox
    Q4/03 SJ 3(4):449
    option tscale() renamed as trscale()

    SJ-3-2 gr41_1 . . . . . . . . . . . . . . . . . Software update for distplot
    (help distplot if installed) . . . . . . . . . . . . . . . N. J. Cox
    Q2/03 SJ 3(2):211
    enhanced to use Stata 8 graphics and provides new options

    STB-51 gr41 . . . . . . . . . . . . . . . . . . Distribution function plots
    (help distplot if installed) . . . . . . . . . . . . . . . N. J. Cox
    9/99 pp.12--16; STB Reprints Vol 9, pp.108--112
    plots the cumulative distribution function or survival function
    and allows multiple variables


    What's biting you in this 22 year history is that the syntax changed in 2005. Accordingly the paper you are copying but not citing (gr0004 from Stata Journal 4(2): 2004) does not exemplify currrent syntax.

    The code behind the Figure you copy is very similar to that given in the current help file, slightly modified below.

    Code:
      clear
        input float(year freq) long(Opinion race)
        1959 81 3 2
        1959 23 2 2
        1959 4 1 2
        1959 325 3 1
        1959 253 2 1
        1959 54 1 1
        1971 224 3 2
        1971 144 2 2
        1971 24 1 2
        1971 600 3 1
        1971 636 2 1
        1971 158 1 1
        end
        label values Opinion Opinion
        label def Opinion 1 "Poor" 2 "Fair" 3 "Good"
        label values race race
        label def race 1 "White" 2 "Black"
    
        set scheme s1color 
        mylabels 2 5 10(10)80, myscale(logit(@/100)) local(myla)
        distplot Opinion [w=freq], recast(connected) mid over(year) by(race, note("")) trscale(logit(@)) xla(1/3, valuelabel) yla(`myla', ang(h)) ytitle(Percent) xsc(r(0.8 3.2))

    The most important detail so far as you are concerned is that instead of
    Code:
     
     by(stazi_ind) 
    you need
    Code:
    over(stazi_ind)

    Comment

    Working...
    X