Announcement

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

  • Problems when generating dummy

    Hello everybody,
    I am new to Stata, but I need to use it for my bachelor thesis. I have recently come across a problem with my code in which I am trying to create a dummy value if one country is part of the eurozone in order to see the effects of a monetary union on trade. I am using the CEPII gravity database plus the years in which the eurozone countries have adopted the euro. Both the time variables are correct yet when I try to do the following code
    "gen EMU_one_sided = ((eurozone_join_o <= year & eurozone_join_d > year) | (eurozone_join_d <= year & eurozone_join_o > year))" I only get 0s.

    I have also tried to do it using this:

    "gen eurozone_o = eurozone_join_o <= year
    gen eurozone_d = eurozone_join_d <= year
    gen EMU_one_sided = (eurozone_o != eurozone_d)"

    Does anyone knows what I am doing wrong or what I can do in order to get a normal variation since there have to be countries that are in the eurozone trading with non-members.

    (I have replaced all the missing values for the eurozone_join_o and eurozone_join_d variables with 2042 for countries not part of the eurozone)
    Last edited by Angela Cojoc; 26 Nov 2024, 11:42.

  • #2
    With,

    gen EMU_one_sided = ((eurozone_join_o <= year & eurozone_join_d > year) | (eurozone_join_d <= year & eurozone_join_o > year))

    the second part is exactly the opposite of the first, and you've used "or".

    how are these variables defined? eurozone_join_o , eurozone_join_d


    Comment


    • #3
      So eurozone_join_o is the year when the origin country adopted the euro and eurozone_join_d is. the year for the destination country. Both are int
      And yes I used or because I have already done the analysis for both countries being a part of the eurozone at the same time. So i am only interestedin either the origin or destination country being in the eurozone

      Eurozone_join_o and eurozone_join_d are the same it was just easier to duplicate it
      Last edited by Angela Cojoc; 26 Nov 2024, 12:11.

      Comment


      • #4
        Code:
        gen eurozone_o = year  >= eurozone_join_o  // (1 if orig)
        gen eurozone_d = year > = eurozone_join_d  // (1 if dest)
        g eurozone_both = eurozone_o + eurozone_d  == 2 // (1 if both)
        g eurozone_one_side = eurozone_o + eurozone_d == 1 // 1 if only one is eurozone
        g eurozone_niether = eurozone_o + eurozone_d == 0  // 1 if neither in eurozone
        g eurozone_o_not_d = eurozone_o==1 & eurozone_d == 0  
        g eurozone_d_not_o = eurozone_o==0 & eurozone_d == 1
        Last edited by George Ford; 26 Nov 2024, 12:15.

        Comment


        • #5
          the eurozone_one_side is still just 0s
          Attached Files

          Comment


          • #6
            tab2 eurozone_o eurozone_d

            Comment


            • #7
              Click image for larger version

Name:	Screenshot 2024-11-26 at 19.52.47.png
Views:	1
Size:	90.3 KB
ID:	1768348does this look right?

              Comment


              • #8
                It's telling you why one-sided is always zero.

                If one-sided is not always zero (in reality), then there's a problem with the variables used to construct eurozone_o/d.

                Comment


                • #9
                  yes at first I also thought there was something wrong with the eurozone_join variables but they look fine when i tabulate them
                  Click image for larger version

Name:	Screenshot 2024-11-26 at 20.14.12.png
Views:	1
Size:	193.4 KB
ID:	1768353

                  Comment


                  • #10
                    switch 2042 to -999. it's catching the 2042 as specified.

                    Comment


                    • #11
                      It worked now! Thank you very much!!

                      Comment

                      Working...
                      X