Announcement

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

  • Difference in Difference Analysis Using Panel and Time Series Data

    I am trying to conduct difference in difference analysis. I want to look at whether bank holding company's (bhc) providing a certain type of loan can reduce overall credit enhancements, proposing that lending this type of loan has a greater impact on credit enhancements of small BHCs compared to large BHCs. I am looking at a period between 2019Q1 and 2020Q3 and have set up panel data in this way. I have created a loan dummy (PPP) which takes the value of 1 if a BHC has a balance of these loans outstanding greater than 0 (therefore providing the loans) and 0 otherwise. I have also created a treated group in which the dummy variable takes the value 1 if the BHC falls in the bottom 75% of my sample (qualifying as small). Finally I have created my DiD estimator by using the command:

    gen PPPBHC = PPP*BHC

    I am extremely new to Stata and do not know where to go from here. I want to create a vector 'X' (for example) which is a vector of all explanatory factors at BHC level. I have collected these and are shown in my data sample such as ROA, UC etc.

    I have read through the guides and have managed to set up my panel data using:

    xtset bhcid quarter

    But I need some guidance as to how to create this explanatory vector in which the majority of my variables are included - I would like to lag all these by one quarter to mitigate reverse causality issues. I would also like to control for BHC and time fixed effects. I know I need to create quarterly dummies as my dependent variable is the quarterly change which I believe I can do by using the command:

    i.quarter

    Other than this I am unsure of how to execute my desired regression, any help on this would be appreciated.

    input int bhcid double assets long uc float(leverage roa risk dr sa) long(ce pppbal) float(quarter logassets BHC PPP)
    135 10059165 1595813 .1934232 .008206502 .911175 .019205164 133.4364 0 0 241 16.123995 1 0
    146 10084886 1323122 .1400699 .001810943 .8175479 .003649191 4.6193156 0 . 240 16.126549 1 0
    132 10144014 34193 .0964483 .001811249 .8403483 .00238113 13.172705 0 . 236 16.132395 1 0
    135 10168560 125654 .19831324 .008832491 .8679075 .004936665 53.69326 0 0 242 16.134811 1 0
    144 10170960 598833 .04209426 .00600147 .6255334 .006011625 10.706806 0 . 238 16.135048 1 0
    131 10214189 2250303 .14253192 .004747283 .8005214 .003098738 5.274777 0 . 236 16.139288 1 0
    136 10335774 432854 .10949872 .005860043 .7154263 .004595784 11.001625 0 125773 241 16.151121 1 1
    140 10339817 1736538 .1530442 .01677197 .5230162 .000723009 1.8082997 0 703117 241 16.151512 1 1
    130 10415970 2203730 .12637095 .003086504 .7789994 .008919548 4.1620674 0 . 236 16.158852 1 0
    142 10470261 1350219 .11341389 .010235881 .918959 .001527983 5.141767 0 . 238 16.16405 1 0
    145 10499696 970167 .1342738 .002088878 .7538101 .006503489 12.3569 321828 . 240 16.166857 1 0
    146 10513539 692292 .13415168 .003473649 .8007044 .001537909 3.956913 0 400316 241 16.168175 1 1
    139 10539628 1294185 .1191413 .00976769 .6993737 .000930493 2.777986 0 746431 242 16.170652 1 1
    140 10567652 1157496 .1532508 .02543294 .53413665 .000674176 1.8284714 0 703731 242 16.173307 1 1
    130 10633873 642428 .12540944 .00618653 .7817224 .003138513 4.0622888 0 . 237 16.179556 1 0
    130 10638226 867203 .12720965 .013334362 .7784908 .007181913 4.930581 -809019 . 239 16.179964 1 0
    136 10669451 1949744 .1077182 .007398844 .7159722 .0000315485 10.53928 0 . 242 16.182896 1 0
    130 10736134 825527 .12590845 .010155145 .7781742 .003161542 4.335874 256247 . 238 16.189125 1 0
    131 10737857 1744259 .13984504 .009406575 .7907712 .001942605 5.55529 0 . 237 16.189285 1 0
    128 10745388 801280 .16839875 .014313055 .56465137 .004814412 2.656112 0 . 237 16.189987 1 0
    130 10798603 615752 .12425607 .000946759 .7765314 .008276191 4.649884 552772 . 240 16.194927 1 0
    139 10835965 984700 .11407235 .005568228 .6823329 .000704087 2.6541524 0 749429 241 16.198381 1 1
    143 10847184 574232 .1053409 .004556143 .7098354 .002690297 2.4598775 0 524654 241 16.199415 1 1
    143 10850212 1218804 .10747357 .009086992 .7119371 .002241861 2.390374 0 525833 242 16.199696 1 1
    129 10875561 1126089 .0955799 .004949365 .7212164 .002763359 5.209956 -1793222 . 236 16.202028 1 0
    128 10916467 464271 .16096124 .006974394 .55017525 .004919053 2.6686196 0 . 236 16.205784 1 0
    136 10998320 1712900 .09827874 .002850076 .7137742 .000466044 13.211247 0 119944 240 16.213253 1 1
    148 11012195 99753000 .0830067 .009608653 .7109377 .000657153 3.1094434 0 1045356 241 16.214514 1 1
    125 11171583 1241489 .17335744 .012273373 .773982 .000044057 1.4353052 0 . 237 16.228884 1 0
    132 11182548 2402269 .08865645 .002588602 .8544877 .001012514 22.897346 0 . 237 16.229864 1 0
    129 11220238 287793 .09563523 .009735245 .7273983 .002997382 6.572628 1832127 . 237 16.23323 1 0
    126 11278499 0 .10778996 .004064806 .7808282 .009578915 8.444398 0 . 236 16.238409 1 0
    125 11282450 1169545 .17674334 .023900155 .7707222 .000218518 1.4421033 0 . 239 16.238758 1 0
    125 11304957 1054715 .1672653 .005941855 .7687977 .000157095 1.4918864 0 . 236 16.240751 1 0
    124 11312495 1232268 .12129084 .003680407 .7565105 .004724736 2.3524816 0 . 236 16.241419 1 0
    123 11332739 1815459 .13192733 .003316723 .877019 .003529479 23.95806 0 . 236 16.243206 1 0
    125 11332762 1122097 .17355813 .018178932 .7598674 .000190408 1.3917003 0 . 238 16.243208 1 0
    145 11356793 534157 .13000448 .004444153 .6968511 .001717616 13.68709 0 479101 241 16.245327 1 1
    148 11394874 2075458 .08329087 .014548317 .7153498 .000515473 3.087441 0 1053016 242 16.248674 1 1
    141 11402982 1608835 .1497979 .018118957 .7994525 .000634785 3.309753 0 . 239 16.249386 1 0
    128 11410295 526581 .1625929 .025335895 .5840257 .005928151 2.7944434 0 . 239 16.250027 1 0
    123 11508089 1762001 .13886519 .010335237 .8732219 .002798078 22.960016 0 . 238 16.25856 1 0
    132 11520717 2239355 .09138276 .007706449 .893485 .003370088 25.23601 0 . 239 16.259657 1 0
    123 11521429 1969698 .13467592 .006707262 .8801816 .003495518 27.63793 0 . 237 16.25972 1 0
    141 11540121 1704311 .14578044 .0129758 .7860037 .000781989 3.227599 0 . 238 16.261341 1 0



  • #2
    You don't have to "create a vector" to do this in Stata. Stata's regression commands will create all the matrices and vectors it needs to do the regression for you: you just have to tell it which variables you want to use.

    Also, unless you are using an ancient version of Stata, you do not need to (and should not) create that PPPBHC variable--with factor-variable notation (see -help fvvarlist-) Stata can create it for you automatically, and then you will be able to use the -margins- command after your regression to enable you to more easily interpret your results.

    I'm going to guess that your outcome variable, "credit enhancements" is the one called ce.
    Your commands will look something like this:

    Code:
    xtset bhcid quarter
    xtreg ce i.BHC##i.PPP list_your_explanatory_variables_here, fe
    I cannot illustrate this code with the example you provided because in that example BHC = 1 in all observations, so no regression is possible. I also notice that there is massive colinearity among the variables other than ce, BHC, and PPP in your data--you will want to look into that before proceeding.

    Note: You should expect to get a message with your regression output that the variable 1.BHC is omitted due to colinearity: that's because it will be constant within panels defined by bhc_id. But that's not a problem.* Your DID effect estimator is the coefficient of 1.BHC#1.PPP which will not be omitted. (If Stata omits it, then there is a problem with your data having not all combinations of BHC and PPP are instantiated.)

    *In fact, it's a problem if you don't get that message. It would mean that some bhcid is inconsistently coded BHC = 0 in some observations but BHC = 1 in others.

    Comment


    • #3
      Thank you very much for your explanation.

      I had been advised to create the DiD interaction by my professor, however I will try this other command in place of my initial attempt.

      I also see that no regression was possible due to my confusion with the creation of my dummy variables. I have amended my regression to create a time dummy PPP indicating the period in which the loans were available and BHC which is my dummy to indicate whether a BHC is small or large.

      I ran the following command for my regression, after setting up my data with any BHC explanatory factors lagged by one period, including a quarterly time dummy - as advised by my professor.

      Code:
      xtreg ce d_PPP d_BHC PPPBHCini uc_L1 leverage_L1 roa_L1 risk_L1 dr_L1 sa_L1 logassets_L1 pppno  pppbal i.d_quarter, fe robust
      However, as you stated previously I have an issue with the majority of my variables being omitted due to collinearity - all except for ce, the number of outstanding loans and the balance of outstanding loans. As you predicted it even omitted my interaction term.

      Do you know if there is anyway to overcome this issue please?

      Comment


      • #4
        Do you know if there is anyway to overcome this issue please?
        I did a matrix of correlation plots among the variables. uc and sa are very weird, to say the least. Look into those there is either something very wrong with them, or the relationship between them is bizarre. As to why that would be the case, I have no idea. I don't even know what uc and sa are supposed to be. And if I did, it probably wouldn't help me because I don't work in your domain.

        Comment


        • #5
          Thank you very much for the advice, I will look into these and potentially look at ways of measuring these variables differently/check the data I have to ensure I haven't made an error with the collection of these.

          When adapting the model I noticed that no collinearity was observed between my variables when ran the regression removing the lag on all of my explanatory factors at firm level. However my time dummy for my DiD estimation was still omitted due to collinearity - could this also be due to the strange relationship between uc and sa?

          Comment


          • #6
            Your time dummy is going to be colinear with sum of the i.quarter indicators. I doubt that one is related to the uc/sa issue.

            Comment

            Working...
            X