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


          • #6
            Hello, I would like to estimate a svar model with narrative sign restriction in stata18, but I don't know the right command. For example, I have five variables X1 X2 X3 X4 and X5 for data from 1980 to 2019. My narrative sign restrictions are that the shock of X5 has a positve effect on X1 X2 X3 at specific date 1990 and 1998 , and negative effect on X4 at the date 1995. I want to estimate the svar and show impulses responses graph. Please I need your help.

            Comment


            • #7
              Th Albin Please repost #4 as a new thread with an appropriate title such as

              svar model with narrative sign restriction

              I have very little idea what that means, but I can't discern any relation to this thread.

              Comment


              • #8
                Nick Cox Please I'm a new user so I don't know how the forum work properly, but my request is an emergency one

                Comment


                • #9
                  New users are always welcome, but you should not need any experience of any forum to realise that placing a question under a thread title that doesn't apply doesn't help your cause.

                  As I said, I don't really understand your question -- so sorry, I can't help.

                  Your question can only be answered by people who are attracted by your topic. Are there people interested in three-way graphs (e.g. me) also interested in your topic? I don't know, but my advice remains to ask a new question using a relevant title.

                  There isn't here a queue to be jumped according to your "emergency", usually implying a lack of planning.

                  Comment


                  • #10
                    Simple response is always good. As I stated, I'm a new user, and I should not know the right section for new subject. Give a courteous reply don't harm ideas, I don't know if you are a planning teacher, but it is not the appropriate way to reply to people. Please let's continue your thread safely.

                    Comment


                    • #11
                      I am still puzzled at your placing a question under an irrelevant title. That is not rocket science or metaphysics; it is on the same level as not asking about fish in a bakery.

                      Since you've now posted as I suggested, you have a better chance of an answer.

                      If you think asking you please to do things in your own best interest and sorry, I can't help is discourteous, then sorry (again), and welcome to the world of technical forums.

                      Comment

                      Working...
                      X