Announcement

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

  • Link Individuals to daily dates.

    Hi fellows, I have a paneldataset of 56.000 rows and I am trying to implement a DiD regression including fixed effects.

    My problem is that I have daily output data for 20 banks over a time period of 10 years. I am struggling with connecting the individual banks to their timeperiods.
    The image displays the Bankid (no. 12) the DealAmount and the daily dates.

    I have 20 banks and examine the daily output for 10 years as seen in the example.

    I tried the following code, but honestly I do not really know how this works and where this leads me to.

    egen id = seq()
    replace id=id-1
    gen id_temp=id/7
    drop id_temp
    egen id2=anymatch(id_temp), values(0(1)999)
    gen id3 =id_temp if id2==1
    replace id3=id3[_n-1] if missing(id3)
    egen year=seq(), by (id3)
    rename id3 persod
    drop id_temp
    drop id2
    xtset persod year
    xtreg DealAm TotalA i.year, fe cluster(persid)

    Much appreaciate your help guys and girls.



    Click image for larger version

Name:	Unbenannt.png
Views:	1
Size:	598.9 KB
ID:	1638999

  • #2
    updated image. Sorry for that
    Click image for larger version

Name:	Unbenannt1.png
Views:	1
Size:	169.0 KB
ID:	1639001

    Comment


    • #3
      This question is probably impossible to address unless it's revised to be compliant with the FAQ (http://www.statalist.org/forums/help), particularly on using -dataex- to post the data in code form rather than in image form. It's very easy:

      Code:
      sysuse auto, clear
      
      * To export 20 cases for variables mpg price and weight:
      dataex price mpg weight, count(20)
      And then post the results from the output, from CODE to /CODE

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input int(price mpg weight)
       4099 22 2930
       4749 17 3350
       3799 22 2640
       4816 20 3250
       7827 15 4080
       5788 18 3670
       4453 26 2230
       5189 20 3280
      10372 16 3880
       4082 19 3400
      11385 14 4330
      14500 14 3900
      15906 21 4290
       3299 29 2110
       5705 16 3690
       4504 22 3180
       5104 22 3220
       3667 24 2750
       3955 19 3430
       3984 30 2120
      end
      Do that twice, once for your bank data, once for your trading data. List only the variables that are involved in the merging. With those codes users here can create data sets and test their codes. It'd be easier for everyone to continue the dialogue that way.

      Also, the codes posted in #1 do not make much immediate sense, it'd be great if you can add a bit of verbal description on what you'd like to achieve.
      Last edited by Ken Chui; 01 Dec 2021, 09:27.

      Comment


      • #4
        Hejo Ken, thank you very much for the reply. Since I am new I much appreciate any instruction on how to behave correct on this forum.
        I entered the code, as seen below. Hope this is more helpful.

        What I did in the beginning is setting up a group variable for the individual banks (bankid). Then I included treatment variables for treatment- and controlgroup.
        Eventually I wanted to implement fixed effects for the variable DealAm, because the dealamounts of a banks might be biased.

        In order to implement fixed effects I tried to set each year from 2010-2019 to the individuall bankid.

        For example Bankid Year
        1 2010
        2011
        2012
        ....
        2019
        2 2010
        2011
        2012
        ....
        2019


        12 2010
        2011
        ....
        2019



        My problem is that, besidedes multicollinearity, that I have daily outcome dates and between 1000-5000 rows per bankid.
        What I need to do is link the bankid to individuall dates between 2010-2019. Not annualy but daily.



        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input double DealAm int(Date Year1) float bankid
        8.900e+08 18288 2010 12
        8.900e+08 18288 2010 12
        7.800e+09 18291 2010 12
        7.800e+09 18291 2010 12
        7.800e+09 18291 2010 12
        2.500e+10 18305 2010 12
        2.500e+10 18305 2010 12
        2.500e+10 18305 2010 12
        2.500e+10 18305 2010 12
        2.500e+10 18305 2010 12
        2.100e+09 18308 2010 12
        2.100e+09 18308 2010 12
        2.100e+09 18308 2010 12
        3.500e+08 18311 2010 12
        5.000e+09 18319 2010 12
        5.000e+09 18319 2010 12
        5.000e+09 18319 2010 12
        3.018e+09 18326 2010 12
        3.018e+09 18326 2010 12
        3.018e+09 18326 2010 12
        end
        format %tdnn/dd/CCYY Date

        Comment


        • #5
          Thanks for the post. To be very honest I am still very lost. You mentioned that there is something to be linked, but I only saw that one file with daily data already.

          If you meant that you wanted to create an empty daily series that runs from 2010 to 2019, for twelve times, one for each of the twelve banks. Then you can set up that series using this code:

          Code:
          clear
          set obs 3652
          gen date = mdy(12,31,2009) + _n
          format date %td
          
          expand 12
          
          bysort date: gen bankid = _n
          gsort bankid date
          But again, I am not sure if that is what you want. Your question kept hinting that there is another data set that is not daily, but I couldn't see that.

          Sorry, could be me being too tired.

          Comment


          • #6
            I don't understand the problem. If you can make the panel dataset, unless I'm missing something, isn't this just a 1:1 merge problem? Your unit and time ID's can just be merged together.

            Comment

            Working...
            X