Announcement

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

  • Producing three way graph

    Hello Statalist

    I would like to produce a three way graph on stata like the one provided in the attachment, taken from the following paper:


    Shu, X. and Meagher, K.D., 2017. Beyond the stalled gender revolution: Historical and cohort dynamics in gender attitudes from 1977 to 2016. Social Forces, 96(3), pp.1243-1274.

    Similar to the graph attached, I would like to plot the following:

    I have three variables, a binary outcome (delf) coded as (0) % Agree (1) % disagree, a birth cohort categorical variable with 6 categories and a period categorical variable with 3 categories. I would like to plot the outcome variable (% Agree) on the Y axis, the Period on the X axis and then have the different lines represent the different birth cohorts with the % that Agree at each time period.

    I have been trying using the following syntax but I get odd looking graphs (I am a beginner at stata unfortunately):

    Code:
    line delf C1 C2 C3 C4 C5 C6 Period
    Any help would be very much appreciated.
    Thank you.

    Attached Files

  • #2
    It's hard to see the connection between the graphs you show and what you're asking. Also, how can 0 and 1 encode % agree or % disagree?

    Please give a data example to make clearer what you have. The FAQ Advice indicates how to do that.

    Comment


    • #3
      Apologies about that Nick my explanation was not very clear, please see below an example of my data:

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input byte ideology1 int Age byte Period int Cohort
      1 43 0 4
      1 48 0 3
      1 34 0 5
      1 24 0 5
      0 27 0 5
      1 24 0 5
      0 32 0 5
      1 36 0 4
      0 38 0 4
      1 38 0 4
      1 71 0 1
      1 39 0 4
      0 60 0 2
      1 25 0 5
      1 56 0 3
      1 51 0 3
      0 34 0 5
      1 19 0 6
      1 70 0 1
      1 62 0 2
      1 36 0 4
      0 45 0 3
      1 27 0 5
      1 16 0 6
      1 37 0 4
      1 38 0 4
      1 30 0 5
      1 52 0 3
      1 38 0 4
      1 17 0 6
      1 58 0 2
      1 42 0 4
      1 16 0 6
      1 41 0 4
      1 47 0 3
      1 41 0 4
      1 16 0 6
      1 40 0 4
      1 33 0 5
      0 51 0 3
      1 44 0 4
      1 53 0 3
      0 36 0 4
      0 58 0 2
      1 65 0 2
      0 52 0 3
      1 17 0 6
      1 20 0 6
      1 44 0 4
      0 38 0 4
      1 47 0 3
      1 65 0 2
      1 41 0 4
      1 41 0 4
      1 19 0 6
      0 56 0 3
      1 58 0 2
      1 50 0 3
      1 65 0 2
      1 51 0 3
      1 32 0 5
      1 18 0 6
      1 38 0 4
      0 51 0 3
      0 56 0 3
      0 77 0 1
      0 31 0 5
      1 40 0 4
      1 49 0 3
      0 53 0 3
      1 40 0 4
      0 63 0 2
      0 43 0 4
      1 51 0 3
      1 52 0 3
      1 49 0 3
      1 60 0 2
      1 36 0 4
      1 35 0 4
      1 76 0 1
      1 36 0 4
      1 46 0 3
      1 69 0 1
      1 55 0 3
      0 35 0 4
      1 25 0 5
      1 46 0 3
      1 60 0 2
      0 38 0 4
      0 50 0 3
      1 16 0 6
      1 62 0 2
      1 18 0 6
      0 35 0 4
      1 31 0 5
      0 73 0 1
      1 68 0 1
      1 50 0 3
      1 60 0 2
      1 33 0 5
      end
      label values ideology1 edc
      label def edc 0 "Agree", modify
      label def edc 1 "Disagree", modify
      label values Age X003
      label values Period per
      label def per 0 "1999-2004", modify
      label values Cohort birth_year
      label def birth_year 1 "1923-1933", modify
      label def birth_year 2 "1934-1944", modify
      label def birth_year 3 "1945-1955", modify
      label def birth_year 4 "1956-1966", modify
      label def birth_year 5 "1967-1977", modify
      label def birth_year 6 "1978-1988", modify
      The ideology1 variable is binary coded as (0) for Agree and (1) for disagree. Cohort and period are categorical. At each birth cohort there will be a percentage who Agree (0) and a percentage who Disagree (0). I would like to graph that so that the Y axis ranges from 0-100%, the X axis has the the different survey waves (Period) and the lines shown on the graph would represent the different birth cohort with each point being a percentage who agree. For instance, from those born between 1990-2000 20% agree during the period of 2004-2006 (that would be a point on the graph).

      I hope my question makes better sense now!

      Comment


      • #4
        Thanks for the data example. It only includes data from one period, so a line graph doesn't work. But for your fuller dataset something like this may help:

        Code:
        egen toshow = mean(100 * ideology1), by(Period Cohort)
        separate toshow, by(Cohort) veryshortlabel
        line toshow? Period , ytitle(% disagreeing)
        To show % agreeing subtract from 100 or average 100 * (1 - ideology1).

        Comment


        • #5
          Thank you very much for your help and patience Nick, the code provides me with the graph I had in mind.

          -Hale
          Last edited by Hale Isaac; 22 Feb 2019, 10:13.

          Comment

          Working...
          X