Announcement

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

  • #16
    I haven't read this discussion carefully, but just in case it is relevant I will note that Stata 17 has some neat new commands for difference in differences:

    https://www.stata.com/new-in-stata/d...ences-DID-DDD/

    https://www.youtube.com/watch?v=OQCKafoCb9Q
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #17
      No, something is definitely wrong. It is almost certainly a problem with the data itself. Please use the -dataex- command and show an excerpt of the data. Make sure it is an excerpt of the data that reproduces this problem when you run the same code on it. If you are running version 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


      • #18
        I did it using
        Code:
        dataex register ps age18_24 year_first_post_implement pre_reg, count (50)
        . Hope it is ok.
        Here the results I got:
        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input float(register ps age18_24 year_first_post_implement pre_reg)
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 1 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        0 0 1 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 1 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        0 0 0 . 0
        1 0 0 . 0
        0 0 1 . 0
        1 0 0 . 0
        0 0 0 . 0
        0 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        . 0 0 . 0
        0 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        0 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 1 . 0
        . 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        1 0 0 . 0
        end

        Comment


        • #19
          In your example data, ps is 0 in every observation. If that's true in your complete data set, then that alone destroys the modeling. You need to have both states that have implemented the pre-registration and those that have not.

          Your example data contains the variable year_first_post_implementation; the variable needed is years_since_implement. Also, the variable year_first_post_implementation always has missing values in your example. Since years_since_implement is calculated from it, that implies that years_since_implement is also in trouble.

          Go over your data set and do a cross tab of ps and years_since_implement. I won't go so far as to say there should be no empty cells in that table, but there should be few of them, if any. And, in particular, each value of ps should be found with both positive and negative values of years_since_implement. If that's not the case, then the data are no suitable for analysis and will need to be revised. (And this kind of incorrect data would produce precisely the kind of troublesome results you are showing, which is why I'm focusing on this possibility.)


          Comment


          • #20
            Yes, I am actually noticing. Here you can find the cross tabulation

            Code:
            . tab ps years_since_implement
            
                       | years_sinc
                       | e_implemen
                       |     t
                    ps |         3 |     Total
            -----------+-----------+----------
                     0 | 1,802,520 | 1,802,520 
                     1 |   732,853 |   732,853 
            -----------+-----------+----------
                 Total | 2,535,373 | 2,535,373
            The doubt that arises is that the variable -Ps- is not dummied; I just copied the code you provided me because I couldn't find an easier way to aggregate pre-registered states:
            Code:
            by statefip, sort: egen ps = max(pre_reg)
            Then, I also copied the code for creating the event-dummies since, again, I am not able to do on my own (that's why I asked you later in #15 how you proceeded with its creation):
            Code:
            by statefip, sort: egen year_first_post_implement = min(cond(pre_reg, year, .))
            gen years_since_implement = year - year_first_post_implement
            replace years_since_implement = max(min(year_first_post_implement, 3), -5)
            That's the code for the event-time dummy. In addition, as you have seen from previous posts, I can capture the effect for year zero (baseline) and up to three years after the introduction of the law, but not the years prior to the introduction (which, however, I see written in your code as -5).

            Comment


            • #21
              The variable ps is a nice 0/1 variable, and its distribution is reasonable. But clearly there is a problem with time since implementation, as the only value you are getting is 3. So something is wrong with that. Without an example of your starting data, I can't say what the source of the problem is, nor how to fix it. Please post back, and use the -dataex- command to show example of your starting data. 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


              • #22
                I tried to insert the link that refers you to my folder on google drive, because maybe you can't understand from the extract with -dataex- I hope you are able to log in, otherwise warn me that I find another way. I also provided you with a tabulate of time too, just in case it can help you.
                [CODE] tab year

                survey year | Freq. Percent Cum.
                ------------+-----------------------------------
                1980 | 174,801 6.89 6.89
                1982 | 156,984 6.19 13.09
                1984 | 152,600 6.02 19.11
                1986 | 149,443 5.89 25.00
                1988 | 140,882 5.56 30.56
                1990 | 150,172 5.92 36.48
                1992 | 145,657 5.74 42.22
                1994 | 140,184 5.53 47.75
                1996 | 124,112 4.90 52.65
                1998 | 123,569 4.87 57.52
                2000 | 121,283 4.78 62.31
                2002 | 143,633 5.67 67.97
                2004 | 140,277 5.53 73.50
                2006 | 136,046 5.37 78.87
                2008 | 132,812 5.24 84.11
                2010 | 134,179 5.29 89.40
                2012 | 133,427 5.26 94.66
                2014 | 135,312 5.34 100.00
                ------------+-----------------------------------
                Total | 2,535,373 100.00
                To use Google Drive, you need to use a supported web browser. Learn what a browser is, which browser you use, and how to update to the latest version. Option
                Last edited by Cairone Federica; 24 Apr 2021, 02:16.

                Comment


                • #23
                  Code:
                  Code:
                  * Example generated by -dataex-. To install: ssc install dataex
                  clear
                  input int year byte statefip
                  1980 17
                  1980 17
                  1980 17
                  1980 17
                  1980 17
                  1980 17
                  1980 17
                  1980  2
                  1980  2
                  1980  2
                  1980  2
                  1980 31
                  1980 31
                  1980 31
                  1980 30
                  1980 30
                  1980 46
                  1980 46
                  1980 46
                  1980 19
                  1980 19
                  1980 29
                  1980 29
                  1980 29
                  1980  9
                  1980  9
                  1980  9
                  1980  9
                  1980 49
                  1980 49
                  1980 54
                  1980 54
                  1980 54
                  1980 54
                  1980  6
                  1980  6
                  1980  6
                  1980 19
                  1980 19
                  1980 29
                  1980 29
                  1980 29
                  1980 29
                  1980 42
                  1980 42
                  1980 42
                  1980 28
                  1980 28
                  1980 28
                  1980 28
                  end
                  label values statefip STATEFIP
                  label def STATEFIP 2 "alaska", modify
                  label def STATEFIP 6 "california", modify
                  label def STATEFIP 9 "connecticut", modify
                  label def STATEFIP 17 "illinois", modify
                  label def STATEFIP 19 "iowa", modify
                  label def STATEFIP 28 "mississippi", modify
                  label def STATEFIP 29 "missouri", modify
                  label def STATEFIP 30 "montana", modify
                  label def STATEFIP 31 "nebraska", modify
                  label def STATEFIP 42 "pennsylvania", modify
                  label def STATEFIP 46 "south dakota", modify
                  label def STATEFIP 49 "utah", modify
                  label def STATEFIP 54 "west virginia", modify

                  Comment


                  • #24
                    Thank you for your response. Unfortunately, what you have shown with -dataex- does not include enough variables to work with. While I appreciate the Google drive link, I do not download files from people I do not know. Please post an example using -dataex-. Include, at a minimum, all variables mentioned in #1 and #5 of this thread. And be sure that the data includes both states that pre-registered and states that did not, and that all years are also represented in the example.

                    Comment


                    • #25
                      Code:
                      . dataex year statefip pre_reg register vote age18_24 ps, count(500)
                      
                      ----------------------- copy starting from the next line -----------------------
                      
                      
                      Code:
                      * Example generated by -dataex-. To install: ssc install dataex
                      clear
                      input int year byte statefip float(pre_reg register vote age18_24 ps)
                      2006 1 0 1 1 0 0
                      2006 1 0 . . . 0
                      2006 1 0 1 1 0 0
                      2006 1 0 1 1 0 0
                      2002 1 0 . . . 0
                      1980 1 0 1 1 0 0
                      2012 1 0 . . . 0
                      2006 1 0 1 1 1 0
                      2006 1 0 1 0 0 0
                      2004 1 0 1 1 0 0
                      2006 1 0 1 1 0 0
                      1986 1 0 . . . 0
                      2004 1 0 1 1 0 0
                      1994 1 0 1 0 0 0
                      2006 1 0 1 1 0 0
                      2002 1 0 0 0 0 0
                      2012 1 0 . . 0 0
                      1982 1 0 . . . 0
                      1980 1 0 . . 0 0
                      2004 1 0 1 0 0 0
                      2006 1 0 . . . 0
                      2014 1 0 . . . 0
                      1988 1 0 1 1 0 0
                      2006 1 0 0 0 0 0
                      2002 1 0 1 0 0 0
                      2006 1 0 . . . 0
                      1996 1 0 . . . 0
                      1990 1 0 . . . 0
                      1990 1 0 1 1 0 0
                      2002 1 0 1 1 0 0
                      1990 1 0 1 1 0 0
                      1994 1 0 1 1 0 0
                      1992 1 0 . . . 0
                      2006 1 0 1 1 0 0
                      2012 1 0 . . . 0
                      2012 1 0 . . . 0
                      1984 1 0 . . . 0
                      2008 1 0 1 1 0 0
                      1998 1 0 1 0 0 0
                      2014 1 0 . . 0 0
                      2006 1 0 1 0 0 0
                      2012 1 0 . . 1 0
                      2006 1 0 1 1 0 0
                      2002 1 0 1 1 0 0
                      1982 1 0 1 1 0 0
                      1982 1 0 . . . 0
                      1992 1 0 . . . 0
                      1980 1 0 1 1 1 0
                      1982 1 0 1 0 1 0
                      1992 1 0 1 1 1 0
                      2006 1 0 . . . 0
                      2014 1 0 1 1 0 0
                      2014 1 0 . . 0 0
                      1984 1 0 1 . 1 0
                      2006 1 0 0 0 0 0
                      1980 1 0 1 0 0 0
                      1980 1 0 1 1 0 0
                      1996 1 0 1 0 0 0
                      1984 1 0 . . . 0
                      1994 1 0 1 1 0 0
                      1986 1 0 . . . 0
                      2002 1 0 . . 0 0
                      1996 1 0 0 0 1 0
                      1994 1 0 . . . 0
                      1980 1 0 0 0 0 0
                      2002 1 0 . . . 0
                      1986 1 0 1 1 0 0
                      1986 1 0 . . . 0
                      1986 1 0 1 1 0 0
                      1996 1 0 1 1 0 0
                      1998 1 0 . . . 0
                      1996 1 0 1 0 0 0
                      1986 1 0 1 1 0 0
                      2002 1 0 . . 0 0
                      2008 1 0 1 1 0 0
                      1998 1 0 1 0 0 0
                      1984 1 0 0 0 0 0
                      1988 1 0 1 1 0 0
                      1984 1 0 1 1 0 0
                      2004 1 0 1 1 0 0
                      1980 1 0 . . . 0
                      1986 1 0 1 1 0 0
                      2014 1 0 0 0 1 0
                      1986 1 0 . . . 0
                      2012 1 0 . . . 0
                      2010 1 0 0 0 0 0
                      2008 1 0 1 1 1 0
                      1980 1 0 1 1 0 0
                      2000 1 0 1 1 1 0
                      1994 1 0 1 1 1 0
                      1992 1 0 1 1 0 0
                      1994 1 0 . 0 1 0
                      1994 1 0 0 0 0 0
                      2004 1 0 0 0 0 0
                      1982 1 0 . . . 0
                      1980 1 0 1 1 0 0
                      1980 1 0 . . . 0
                      1990 1 0 1 . 1 0
                      2004 1 0 1 1 0 0
                      2000 1 0 1 1 0 0
                      2014 1 0 . . 0 0
                      1988 1 0 1 1 0 0
                      1990 1 0 1 1 0 0
                      1980 1 0 . . . 0
                      2008 1 0 . . 0 0
                      2012 1 0 1 1 0 0
                      1982 1 0 . . 0 0
                      1998 1 0 1 0 0 0
                      1998 1 0 1 1 1 0
                      1996 1 0 . . 0 0
                      1980 1 0 1 1 0 0
                      1984 1 0 . . . 0
                      2004 1 0 . . 0 0
                      1980 1 0 . . . 0
                      1986 1 0 . . . 0
                      2014 1 0 1 1 0 0
                      1984 1 0 1 1 1 0
                      1984 1 0 . . . 0
                      2014 1 0 0 0 0 0
                      2012 1 0 1 1 0 0
                      2006 1 0 0 0 0 0
                      1992 1 0 1 1 0 0
                      2006 1 0 . . . 0
                      2010 1 0 . . . 0
                      1982 1 0 . . 0 0
                      2004 1 0 . . . 0
                      1990 1 0 1 1 0 0
                      1998 1 0 . . . 0
                      1986 1 0 1 1 0 0
                      1980 1 0 1 0 0 0
                      2008 1 0 . . . 0
                      1990 1 0 1 0 0 0
                      1992 1 0 1 1 0 0
                      2012 1 0 0 0 0 0
                      2000 1 0 . . . 0
                      2000 1 0 . . 0 0
                      2014 1 0 1 0 0 0
                      2008 1 0 . . . 0
                      2000 1 0 1 0 0 0
                      1998 1 0 1 1 0 0
                      1990 1 0 . . . 0
                      1998 1 0 . . . 0
                      1980 1 0 1 1 0 0
                      2010 1 0 . . . 0
                      1990 1 0 1 1 0 0
                      1994 1 0 0 . 0 0
                      1992 1 0 1 1 0 0
                      1992 1 0 1 1 1 0
                      1988 1 0 . . . 0
                      2000 1 0 0 0 1 0
                      2000 1 0 1 1 0 0
                      1998 1 0 1 1 0 0
                      1990 1 0 1 1 0 0
                      1998 1 0 0 0 0 0
                      1986 1 0 . . . 0
                      1994 1 0 . . . 0
                      1992 1 0 1 1 0 0
                      1998 1 0 1 0 0 0
                      1988 1 0 . . . 0
                      2000 1 0 0 0 0 0
                      1992 1 0 1 1 0 0
                      2014 1 0 . . 0 0
                      1990 1 0 1 1 0 0
                      1998 1 0 1 0 0 0
                      1984 1 0 0 0 0 0
                      1988 1 0 1 1 0 0
                      1984 1 0 . . . 0
                      1986 1 0 1 1 0 0
                      1998 1 0 0 0 0 0
                      1984 1 0 1 1 0 0
                      1986 1 0 1 1 0 0
                      1996 1 0 1 0 0 0
                      1998 1 0 . . . 0
                      1990 1 0 . . . 0
                      1986 1 0 . . . 0
                      2008 1 0 1 1 0 0
                      1992 1 0 1 0 0 0
                      1994 1 0 1 1 0 0
                      2008 1 0 1 1 0 0
                      1982 1 0 1 0 0 0
                      1996 1 0 . . . 0
                      1984 1 0 . . 1 0
                      1986 1 0 . . . 0
                      2010 1 0 1 1 0 0
                      1984 1 0 . . . 0
                      1990 1 0 1 1 0 0
                      1998 1 0 1 1 0 0
                      1980 1 0 1 1 0 0
                      1994 1 0 1 1 0 0
                      2014 1 0 1 0 0 0
                      1998 1 0 . . 0 0
                      2002 1 0 0 0 0 0
                      2014 1 0 . . . 0
                      1994 1 0 0 0 1 0
                      2006 1 0 1 0 0 0
                      1998 1 0 1 0 0 0
                      2012 1 0 1 1 0 0
                      1984 1 0 0 0 1 0
                      1990 1 0 1 1 0 0
                      2006 1 0 1 0 0 0
                      1996 1 0 . . 0 0
                      1986 1 0 1 0 0 0
                      1990 1 0 . . . 0
                      1992 1 0 1 0 0 0
                      2010 1 0 1 1 0 0
                      1982 1 0 1 1 0 0
                      1984 1 0 . . . 0
                      2002 1 0 . . . 0
                      2010 1 0 . . . 0
                      1988 1 0 1 1 0 0
                      1984 1 0 0 0 1 0
                      1982 1 0 1 1 0 0
                      2014 1 0 0 0 1 0
                      1990 1 0 1 0 0 0
                      2014 1 0 1 0 0 0
                      2010 1 0 . . . 0
                      1980 1 0 1 1 0 0
                      1984 1 0 1 0 0 0
                      1998 1 0 . . . 0
                      2014 1 0 1 1 1 0
                      1980 1 0 1 1 0 0
                      1998 1 0 1 1 0 0
                      1984 1 0 . . . 0
                      1984 1 0 . . . 0
                      2004 1 0 1 1 0 0
                      2008 1 0 1 1 0 0
                      2002 1 0 1 1 0 0
                      2012 1 0 1 1 0 0
                      1984 1 0 . . . 0
                      1986 1 0 0 0 0 0
                      1996 1 0 1 1 0 0
                      1982 1 0 . . . 0
                      1984 1 0 . . . 0
                      2006 1 0 . . 0 0
                      2012 1 0 0 0 1 0
                      1994 1 0 . . . 0
                      1998 1 0 . . 0 0
                      2010 1 0 . . 0 0
                      1998 1 0 1 1 0 0
                      1992 1 0 1 0 0 0
                      2014 1 0 . . 0 0
                      1980 1 0 1 0 0 0
                      1990 1 0 1 1 0 0
                      2004 1 0 0 0 0 0
                      1994 1 0 . 0 1 0
                      2004 1 0 1 1 0 0
                      2014 1 0 1 1 0 0
                      1982 1 0 1 1 0 0
                      2010 1 0 1 0 0 0
                      2014 1 0 0 0 0 0
                      1990 1 0 . . . 0
                      1996 1 0 1 0 1 0
                      1982 1 0 . . . 0
                      1988 1 0 . . . 0
                      1984 1 0 1 1 0 0
                      2000 1 0 1 1 0 0
                      2004 1 0 1 1 0 0
                      2008 1 0 . . . 0
                      2006 1 0 . . 1 0
                      2008 1 0 . . . 0
                      2006 1 0 0 0 0 0
                      1980 1 0 0 0 1 0
                      2002 1 0 1 1 0 0
                      1994 1 0 1 1 0 0
                      1992 1 0 . . . 0
                      1980 1 0 1 . 0 0
                      1992 1 0 . . . 0
                      2012 1 0 1 1 0 0
                      1998 1 0 1 1 0 0
                      1980 1 0 1 1 0 0
                      2004 1 0 1 1 0 0
                      2002 1 0 1 1 0 0
                      2014 1 0 . . . 0
                      1980 1 0 . . . 0
                      2008 1 0 1 1 0 0
                      2008 1 0 . . . 0
                      1990 1 0 . . . 0
                      1984 1 0 1 1 0 0
                      2002 1 0 1 1 0 0
                      1984 1 0 . . . 0
                      1982 1 0 1 0 0 0
                      2012 1 0 1 1 0 0
                      2014 1 0 . . 1 0
                      1990 1 0 1 1 0 0
                      2002 1 0 0 0 0 0
                      1984 1 0 . . . 0
                      1982 1 0 . . . 0
                      1988 1 0 1 1 1 0
                      1980 1 0 . . . 0
                      1980 1 0 . . . 0
                      1980 1 0 1 1 0 0
                      1982 1 0 . . . 0
                      1994 1 0 1 1 0 0
                      1998 1 0 0 0 0 0
                      1982 1 0 . . . 0
                      1982 1 0 1 1 0 0
                      2010 1 0 1 1 0 0
                      2006 1 0 . . . 0
                      1990 1 0 . . . 0
                      2002 1 0 1 1 0 0
                      1980 1 0 0 0 1 0
                      2002 1 0 0 0 0 0
                      2002 1 0 1 1 0 0
                      1994 1 0 1 1 0 0
                      2002 1 0 . . . 0
                      2000 1 0 . . . 0
                      2014 1 0 1 1 0 0
                      2014 1 0 1 1 0 0
                      1980 1 0 . . . 0
                      1998 1 0 1 0 0 0
                      1998 1 0 1 1 0 0
                      1984 1 0 0 0 0 0
                      1986 1 0 1 1 0 0
                      1998 1 0 1 1 0 0
                      1986 1 0 1 1 0 0
                      2010 1 0 0 0 0 0
                      2004 1 0 1 1 0 0
                      1992 1 0 0 0 0 0
                      2010 1 0 . . . 0
                      2006 1 0 1 1 0 0
                      2006 1 0 . . 0 0
                      1982 1 0 1 1 0 0
                      1994 1 0 . . . 0
                      1996 1 0 . . . 0
                      1990 1 0 1 1 0 0
                      1980 1 0 . . . 0
                      1994 1 0 . . . 0
                      2006 1 0 . . 1 0
                      2004 1 0 1 1 0 0
                      2002 1 0 . . . 0
                      2002 1 0 1 1 0 0
                      2008 1 0 1 1 0 0
                      1982 1 0 1 0 1 0
                      2002 1 0 . . . 0
                      2012 1 0 1 1 0 0
                      2012 1 0 . . . 0
                      1980 1 0 1 1 0 0
                      1996 1 0 1 1 0 0
                      2012 1 0 . . . 0
                      1980 1 0 1 1 0 0
                      2002 1 0 . . . 0
                      1980 1 0 . . . 0
                      1980 1 0 . . . 0
                      2002 1 0 1 1 0 0
                      1986 1 0 . . . 0
                      1980 1 0 . . . 0
                      1980 1 0 . . . 0
                      1980 1 0 0 0 0 0
                      2004 1 0 . . . 0
                      2004 1 0 . . . 0
                      1990 1 0 1 . 0 0
                      1994 1 0 1 0 0 0
                      1984 1 0 1 1 0 0
                      1982 1 0 1 1 0 0
                      1984 1 0 1 1 0 0
                      1980 1 0 0 0 0 0
                      1984 1 0 0 0 0 0
                      2002 1 0 . . 0 0
                      2014 1 0 1 0 0 0
                      2004 1 0 1 1 0 0
                      2000 1 0 . . 0 0
                      2008 1 0 . . . 0
                      1992 1 0 . . . 0
                      1996 1 0 0 0 1 0
                      2006 1 0 . . 0 0
                      1986 1 0 0 0 1 0
                      2004 1 0 1 1 0 0
                      2012 1 0 . . . 0
                      1990 1 0 1 1 0 0
                      1994 1 0 . . . 0
                      1990 1 0 1 0 0 0
                      2008 1 0 . . 0 0
                      1994 1 0 . . . 0
                      1984 1 0 1 1 0 0
                      2014 1 0 1 0 0 0
                      2002 1 0 . . . 0
                      1988 1 0 0 0 0 0
                      1994 1 0 . . . 0
                      2012 1 0 1 1 0 0
                      1986 1 0 0 0 1 0
                      2014 1 0 0 0 0 0
                      2002 1 0 . . . 0
                      2006 1 0 . . . 0
                      1990 1 0 1 0 0 0
                      1988 1 0 . . . 0
                      2002 1 0 1 1 0 0
                      1984 1 0 . . 0 0
                      2010 1 0 1 1 0 0
                      2002 1 0 1 0 0 0
                      1980 1 0 1 1 0 0
                      1996 1 0 . . . 0
                      2012 1 0 1 1 0 0
                      1984 1 0 0 0 0 0
                      1984 1 0 . . . 0
                      2010 1 0 . . . 0
                      1988 1 0 . . 1 0
                      2002 1 0 . . . 0
                      1990 1 0 . . . 0
                      1982 1 0 0 0 1 0
                      2006 1 0 1 0 0 0
                      2006 1 0 . . . 0
                      2002 1 0 1 1 0 0
                      1994 1 0 1 0 0 0
                      2008 1 0 . . 0 0
                      2004 1 0 1 1 1 0
                      2000 1 0 1 1 0 0
                      2006 1 0 1 1 0 0
                      1980 1 0 0 0 1 0
                      2006 1 0 1 1 0 0
                      1994 1 0 1 0 0 0
                      1990 1 0 . . . 0
                      2000 1 0 . . 0 0
                      1980 1 0 0 0 0 0
                      2014 1 0 . . . 0
                      2004 1 0 1 1 0 0
                      1992 1 0 . . . 0
                      1990 1 0 1 1 0 0
                      1990 1 0 1 1 0 0
                      2008 1 0 1 1 0 0
                      1980 1 0 1 0 0 0
                      2010 1 0 1 1 0 0
                      1990 1 0 . . 1 0
                      1988 1 0 1 1 0 0
                      2002 1 0 . . . 0
                      1984 1 0 1 1 0 0
                      2010 1 0 1 1 0 0
                      1986 1 0 1 0 0 0
                      1980 1 0 1 1 0 0
                      1984 1 0 1 1 0 0
                      1994 1 0 1 0 0 0
                      1982 1 0 . . . 0
                      1982 1 0 1 1 0 0
                      1984 1 0 1 1 1 0
                      2002 1 0 . . . 0
                      1980 1 0 1 1 1 0
                      1998 1 0 0 0 0 0
                      1992 1 0 . . . 0
                      1982 1 0 . . . 0
                      1982 1 0 1 0 0 0
                      1982 1 0 1 1 0 0
                      1990 1 0 1 0 0 0
                      1998 1 0 . . . 0
                      1980 1 0 . . . 0
                      1982 1 0 1 0 0 0
                      2002 1 0 1 1 0 0
                      2002 1 0 . . . 0
                      1980 1 0 1 1 0 0
                      1980 1 0 1 1 0 0
                      1984 1 0 1 1 0 0
                      2010 1 0 1 1 0 0
                      2012 1 0 0 0 0 0
                      1980 1 0 0 0 1 0
                      1992 1 0 1 1 0 0
                      1986 1 0 . . . 0
                      1980 1 0 . . . 0
                      1982 1 0 . . . 0
                      1980 1 0 1 0 0 0
                      2010 1 0 . . 0 0
                      1990 1 0 . . . 0
                      1986 1 0 1 0 1 0
                      1982 1 0 0 0 1 0
                      1982 1 0 1 0 1 0
                      1988 1 0 1 1 0 0
                      2004 1 0 1 1 0 0
                      1990 1 0 1 1 0 0
                      2014 1 0 1 1 0 0
                      2012 1 0 0 0 1 0
                      2002 1 0 1 1 0 0
                      2006 1 0 1 1 0 0
                      1980 1 0 . . . 0
                      2000 1 0 . . . 0
                      1992 1 0 1 1 0 0
                      2002 1 0 . . . 0
                      1990 1 0 0 0 0 0
                      1996 1 0 1 0 1 0
                      1986 1 0 1 0 0 0
                      2002 1 0 . . . 0
                      1992 1 0 . . 0 0
                      2002 1 0 . . 0 0
                      1996 1 0 1 1 0 0
                      1996 1 0 1 1 0 0
                      1980 1 0 0 0 0 0
                      2002 1 0 . . . 0
                      1992 1 0 0 0 0 0
                      1992 1 0 1 1 0 0
                      1986 1 0 . . . 0
                      1988 1 0 1 0 0 0
                      1994 1 0 0 0 0 0
                      1980 1 0 0 0 0 0
                      1988 1 0 1 1 0 0
                      1996 1 0 . . . 0
                      2008 1 0 1 1 0 0
                      2004 1 0 1 1 0 0
                      1986 1 0 0 0 1 0
                      2004 1 0 . . 0 0
                      2014 1 0 . . 0 0
                      1986 1 0 1 1 0 0
                      2002 1 0 1 0 0 0
                      2014 1 0 1 1 0 0
                      2002 1 0 0 0 0 0
                      end
                      label values statefip STATEFIP
                      label def STATEFIP 1 "alabama", modify
                      I don't know how to show you what you ask, the point is that I have about 2512032 observations, so, I don't know how to show you more samples. If I open the Data Editor (Browse) the data relating to the years are arranged in chronological order from 1980 to 2014 (our reference years).
                      More, I generated the dummy pre_reg=1 for the states which have approved preregistration law. From here, the variable - ps - , another dummy, takes on value 1 if the state has ever implemented preregistration. So, opening the Data Editor (Browse) I should see that both variables have the same value, in the sense that if pre_reg = 1, then automatically ps = 1 too, correct? I ask you because if my reasoning is correct, then yes, there is a problem with these variables.

                      Comment


                      • #26
                        OK, this data looks unsuitable for the model you are trying to use, and perhaps unsuitable for your problem.

                        You originally described a data set in which the variable pre_reg was 1 for a year-state combination when that state had already adopted pre-registration by that year, and 0 for earlier years. And the code you show on how you generated looks like that. But in the example (which encompasses only one state), pre-reg is the same for all years. You need some variable that works like what you described originally: we have to know for each state which years have pre-registration in place and which do not. Also, the absence of that information makes it impossible to correctly generate the variable showing the number of years since implementation, which is another indispensable variable for this analysis. If you have variables that work like that, please show them. Also it would be helpful to have data that includes at least one state with pre-registration (and years both before and after) and at least one state that never had pre-registration. You can select out perhaps just a dozen individual observations for each such state and year you show--that would be more helpful than 500 observations all from one state. If you don't have any variables that work like that, then you are going to have to go back to your original data sources and get them.

                        Comment


                        • #27
                          I don't know how to show you with the command -dataex- the examples you asked me. However, I show you a first part of the database that I used to build the preregistration variable whihch takes on value 1 only for the States that have introduced preregistration including the year of law introduction (i.e. California, Colorado, Delaware, etc..) I assumed that the dummy assumed a value equal to zero for states other than those listed. Is this setting incorrect?

                          Code:
                          gen pre_reg=1 if statefip==6 & year>= 2009 /*California*/
                          replace pre_reg=1 if statefip==8 & year>=2013 /*Colorado*/
                          replace pre_reg=1 if statefip==10 & year>=2010 /*Delaware*/ 
                          replace pre_reg=1 if statefip==11 & year>=2009 /*DC*/
                          replace pre_reg=1 if statefip==12 & year>=2007 /*Florida*/
                          replace pre_reg=1 if statefip==22 & year>=2014 /*Louisiana*/ 
                          replace pre_reg=1 if statefip==23 & year>=2011 /*Maine*/    
                          replace pre_reg=1 if statefip==24 & year>=2010 /*Maryland*/
                          replace pre_reg=1 if statefip==25 & year>=2014 /*Massachusetts*/
                          replace pre_reg=1 if statefip==37 & year>=2009 & year<2013/*North Caroline*/
                          replace pre_reg=1 if statefip==41 & year>=2007 /*Oregon*/
                          replace pre_reg=1 if statefip==44 & year>=2010 /*Rhode Island*/
                          replace pre_reg=1 if statefip==49 & year>=2015 /*Utah*/
                          replace pre_reg=1 if statefip==15 & year>=1993 /*Hawaii*/
                          replace pre_reg=1 if statefip==34 & year>=2016 /*New Jersey*/
                          replace pre_reg=0 if pre_reg==.
                          If I use my original dataset (without creating variables) and try to report the data with -dataex-, I get what I show you in #23, while, after having generated the dataset, using the -dataex- command I can show you what I did in #25.
                          The biggest problem is creating the event time dummy.

                          Comment


                          • #28

                            I think the dataset built so far is correct. What needs to be fixed is the part of the model in # 1 relating to the variable -Ps- (which in my opinion has been defined correctly by you), then the variable Ts is missing to fix and, consequently, the event dummy variable as in model in # 1 given by 1 * (t - Ts = t).
                            Code:
                            /*Variable Ps*/
                            by statefip, sort: egen ps = max(pre_reg)
                            
                            /*EVENT-TIME DUMMY */
                            by statefip, sort: egen year_first_post_implement = min(cond(pre_reg, year, .))
                            gen years_since_implement = year - year_first_post_implement
                            replace years_since_implement = max(min(year_first_post_implement, 3), -5)
                            This was our starting point...

                            Comment


                            • #29
                              OK, I think I see the problem. When a state never adopts pre-registration, year_first_post_implement will have a missing value, and then year_since_implement will be incorrectly calculated as 3. In fact, it isn't clear what year_since_implement should be, because we don't know when or even whether that state will ever implement pre-registration. However, there is a way out of this dilemma in this case because the model you are using says that anything more than 5 years before implementation is to be coded as -5. We can treat those states that never implement pre-registration as never implementing it, which means that they are at least 5 years before implementation, so year_first_post_implement should be -5. So I would change the code in #28 by adding one more command:
                              Code:
                              /*EVENT-TIME DUMMY */
                              by statefip, sort: egen year_first_post_implement = min(cond(pre_reg, year, .))
                              gen years_since_implement = year - year_first_post_implement
                              replace years_since_implement = max(min(year_first_post_implement, 3), -5)
                              replace years_since_implement = -5 if ps == 0
                              Now, this will create a new problem that I hadn't noticed up to this point. You won't be able to use factor-variable notation with this variable, because it has negative values. So we have to create a new variable parallel to it that is always non-negative, and label the values of that variable with numbers from -5 to 3 to make the outputs read in a sensible way.

                              Code:
                              gen event_time_var = years_since_implement + 5
                              label define event_time_var  0 "-5" 1 "-4" 2 "-3" 3 "-2" 4 "-1" 5 "0" 6 "1" 7 "2" 8 "3"
                              label values event_time_var event_time_var
                              Then your regression will look like this:
                              Code:
                              regress register i.ps##i.event_time_var ... // ADDITIONAL COVARIATES AND OPTIONS AS APPROPRIATE

                              Comment


                              • #30
                                Code:
                                . regress register i.age18_24##i.ps##i.event_time_var i.age18_24 i.statefip i.year, cluster(statefip) 
                                note: 8.event_time_var omitted because of collinearity
                                note: 1.age18_24#8.event_time_var omitted because of collinearity
                                note: 0b.ps#8.event_time_var identifies no observations in the sample
                                note: 1.ps#0b.event_time_var identifies no observations in the sample
                                note: 1.ps#8.event_time_var omitted because of collinearity
                                note: 0b.age18_24#0b.ps#8.event_time_var identifies no observations in the sample
                                note: 0b.age18_24#1.ps#0b.event_time_var identifies no observations in the sample
                                note: 1.age18_24#0b.ps#8.event_time_var identifies no observations in the sample
                                note: 1.age18_24#1.ps#0b.event_time_var identifies no observations in the sample
                                note: 1.age18_24#1.ps#8.event_time_var omitted because of collinearity
                                note: 44.statefip omitted because of collinearity
                                
                                Linear regression                               Number of obs     =  1,350,537
                                                                                F(17, 50)         =          .
                                                                                Prob > F          =          .
                                                                                R-squared         =     0.0497
                                                                                Root MSE          =      .4112
                                
                                                                            (Std. Err. adjusted for 51 clusters in statefip)
                                --------------------------------------------------------------------------------------------
                                                           |               Robust
                                                  register |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                                ---------------------------+----------------------------------------------------------------
                                                1.age18_24 |  -.2249381   .0062449   -36.02   0.000    -.2374813   -.2123949
                                                      1.ps |  -.0083219   .0013291    -6.26   0.000    -.0109914   -.0056524
                                                           |
                                               age18_24#ps |
                                                      1 1  |  -.0091953   .0112757    -0.82   0.419    -.0318431    .0134525
                                                           |
                                            event_time_var |
                                                        3  |          0  (omitted)
                                                           |
                                   age18_24#event_time_var |
                                                      1#3  |          0  (omitted)
                                                           |
                                         ps#event_time_var |
                                                      0#3  |          0  (empty)
                                                     1#-5  |          0  (empty)
                                                      1#3  |          0  (omitted)
                                                           |
                                age18_24#ps#event_time_var |
                                                    0#0#3  |          0  (empty)
                                                   0#1#-5  |          0  (empty)
                                                    1#0#3  |          0  (empty)
                                                   1#1#-5  |          0  (empty)
                                                    1#1#3  |          0  (omitted)
                                                           |
                                                  statefip |
                                                   alaska  |   .0316096   .0001861   169.87   0.000     .0312358    .0319833
                                                  arizona  |  -.0921782    .000166  -555.43   0.000    -.0925116   -.0918449
                                                 arkansas  |  -.0869373   .0001295  -671.11   0.000    -.0871975   -.0866771
                                               california  |  -.0242656   .0007779   -31.20   0.000    -.0258279   -.0227032
                                                 colorado  |  -.0086523   .0002581   -33.52   0.000    -.0091707   -.0081338
                                              connecticut  |  -.0024957   .0008899    -2.80   0.007    -.0042832   -.0007083
                                                 delaware  |  -.0284968   .0001877  -151.80   0.000    -.0288739   -.0281198
                                     district of columbia  |   .0372218   .0002308   161.25   0.000     .0367582    .0376855
                                                  florida  |  -.0343185   .0009773   -35.12   0.000    -.0362814   -.0323555
                                                  georgia  |  -.0682481   .0004501  -151.63   0.000    -.0691521   -.0673441
                                                   hawaii  |  -.1152938   .0003116  -369.95   0.000    -.1159197   -.1146678
                                                    idaho  |  -.0594001   .0001315  -451.68   0.000    -.0596642   -.0591359
                                                 illinois  |   .0049695   .0004685    10.61   0.000     .0040286    .0059105
                                                  indiana  |  -.0633367   .0002442  -259.31   0.000    -.0638272   -.0628461
                                                     iowa  |    .001069   .0004155     2.57   0.013     .0002345    .0019035
                                                   kansas  |  -.0522368   .0002971  -175.79   0.000    -.0528337     -.05164
                                                 kentucky  |  -.0456275   .0004077  -111.91   0.000    -.0464464   -.0448085
                                                louisiana  |   .0263448   .0009003    29.26   0.000     .0245365    .0281531
                                                    maine  |   .0755742   .0000845   894.81   0.000     .0754046    .0757438
                                                 maryland  |  -.0085381   .0002228   -38.33   0.000    -.0089856   -.0080907
                                            massachusetts  |   .0287005   .0019257    14.90   0.000     .0248326    .0325684
                                                 michigan  |   .0447362   .0007579    59.03   0.000     .0432139    .0462586
                                                minnesota  |   .0785343   .0007496   104.77   0.000     .0770288    .0800398
                                              mississippi  |   .0329007   .0003172   103.72   0.000     .0322636    .0335379
                                                 missouri  |   .0052358   .0003405    15.38   0.000     .0045518    .0059198
                                                  montana  |  -.0114018   .0001945   -58.63   0.000    -.0117924   -.0110112
                                                 nebraska  |  -.0261373    .000257  -101.70   0.000    -.0266535   -.0256211
                                                   nevada  |  -.1397143   .0006095  -229.25   0.000    -.1409384   -.1384901
                                            new hampshire  |   -.042164   .0013075   -32.25   0.000    -.0447901   -.0395379
                                               new jersey  |  -.0113817   .0009331   -12.20   0.000    -.0132559   -.0095074
                                               new mexico  |  -.0721193   .0002695  -267.60   0.000    -.0726606    -.071578
                                                 new york  |    -.03612   .0006343   -56.94   0.000     -.037394    -.034846
                                           north carolina  |   -.044337    .001614   -27.47   0.000    -.0475789   -.0410951
                                             north dakota  |   .1253417   .0001731   724.06   0.000      .124994    .1256894
                                                     ohio  |  -.0356793   .0005732   -62.24   0.000    -.0368307   -.0345279
                                                 oklahoma  |  -.0593152   .0000955  -621.16   0.000     -.059507   -.0591234
                                                   oregon  |   .0276555    .000424    65.22   0.000     .0268038    .0285072
                                             pennsylvania  |  -.0806426   .0005117  -157.60   0.000    -.0816703   -.0796149
                                             rhode island  |          0  (omitted)
                                           south carolina  |  -.0812986    .000303  -268.33   0.000    -.0819072   -.0806901
                                             south dakota  |   .0117975   .0001766    66.79   0.000     .0114427    .0121523
                                                tennessee  |  -.0654777   .0002082  -314.53   0.000    -.0658959   -.0650596
                                                    texas  |  -.0539844   .0001757  -307.22   0.000    -.0543373   -.0536314
                                                     utah  |  -.0481535   .0002549  -188.92   0.000    -.0486654   -.0476415
                                                  vermont  |   .0053522   .0007814     6.85   0.000     .0037827    .0069216
                                                 virginia  |  -.0497081   .0003068  -162.00   0.000    -.0503244   -.0490918
                                               washington  |  -.0201485   .0005338   -37.75   0.000    -.0212205   -.0190764
                                            west virginia  |  -.0883677   .0001171  -754.83   0.000    -.0886029   -.0881326
                                                wisconsin  |   .0473683   .0003762   125.90   0.000     .0466126     .048124
                                                  wyoming  |  -.0743835   .0005861  -126.91   0.000    -.0755608   -.0732063
                                                           |
                                                      year |
                                                     1984  |   .0452469   .0048043     9.42   0.000     .0355972    .0548966
                                                     1986  |   .0006357   .0046805     0.14   0.893    -.0087653    .0100368
                                                     1988  |   .0245447   .0060274     4.07   0.000     .0124383     .036651
                                                     1990  |   -.006067   .0060127    -1.01   0.318     -.018144    .0060099
                                                     1992  |   .0547182   .0061069     8.96   0.000     .0424522    .0669843
                                                     1994  |  -.0053187   .0066643    -0.80   0.429    -.0187044    .0080671
                                                     1996  |   .0416648   .0073178     5.69   0.000     .0269666     .056363
                                                     1998  |    .013008    .007825     1.66   0.103    -.0027091     .028725
                                                     2000  |   .0571259   .0078443     7.28   0.000     .0413701    .0728816
                                                     2002  |   .0240823   .0086177     2.79   0.007     .0067732    .0413914
                                                     2004  |   .0875308   .0078449    11.16   0.000     .0717739    .1032876
                                                     2006  |   .0497992   .0088804     5.61   0.000     .0319625    .0676359
                                                     2008  |   .0989303    .009027    10.96   0.000     .0807991    .1170616
                                                     2010  |    .053601   .0086679     6.18   0.000      .036191     .071011
                                                     2012  |   .0939039   .0094974     9.89   0.000     .0748279      .11298
                                                     2014  |   .0482743   .0096679     4.99   0.000     .0288557    .0676929
                                                           |
                                                     _cons |   .7826052   .0058719   133.28   0.000     .7708111    .7943993
                                --------------------------------------------------------------------------------------------
                                
                                . 
                                end of do-file
                                This seems to be very similar to what I should be getting but I still have problems as I am showing you.
                                Since the age of an individual is a dimension along which the treatment varies, along with time and space, we first split the set of individuals into two age groups: the young and the old. For each of them, we then use a difference-in-differences (hereafter DD) regression design, which compares electoral outcomes for individuals in states with preregistration and states without before and after voting reform is introduced.

                                Comment

                                Working...
                                X