Announcement

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

  • Difference in differences - collinearity

    Hello all.

    This is my first post in Statalist, and sorry if I write something wrong.

    I have data from 2005-2013, from before and after the municipal amalgamation in Denmark, as occured in 2007.
    I want to find out, whether the municipal amalgamation had an effect on municipal satisfaction on the service delivered.
    I've appended 3 datasets to 1, and i'm trying to do the didregress, and it says that the threatment variable, sammenlagtekommuner, was omitted because of collinearity.
    Sammenlagtekommuner is a dummyvariable, where 1=amalgamated municipals and 0=non-amalgamated municipals.
    Service = municipal satisfaction on the service delivered
    Kommuner = municipalcodes
    År= year

    Code:
    clear
    input float service int sammenlagtekommuner float(kommuner år)
    2.875 0 . 2005
    4 0 . 2005
    2.75 0 . 2005
    2.5 0 . 2005
    2.75 0 . 2005
    3.5 0 . 2005
    3.875 0 . 2005
    3.375 0 . 2005
    5.25 0 . 2005
    3 0 . 2005
    3 0 . 2005
    4.25 0 . 2005
    3.125 0 . 2005
    3.875 0 . 2005
    2.375 0 . 2005
    2.5 0 . 2005
    4.25 0 . 2005
    3.75 0 . 2005
    3.375 0 . 2005
    4.25 0 . 2005
    2.375 0 . 2005
    3.375 0 . 2005
    4.375 0 . 2005
    3 0 . 2005
    3.375 0 . 2005
    2.75 0 . 2005
    3.875 0 . 2005
    4.125 0 . 2005
    2 0 . 2005
    1.875 0 . 2005
    2.5 0 . 2005
    4 0 . 2005
    2.875 0 . 2005
    3.5 0 . 2005
    3.625 0 . 2005
    2.25 0 . 2005
    2.75 0 . 2005
    2.25 0 . 2005
    2.875 0 . 2005
    3.625 0 . 2005
    3.875 0 . 2005
    3.875 0 . 2005
    3.125 0 . 2005
    3.25 0 . 2005
    3 0 . 2005
    3.625 0 . 2005
    2.875 0 . 2005
    3.375 0 . 2005
    3.125 0 . 2005
    4.25 0 . 2005
    3.375 0 . 2005
    2.625 0 . 2005
    1 0 . 2005
    3.5 0 . 2005
    2.5 0 . 2005
    1.5 0 . 2005
    4.125 0 . 2005
    3.625 0 . 2005
    3.125 0 . 2005
    4.375 0 . 2005
    3 0 . 2005
    2.625 0 . 2005
    3.25 0 . 2005
    3.75 0 . 2005
    1.875 0 . 2005
    4.75 0 . 2005
    4.75 0 . 2005
    3.125 0 . 2005
    2.125 0 . 2005
    2.625 0 . 2005
    3.25 0 . 2005
    4 0 . 2005
    3.875 0 . 2005
    4.5 0 . 2005
    4.625 0 . 2005
    5.125 0 . 2005
    4.5 0 . 2005
    3.125 0 . 2005
    3.25 0 . 2005
    2.625 0 . 2005
    3.5 0 . 2005
    3.375 0 . 2005
    2 0 . 2005
    4.625 0 . 2005
    3.375 0 . 2005
    2.875 0 . 2005
    3.5 0 . 2005
    4.25 0 . 2005
    3.25 0 . 2005
    2.875 0 . 2005
    5.125 0 . 2005
    4.5 0 . 2005
    2.875 0 . 2005
    3 0 . 2005
    3.25 0 . 2005
    4.375 0 . 2005
    1.625 0 . 2005
    2.625 0 . 2005
    4.375 0 . 2005
    2.875 0 . 2005
    end
    label values sammenlagtekommuner sammenlagtekommuner
    label def sammenlagtekommuner 0 "Ikke-sammenlagte kommuner", modify
    Thanks in regards, and for clarity, here is the do-file and the dataset. If anything needed for answering the question, please let me know.
    Attached Files

  • #2
    Thanks so much for giving your example data on your first post. Could you please take the code from your do file that you've posted and include it in your example code? Not everyone on Statalist will open files that're posted here.

    Also, hey Casper Harild-Ankersen, welcome to Statalist.


    EDIT: Note that when I say "your code", I mean the code that produced the problem. Presumably, you've cleaned your data such that your estimation command will reproduce the issue you're having.
    Last edited by Jared Greathouse; 10 Apr 2022, 11:48.

    Comment


    • #3
      the issue is that the group variable (kommuner) is missing in the pre-period,
      Code:
      use "/Users/oyvsni/Downloads/datafil 05 09 13.dta", clear
      tab kommune if år<2007
      no observations
      
      *V5 label says "kommunenummer"
      replace kommune = V5 if missing(kommune)
      also, treatment should switch on in the post-period,
      Code:
      gen treatment = år>=2007 & sammenlagtekommuner
      didregress (service) (treatment), group(kommuner) time(år)
      
      Number of groups and treatment time
      
      Time variable: år
      Control:       treatment = 0
      Treatment:     treatment = 1
      -----------------------------------
                   |   Control  Treatment
      -------------+---------------------
      Group        |
          kommuner |       239         66
      -------------+---------------------
      Time         |
           Minimum |      2005       2009
           Maximum |      2009       2009
      -----------------------------------
      
      Difference-in-differences regression                     Number of obs = 9,875
      Data type: Repeated cross-sectional
      
                                   (Std. err. adjusted for 305 clusters in kommuner)
      ------------------------------------------------------------------------------
                   |               Robust
           service | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
      ATET         |
         treatment |
         (1 vs 0)  |   .2719254   .0788703     3.45   0.001     .1167246    .4271262
      ------------------------------------------------------------------------------
      Note: ATET estimate adjusted for group effects and time effects.

      Comment


      • #4
        Jared Greathouse and Øyvind Snilsberg, thanks for the help!

        , can you please explain, why the command estat trendplots, does not work, after the commands is typed in?
        It says that treatment assignment times vary; not allowed with estat trendplots.
        Thanks again for the help.

        Comment


        • #5
          you only have data on 20 out of 273 amalgamated municipals (and 31 out of 32 non-amalgamated municipals) before and after the amalgamation. to get estat trendplots to run include in your analysis only municipals that were observed both before and after the amalgamation,
          Code:
          use "/Users/oyvsni/Downloads/datafil 05 09 13.dta", clear
          
          replace kommune = V5 if missing(kommune)
          
          table år
          -------------------
                 |  Frequency
          -------+-----------
          år     |          
            2005 |      2,011
            2009 |      3,333
            2012 |          1
            2013 |      4,528
            5347 |          1
            5348 |          1
          -------------------
          
          keep if inlist(år,2005,2009,2013)
          
          egen tag = tag(kommuner år)
          egen total = total(tag), by(kommuner)
          
          table total år if tag & sammenlagt, nototal
          ---------------------------
                |          år        
                |  2005   2009   2013
          ------+--------------------
          total |                    
            1   |   207              
            2   |           46     46
            3   |    20     20     20
          ---------------------------
          
          table total år if tag & !sammenlagt, nototal
          ---------------------------
                |          år        
                |  2005   2009   2013
          ------+--------------------
          total |                    
            2   |            1      1
            3   |    31     31     31
          ---------------------------
          
          keep if total == 3
          
          gen treatment = år>=2007 & sammenlagtekommuner
          
          didregress (service) (treatment), group(kommuner) time(år)
          
          estat trendplots
          Last edited by Øyvind Snilsberg; 11 Apr 2022, 04:48.

          Comment

          Working...
          X