Announcement

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

  • Birth Cohorts

    I am very new to the RD design. Can anyone help me to understand what it means as birth cohort?

    I am following this paper: https://www.nber.org/system/files/wo...013/w16013.pdf

    Here, how do we construct the running variable: which is the individual birth cohort relative to the cutoff (measured in months)? I have the month of birth and year of birth variable.

  • #2
    In general terms, a birth cohort refers to a population of people who were born at (approximately) the same time. In epidemiology, my field, a birth cohort usually refers to all the people born in a given calendar year, or, in some situations, in a fixed five-year period,or a fixed 6-month period, etc.

    In the context of the article you have linked, they are looking for the effect of a certain change in educational law/policy in the UK. They do this by comparing two birth cohorts: one is people born shortly before the change took effect, and the other is people born shortly after the change took effect. The strength of the design is that although the two groups have different exposure to the law/policy change, they are approximately the same age, so that the effects of age differences should be small.

    Comment


    • #3
      Thank you Clyde. I undertood that.

      Say I want to create a variable identifying cohort relative to the cutoff date (say 04/1996).
      For example, if A and B's birthdays are 03/1996 and 02/1996, respectively, then the cohort variable must take a value of 1 for A and 2 for B.

      Is that what they are doing here?

      Then I transform the birth variable (month of the birth/year of birth- these two variables I have) to the month variable (e.g., total # of months)?
      For example, by choosing any reference date say, 01/1900, I can transform someone's birthday variable to the variable that records all months from the reference date.
      If A's birthday is, like above, 03/1996, then the new variable identifies this guy with the value of 96*12+3 = 1155. (= total # of month b/w 01/1900 and A's birthday).
      Also, the cutoff date can be changed in the same way: 96*12+4 = 1156. (= total # of month b/w 01/1900 and the cutoff date)

      And then I can simply subtract all guys' values from the cutoff date, which yields a distance measured in the # of months b/w birthday and the cutoff date for each individual. - Is that right?

      Can you help me with the code? If the above process is right what would be the correct reference date?

      Comment


      • #4
        What you describe is much more complicated than required.

        The first thing is to convert your year and month into a combined monthly Stata date variable. (Stata monthly date variables actually work like what you were decribing: they are relative to 01/1960. Using Stata date variables let's Stata handle most of the details for you and allows you to do things with built-in functions that simplify calculations.) Then you just define a new variable that depends on that value. As you do not show example data, the following code may need substantial modifications in order to work with your actual data--it is based on my imagination of what your data are like. My telepathy skills are mediocre.

        Code:
        gen mdate = ym(month, year)
        format mdate %tm
        assert missing(mdate) == missing(month, year)
        
        gen cohort = mdate < tm(1996m4) if !missing(mdate)
        The variable cohort will be 0 for all subjects born before 04/1996 and 1 for those born 04/1996 and after. If you prefer 1 and 2 instead of 0 and 1, just add 1 to it.

        One other thing: birth cohorts are typically defined to cover a relatively narrow range of time. So it's not enough here to just define the cutoff that separates the two cohorts. You also have to eliminate all people born too far before, or too far after. Just how far is "too far" depends on the specific context.

        In skimming the paper you linked to, if you are trying to follow their methods, they actually used very narrow birth cohorts: one quarter-year. Each quarter of each year was a separate cohort in their study. So if you are trying to mimic their study you would need to actually refine your monthly dates further to quarterly dates:

        Code:
        gen qdate = qofd(dofm(mdate))
        format qdate %tq
        And then qdate itself becomes the cohort variables. You would not have a single cut-off that defines two large cohorts. Each quarter is its own quarter and there are many of them.

        Comment


        • #5
          This was explained very well.

          I am using individual level data and trying to mimic similar policy in another country. My cut off is defined by people born before Apr 1996 and after April 1996.
          Based on the equation used in the paper : Eic = γ0 + γ1Dic + f(Ric) + X0 icγ2 + uic, (Page 9), where the dependent variable is a measure of educational attainment for individual i in birth cohort c at time t, D is a dummy variable indicating whether an individual belongs to a postchange cohort, R is an individual’s birth cohort (measured in months) relative to the relevant cutoff and X includes predetermined characteristics such as the year of the survey.

          I am trying to construct the R variable first (and they say, it is measured in months). So the way you suggested the code, the cohort appears to be binary. I am confused, because the D variable does that construction here (R>=0 then D==1 and R<0 then D==0). I am trying to create the R variable and trying to build the basic rdplot. Can you help me with that?

          Here is a small snippet of my data:

          Attached Files
          Last edited by Sandipa Bhattacharya; 16 Jul 2021, 16:43.

          Comment


          • #6
            Yes, I can help you, but only if you help me. Screenshots, though well intended, are not helpful. The helpful way to show example data is with the -dataex- command. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

            Comment


            • #7
              Here it goes:

              . dataex caseid age birthmo birthyear

              ----------------------- copy starting from the next line -----------------------
              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input str18 caseid byte(age birthmo) int birthyear
              "    01000101    02" 46  7 1969
              "    01000101    04" 20  1 1995
              "    01000109    01" 40  3 1975
              "    01000109    02" 21  1 1994
              "    01000109    03" 19  2 1996
              "    01000110    02" 26  1 1989
              "    01000111    02" 43 12 1971
              "    01000111    03" 17 10 1997
              "    01000117    02" 22  4 1993
              "    01000120    01" 35 10 1979
              "    01000123    02" 25  5 1990
              "    01000129    02" 46  9 1968
              "    01000129    03" 17 12 1997
              "    01000130    02" 40  1 1975
              "    01000130    04" 21 10 1993
              "    01000130    05" 17  2 1998
              "    01000134    02" 46  3 1969
              "    01000143    01" 40  7 1975
              "    01000150    02" 37  4 1978
              "    01000152    02" 37  4 1978
              "    01000157    02" 33  7 1982
              "    01000162    02" 44  1 1971
              "    01000162    03" 24  5 1991
              "    01000162    04" 21  1 1994
              "    01000171    02" 42  6 1973
              "    01000172    02" 35  2 1980
              "    01000192    07" 27 12 1987
              "    01000196    02" 34  2 1981
              "    01000207    02" 20  7 1995
              "    01000213    03" 24  3 1991
              "    01000214    02" 40 12 1974
              "    01000216    02" 33  5 1982
              "    01000219    02" 32  5 1983
              "    01000221    02" 47  1 1968
              "    01000221    04" 19  5 1996
              "    01000227    02" 48 11 1966
              "    01000227    04" 24  3 1991
              "    01000245    04" 32  6 1983
              "    01000245    07" 20  8 1994
              "    01000248    02" 30  6 1985
              "    01000252    02" 38  7 1977
              "    01000256    02" 31  6 1984
              "    01000257    02" 40  5 1975
              "    01000257    03" 22 12 1992
              "    01000258    02" 43  7 1972
              "    01000258    04" 23  2 1992
              "    01000258    06" 17 12 1997
              "    01000264    02" 20 12 1994
              "    01000274    02" 45 12 1969
              "    01000274    06" 15  9 1999
              "    01000275    03" 31  1 1984
              "    01000280    02" 46 11 1968
              "    01000280    03" 29  9 1985
              "    01000282    02" 41  2 1974
              "    01000283    02" 40  1 1975
              "    01000283    03" 18  1 1997
              "    01000283    04" 16  4 1999
              "    01000287    02" 27  5 1988
              "    01000287    03" 16  6 1999
              "    01000287    06" 30  2 1985
              "    01000290    02" 40  6 1975
              "    01000295    04" 28  6 1987
              "    01000310    02" 38  7 1976
              "    01000313    02" 44  3 1971
              "    01000314    04" 32  2 1983
              "    01000315    02" 43  7 1971
              "    01000315    04" 17 10 1997
              "    01000319    02" 49 11 1965
              "    01000322    04" 31  3 1984
              "    01000330    02" 42  6 1973
              "    01000334    02" 46  4 1969
              "    01000341    03" 29  4 1986
              "    01000353    04" 37 11 1977
              "    01000354    02" 36  5 1979
              "    01000366    02" 48 10 1966
              "    01000366    03" 22  3 1993
              "    01000371    04" 49 10 1965
              "    01000373    02" 40  1 1975
              "    01000374    02" 29  1 1986
              "    01000375    03" 32  5 1983
              "    01000382    02" 48  4 1967
              "    01000382    04" 18  8 1996
              "    01000383    02" 29  5 1986
              "    01000387    02" 25 11 1989
              "    01000406    02" 43  4 1972
              "    01000406    03" 17  2 1998
              "    01000406    04" 15  9 1999
              "    01000409    04" 37  7 1977
              "    01000411    03" 41  1 1974
              "    01000412    04" 39  3 1976
              "    01000412    05" 39  4 1976
              "    01000413    02" 46  5 1969
              "    01000413    05" 43  5 1972
              "    01000429    02" 39  1 1976
              "    01000430    02" 39  1 1976
              "    01000433    02" 39  7 1975
              "    01000433    03" 19  6 1996
              "    01000434    03" 45  1 1970
              "    01000434    06" 22  2 1993
              "    01000435    02" 36  7 1978
              end
              label values age AGE
              label def AGE 15 "15", modify
              label def AGE 16 "16", modify
              label def AGE 17 "17", modify
              label def AGE 18 "18", modify
              label def AGE 19 "19", modify
              label def AGE 20 "20", modify
              label def AGE 21 "21", modify
              label def AGE 22 "22", modify
              label def AGE 23 "23", modify
              label def AGE 24 "24", modify
              label def AGE 25 "25", modify
              label def AGE 26 "26", modify
              label def AGE 27 "27", modify
              label def AGE 28 "28", modify
              label def AGE 29 "29", modify
              label def AGE 30 "30", modify
              label def AGE 31 "31", modify
              label def AGE 32 "32", modify
              label def AGE 33 "33", modify
              label def AGE 34 "34", modify
              label def AGE 35 "35", modify
              label def AGE 36 "36", modify
              label def AGE 37 "37", modify
              label def AGE 38 "38", modify
              label def AGE 39 "39", modify
              label def AGE 40 "40", modify
              label def AGE 41 "41", modify
              label def AGE 42 "42", modify
              label def AGE 43 "43", modify
              label def AGE 44 "44", modify
              label def AGE 45 "45", modify
              label def AGE 46 "46", modify
              label def AGE 47 "47", modify
              label def AGE 48 "48", modify
              label def AGE 49 "49", modify
              label values birthmo BIRTHMO
              label def BIRTHMO 1 "january", modify
              label def BIRTHMO 2 "february", modify
              label def BIRTHMO 3 "march", modify
              label def BIRTHMO 4 "april", modify
              label def BIRTHMO 5 "may", modify
              label def BIRTHMO 6 "june", modify
              label def BIRTHMO 7 "july", modify
              label def BIRTHMO 8 "august", modify
              label def BIRTHMO 9 "september", modify
              label def BIRTHMO 10 "october", modify
              label def BIRTHMO 11 "november", modify
              label def BIRTHMO 12 "december", modify
              label values birthyear BIRTHYEAR
              label def BIRTHYEAR 1965 "1965", modify
              label def BIRTHYEAR 1966 "1966", modify
              label def BIRTHYEAR 1967 "1967", modify
              label def BIRTHYEAR 1968 "1968", modify
              label def BIRTHYEAR 1969 "1969", modify
              label def BIRTHYEAR 1970 "1970", modify
              label def BIRTHYEAR 1971 "1971", modify
              label def BIRTHYEAR 1972 "1972", modify
              label def BIRTHYEAR 1973 "1973", modify
              label def BIRTHYEAR 1974 "1974", modify
              label def BIRTHYEAR 1975 "1975", modify
              label def BIRTHYEAR 1976 "1976", modify
              label def BIRTHYEAR 1977 "1977", modify
              label def BIRTHYEAR 1978 "1978", modify
              label def BIRTHYEAR 1979 "1979", modify
              label def BIRTHYEAR 1980 "1980", modify
              label def BIRTHYEAR 1981 "1981", modify
              label def BIRTHYEAR 1982 "1982", modify
              label def BIRTHYEAR 1983 "1983", modify
              label def BIRTHYEAR 1984 "1984", modify
              label def BIRTHYEAR 1985 "1985", modify
              label def BIRTHYEAR 1986 "1986", modify
              label def BIRTHYEAR 1987 "1987", modify
              label def BIRTHYEAR 1988 "1988", modify
              label def BIRTHYEAR 1989 "1989", modify
              label def BIRTHYEAR 1990 "1990", modify
              label def BIRTHYEAR 1991 "1991", modify
              label def BIRTHYEAR 1992 "1992", modify
              label def BIRTHYEAR 1993 "1993", modify
              label def BIRTHYEAR 1994 "1994", modify
              label def BIRTHYEAR 1995 "1995", modify
              label def BIRTHYEAR 1996 "1996", modify
              label def BIRTHYEAR 1997 "1997", modify
              label def BIRTHYEAR 1998 "1998", modify
              label def BIRTHYEAR 1999 "1999", modify
              ------------------ copy up to and including the previous line ------------------

              Listed 100 out of 699686 observations
              Use the count() option to list more

              Comment


              • #8
                Thank you.

                Code:
                //  DEFINE COHORTS AS BIRTH QUARTERS
                gen int cohort = qofd(mdy(birthmo, 1, birthyear))
                assert missing(cohort) == missing(birthyear, birthmo)
                format cohort %tq
                will give you quarterly birth cohorts, as used in that linked paper. When using this variable in your regression, to assure that it is properly handled as a discrete, not a continuous, variable, you must refer to it as i.cohort in the regression command. Read -help fvvarlist- to understand how this works.

                Note: For some odd reason, your birthyear variable has a value label attached to it. As it turns out, the underlying values exactly match the label--so it is harmless, but also useless. It is a potential source of confusion, however. So I suggest you detach the label:

                Code:
                //  VERIFY THAT THE LABEL FOR BIRTHYEAR IS JUST THE SAME AS ITS VALUE
                levelsof birthyear, local(bys)
                foreach b of local bys {
                    assert `"`:label (birthyear) `b''"' == `"`b'"'
                }
                label values birthyear

                Comment


                • #9
                  But that does not give me the cohort relative to the cut off right? How to assign that?
                  I create another variable say R= cohort - yq(1996,2) ?
                  Also I have another confusion. They say that the R variable they are creating in the equation (Page 9 in the paper) is measured in months. Why do you think that is measured as birth quarters? Can you clear that?

                  Comment


                  • #10
                    They say that the R variable they are creating in the equation (Page 9 in the paper) is measured in months. Why do you think that is measured as birth quarters? Can you clear that?
                    My mistake. I was looking at some of the results graphs, and the axes are labeled with quarters rather than months. But you are right, they specifically say that they did cohorts in months, and on top of that a more careful look even at the graphs shows that the number of plotted points is too large to represent quarters and looks right for months. So the code has to change:

                    Code:
                    // DEFINE COHORTS AS BIRTH QUARTERS
                    gen int cohort = ym(birthyear, birthmo)
                    assert missing(cohort) == missing(birthyear, birthmo)
                    format cohort %tm
                    Sorry for the confusion.

                    But that does not give me the cohort relative to the cut off right? How to assign that?
                    I create another variable say R= cohort - yq(1996,2) ?
                    You do not need to get the cohort relative to the cutoff. First of all, there are two cutoffs they consider in that article. Second, if you try to use a variable that is relative to a cutoff, some of its values will be negative, and Stata will not allow that for a factor-variable. So to get the regression discontinuity, what you need to do is create a three-level variable:

                    Code:
                    label define era 1 "Before 1st Cutoff" 2 "Between Cutoffs" 3 "After 2nd Cutoff"
                    gen byte era:era = 1 if cohort < tm(1996m4)
                    replace era = 2 if inrange(cohort, tm(1996m4, fill_in_second_cutoff_here)
                    replace era = 3 if cohort > fill_in_second_cutoff_here_too & !missing(cohort)
                    In your regression you will include i.cohort and i.era. The results for 2.era will represent the regression discontinuity at the first cutoff. And -lincom 3.era - 2.era- will give you the discontinuity at the second cutoff.

                    Comment


                    • #11
                      For the graph on page 47, do I collapse the fraction of full time education based on the quarter of births?

                      * Example generated by -dataex-. To install: ssc install dataex
                      clear
                      input str18 caseid byte(age birthmo) int birthyear byte(educlvl yrschl edyrtotal)
                      " 01000101 04" 20 1 1995 3 2 14
                      " 01000109 02" 21 1 1994 3 2 14
                      " 01000109 03" 19 2 1996 3 1 13
                      " 01000111 03" 17 10 1997 2 7 12
                      " 01000117 02" 22 4 1993 2 5 10
                      " 01000129 03" 17 12 1997 2 6 11
                      " 01000130 04" 21 10 1993 2 7 12
                      " 01000130 05" 17 2 1998 2 6 11
                      " 01000162 03" 24 5 1991 3 4 16
                      " 01000162 04" 21 1 1994 3 4 16
                      " 01000207 02" 20 7 1995 2 7 12
                      " 01000213 03" 24 3 1991 2 7 12
                      " 01000221 04" 19 5 1996 2 4 9
                      " 01000227 04" 24 3 1991 2 5 10
                      " 01000245 07" 20 8 1994 2 5 10
                      " 01000257 03" 22 12 1992 2 7 12
                      " 01000258 04" 23 2 1992 2 7 12
                      " 01000258 06" 17 12 1997 2 7 12
                      " 01000264 02" 20 12 1994 2 2 7
                      " 01000274 06" 15 9 1999 2 5 10
                      " 01000283 03" 18 1 1997 0 99 0
                      " 01000283 04" 16 4 1999 2 6 11
                      " 01000287 03" 16 6 1999 2 4 9
                      " 01000315 04" 17 10 1997 2 4 9
                      " 01000366 03" 22 3 1993 2 7 12
                      " 01000382 04" 18 8 1996 2 7 12
                      " 01000406 03" 17 2 1998 2 5 10
                      " 01000406 04" 15 9 1999 2 3 8
                      " 01000433 03" 19 6 1996 2 7 12
                      " 01000434 06" 22 2 1993 2 7 12
                      " 01000442 07" 23 9 1991 2 7 12
                      " 01000445 08" 22 5 1993 2 7 12
                      " 01000455 04" 24 6 1991 2 7 12
                      " 01000455 05" 20 5 1995 3 1 13
                      " 01000459 04" 22 12 1992 2 7 12
                      " 01000484 06" 22 11 1992 2 7 12
                      " 01000489 06" 23 7 1991 3 3 15
                      " 01000518 03" 19 3 1996 2 2 7
                      " 01000520 02" 21 10 1993 2 5 10
                      " 01000522 02" 21 4 1994 2 4 9
                      " 01000525 03" 21 6 1993 2 7 12
                      " 01000525 05" 22 6 1992 2 3 8
                      " 01000535 03" 18 9 1996 2 3 8
                      " 01000558 03" 15 3 2000 2 4 9
                      " 01000576 05" 17 12 1997 2 5 10
                      " 01000646 05" 15 7 1999 2 5 10
                      " 01000649 02" 20 8 1994 2 6 11
                      " 01000650 02" 20 2 1995 2 7 12
                      " 01000656 08" 17 2 1998 2 4 9
                      " 01000709 02" 22 9 1992 1 5 5
                      " 01000743 03" 16 6 1998 2 6 11
                      " 01000772 03" 21 1 1994 2 3 8
                      " 01000904 02" 23 7 1992 2 7 12
                      " 01000907 04" 22 2 1993 2 7 12
                      " 01000911 03" 21 2 1994 2 7 12
                      " 01000911 04" 19 4 1996 2 6 11
                      " 01000936 05" 15 4 2000 2 4 9
                      " 01000943 06" 18 11 1996 2 6 11
                      " 01000960 03" 16 1 1999 2 5 10
                      " 01000962 04" 19 12 1995 2 7 12
                      " 01000963 04" 20 7 1995 2 6 11
                      " 01000963 05" 16 1 1999 2 4 9
                      " 01000976 06" 21 6 1994 2 7 12
                      " 01000976 09" 20 3 1995 2 6 11
                      " 01000993 03" 15 2 2000 2 7 12
                      " 01000994 05" 23 8 1991 2 5 10
                      " 01001019 03" 18 10 1996 3 1 13
                      " 01001047 04" 22 5 1993 3 2 14
                      " 01001054 08" 22 11 1992 2 5 10
                      " 01001071 02" 23 3 1992 2 5 10
                      " 01001145 04" 16 12 1998 2 6 11
                      " 01001147 08" 15 10 1999 2 4 9
                      " 01001194 04" 21 12 1993 3 2 14
                      " 01001196 03" 19 10 1995 3 2 14
                      " 01001629 02" 24 3 1991 2 7 12
                      " 01001629 03" 20 11 1994 3 3 15
                      " 01001631 03" 20 2 1995 2 5 10
                      " 01001631 04" 19 6 1996 2 7 12
                      " 01001645 04" 21 3 1994 2 7 12
                      " 01001645 08" 19 10 1995 2 6 11
                      " 01001654 04" 18 4 1997 2 5 10
                      " 01001695 07" 21 6 1994 2 6 11
                      " 01001730 03" 19 9 1995 2 4 9
                      " 01001730 10" 22 4 1993 2 6 11
                      " 01001746 07" 16 6 1998 2 6 11
                      " 01001756 05" 21 6 1993 3 4 16
                      " 01001788 03" 17 5 1997 2 6 11
                      " 01001797 04" 20 6 1994 2 7 12
                      " 01001803 02" 23 4 1992 2 4 9
                      " 01001814 02" 20 9 1994 2 5 10
                      " 01001831 03" 15 8 1999 2 6 11
                      " 01001834 03" 15 11 1999 1 5 5
                      " 01001863 02" 17 11 1997 2 6 11
                      " 01001898 04" 15 6 1999 2 4 9
                      " 01001926 03" 21 12 1993 3 4 16
                      " 01001926 04" 19 6 1996 3 2 14
                      " 01001950 04" 20 2 1995 2 7 12
                      " 01001950 06" 21 1 1994 3 2 14
                      " 01001968 03" 17 11 1997 2 7 12
                      " 01001981 03" 16 5 1999 2 5 10
                      end
                      label values age AGE
                      label def AGE 15 "15", modify
                      label def AGE 16 "16", modify
                      label def AGE 17 "17", modify
                      label def AGE 18 "18", modify
                      label def AGE 19 "19", modify
                      label def AGE 20 "20", modify
                      label def AGE 21 "21", modify
                      label def AGE 22 "22", modify
                      label def AGE 23 "23", modify
                      label def AGE 24 "24", modify
                      label values birthmo BIRTHMO
                      label def BIRTHMO 1 "january", modify
                      label def BIRTHMO 2 "february", modify
                      label def BIRTHMO 3 "march", modify
                      label def BIRTHMO 4 "april", modify
                      label def BIRTHMO 5 "may", modify
                      label def BIRTHMO 6 "june", modify
                      label def BIRTHMO 7 "july", modify
                      label def BIRTHMO 8 "august", modify
                      label def BIRTHMO 9 "september", modify
                      label def BIRTHMO 10 "october", modify
                      label def BIRTHMO 11 "november", modify
                      label def BIRTHMO 12 "december", modify
                      label values birthyear BIRTHYEAR
                      label def BIRTHYEAR 1991 "1991", modify
                      label def BIRTHYEAR 1992 "1992", modify
                      label def BIRTHYEAR 1993 "1993", modify
                      label def BIRTHYEAR 1994 "1994", modify
                      label def BIRTHYEAR 1995 "1995", modify
                      label def BIRTHYEAR 1996 "1996", modify
                      label def BIRTHYEAR 1997 "1997", modify
                      label def BIRTHYEAR 1998 "1998", modify
                      label def BIRTHYEAR 1999 "1999", modify
                      label def BIRTHYEAR 2000 "2000", modify
                      label values educlvl EDUCLVL
                      label def EDUCLVL 0 "no education", modify
                      label def EDUCLVL 1 "primary", modify
                      label def EDUCLVL 2 "secondary", modify
                      label def EDUCLVL 3 "higher", modify
                      label values yrschl YRSCHL
                      label def YRSCHL 1 "1", modify
                      label def YRSCHL 2 "2", modify
                      label def YRSCHL 3 "3", modify
                      label def YRSCHL 4 "4", modify
                      label def YRSCHL 5 "5", modify
                      label def YRSCHL 6 "6", modify
                      label def YRSCHL 7 "7", modify
                      label def YRSCHL 99 "niu (not in universe)", modify
                      label values edyrtotal EDYRTOTAL
                      label def EDYRTOTAL 0 "0", modify
                      label def EDYRTOTAL 5 "5", modify
                      label def EDYRTOTAL 7 "7", modify
                      label def EDYRTOTAL 8 "8", modify
                      label def EDYRTOTAL 9 "9", modify
                      label def EDYRTOTAL 10 "10", modify
                      label def EDYRTOTAL 11 "11", modify
                      label def EDYRTOTAL 12 "12", modify
                      label def EDYRTOTAL 13 "13", modify
                      label def EDYRTOTAL 14 "14", modify
                      label def EDYRTOTAL 15 "15", modify
                      label def EDYRTOTAL 16 "16", modify
                      [/CODE]

                      How do I label the x axis?

                      Example:

                      gen int qob = qofd(mdy(birthmo, 1, birthyear)) assert missing(cohort) == missing(birthyear, birthmo) format qob %tq capture program drop my_graph
                      program define my_graph
                      use example.dta, clear
                      collapse yrschl, by(qob)
                      sort qob
                      twoway /*
                      */ (connect 'var' qob, nodraw /*
                      */ mcolor(black black black black) msize(small small small small) msymbol(D x D x) /*
                      */ clwidth(medthick medthick medthick medthick) clcolor(black black black black) clpattern(solid dash dot dash_dot) /*
                      */ xline(, lcolor(black black)) /*
                      */ xsc(r()) xtitle("") xlabel(how to label it?) /* <confused about this part>
                      */ ysc(r()) ytitle("") ylab()/* <confused about this part>
                      */ title("", size(6) justification(left) color(black)) /* <confused about this part>

                      */ legend(label(1 "<=9 Years") label(2 "<=10 Years") label(3 "<=11 Years") label(4 "No university degree") order cols(4) pos(6) size(4)) /*
                      */ xsize(6.5) ysize() graphregion(fcolor(white) ifcolor(white) color(white) icolor(white)) graphregion(margin(l+2 r+2 t+2)) plotregion(fcolor(white)))
                      graph save output/figure_1, replace
                      end
                      my_graph "left_14 left_15 left_16 no_degree" "window_full==1" "0" "1" "0" "0.5" "1"

                      Or may be I am complicating it?

                      Unlike this paper, I have only one cut off- at Apr 1996. Which makes it way more easier. But I am slightly confused with the graph plotting. Can you help me? Or I am doing something wrong?

                      Comment


                      • #12
                        So before you worry about the esthetic details of the graph, worry about the fact that your data is messed up. Your variable edytotal has missing values coded as 99, and those 99's are being treated as actual 99 years of education when you run -collapse-. So first fix your data. Get rid of all the "magic numbers" that are used for missing values and replace them by actual missing values.

                        Next, the variable qob does not exist in your example data, nor do you provide the code for how you computed it. Considering that it is the variable that goes on the x-axis, that's a crucial omission when your big question is how to label the x-axis. Once you have that, the question of how to label the x-axis to match what they did in on page 47 is something that might be faced. But on page 47 the graph has years running from 1921 through 1971, whereas your data seems not to even overlap with that era. Your birth years range from 1991 to 2000. So I can't even guess what you would like the axis labels to look like.

                        Finally, I have to say that I cannot make any sense out of the page 47 graph. They have four curves on the graph, corresponding to different amounts of education. But then the vertical axis is some variable that ranges from 0 to 1, and there is no axis title explaining what that variable might be. The graph title says it's years of full time education, but that clearly can't be right given that almost nobody actually has years of education between 0 and 1. Perhaps somewhere in the article text it explains what the graph really is, but that's a terrible way to design a graph.

                        Comment

                        Working...
                        X