Announcement

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

  • Difference in Difference modeling. How to separate the treated group from the control group in the dataset

    Hello, can anyone please help me on the command to differentiate my control group from treated groups. I am working on crop insurance on cocoa farmers income in Ghana and I have a total of 600 samples. The programme was rolled in some parts of the Ashanti region in Ghana. Out of the 6 districts, I gather data from, it was revealed that only two of the districts were treated and the rest four were not treated. Attached is a sample of my data please
    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(ACF MS Gen Edu Hsz Fexp AgeF) int MAI byte Plns
    46 2 1 3 8 10  4 1500 0
    50 2 1 1 4 17  5 1650 0
    35 1 1 3 6  6  3 1000 0
    46 4 1 3 4 11  3 1900 0
    50 2 1 1 6 19  3 1850 0
    39 2 1 2 3  8  5  890 0
    45 2 1 1 4 15  6 1760 0
    37 2 1 1 3  9  5  790 0
    48 2 2 1 3 13  3    . 0
    53 2 1 1 7 20  5 1800 0
    35 2 1 1 4 11  6  480 0
    43 2 1 1 4  9  5 1570 0
    43 2 2 1 3 10  3 2690 0
    58 2 1 2 8 23  5  890 0
    45 2 2 1 5 10  5    . 0
    40 2 1 2 4  5  4 1350 0
    50 5 2 2 6 20 10  950 0
    36 2 1 1 2  6  7 1580 0
    40 2 1 1 3  7  4    . 0
    53 2 2 1 5 30  3 1500 0
    50 2 1 1 8 17  5  580 0
    50 2 2 2 7 13  6  700 0
    35 2 1 2 2  6  2  970 0
    47 2 2 2 4  5  5 1000 0
    49 2 1 2 4 12  3 1800 0
    55 2 1 1 8 21 12  800 0
    39 2 1 2 2  4  6 2040 0
    50 2 2 1 6 18 15  750 0
    36 2 1 3 2  5 10  640 0
    55 2 1 1 7 23  2 1830 0
    50 2 1 3 6 13  8 1830 0
    58 2 2 2 7 30  5 1900 0
    35 2 2 2 3  6  4 2100 0
    54 5 1 2 7 16  6    . 0
    37 1 1 1 4  5  4 2010 0
    41 2 1 2 2 12  8 1000 0
    52 2 1 1 8 12  5 1070 0
    54 2 2 1 6 30  7    . 0
    55 2 1 1 7 24  5 1200 0
    35 1 1 1 2 10  3  500 0
    57 4 1 2 7 23  6 1750 0
    48 2 1 2 8 14  4 2940 0
    39 2 1 2 3 13  3 2400 0
    56 2 2 1 6 19 12    . 0
    55 2 1 1 7 19  9 2800 0
    47 2 2 2 3 15 14 1790 0
    51 5 1 1 4 23  5 2800 0
    53 2 1 1 6 12  5 1700 0
    48 2 1 2 5 11  3 1800 0
    40 2 2 2 4  9  2 1300 0
    54 2 1 2 6 11  4 1750 0
    47 2 1 1 5 14  3 1400 0
    49 2 2 1 6  5  5  700 0
    54 2 1 1 9 20  6  800 0
    50 2 2 1 6 25  4  300 0
    49 2 1 1 5 18  6  700 0
    55 2 1 2 7 20  7 1000 0
    56 2 2 2 6 18  5 2100 0
    35 2 1 1 4 12  4  500 0
    48 2 1 2 6  8  6 5000 0
    31 2 1 2 4  8  5 1950 0
    46 2 1 2 3 20  7 2080 0
    50 2 1 2 5 23  7 1600 0
    56 2 1 3 7 16  5  690 0
    43 2 1 2 3 13  3  900 0
    44 2 2 1 4 12  4  900 0
    53 5 2 2 5 20  4  850 0
    45 2 2 2 4 12  6 1800 0
    53 2 1 2 7 24  4 1500 0
    52 4 2 2 6 20  6    . 0
    50 2 2 3 5 32  4 1050 0
    30 1 1 2 4 21  6 1200 0
    35 2 2 2 3  4  5 1750 0
    39 2 1 4 3  5  6    . 0
    31 2 1 1 3  7  7 1500 0
    38 2 1 2 5  4  4 2650 0
    50 2 1 4 7 20  5    . 0
    42 2 1 2 4 12  9 1450 0
    49 5 2 2 4  5 10 1470 0
    48 2 1 4 3 10  4 1740 0
    50 2 1 3 6 20  6    . 0
    37 2 2 4 4  4  5  400 0
    52 4 1 2 8 19  4  680 0
    46 2 2 1 4 20  6 2350 0
    40 2 1 3 4 12  6 1450 0
    31 1 2 4 2  8  9 1290 0
    40 2 1 3 3  3  8 1800 0
    43 2 2 1 4  5  6 4000 0
    35 2 1 4 3  6  4 1600 0
    51 2 2 1 5 16  8 1480 0
    46 2 2 2 3 21  9 1370 0
    40 2 1 2 2  8 10 1460 0
    58 5 1 2 6 16  5 1590 0
    43 4 1 1 3  9  7 1640 0
    45 2 1 1 4  7 10 1000 0
    37 2 2 2 2  4  5 1850 0
    48 2 2 2 5 10  4 1500 0
    36 2 2 2 2  4  3 1490 0
    40 4 1 1 3  5  5 1350 0
    30 1 1 3 3  9 10 4000 0
    end
    ------------------ copy up to and including the previous line ------------------
    This is my first time trying statalist so kindly pardon me if i did not do something right. Thanks and looking forward to your wonderful suggestions.

  • #2
    Hi agbenyo could you please tell the variable you used for treatment

    Comment


    • #3
      Hello, Bri thanks for the reply. I was able to get the following commands yesterday.

      gen did=treated*time

      diff Income, t(treated) p(time)

      Currently, my problem is I do not know why my control and treated variables do not have standard errors and t-statistics. check the result below, please

      DIFFERENCE-IN-DIFFERENCES ESTIMATION RESULTS
      Number of observations in the DIFF-IN-DIFF: 518
      Before After
      Control: 223 122 345
      Treated: 100 73 173
      323 195

      Outcome var. MAI S. Err. t P>t

      Before
      Control 1563.857
      Treated 1749.200
      Diff (T-C) 185.343 89.814 2.06 0.040**
      After
      Control 1423.770
      Treated 1488.904
      Diff (T-C) 65.134 110.426 0.59 0.556

      Diff-in-Diff -120.210 142.339 0.84 0.399

      R-square: 0.02
      * Means and Standard Errors are estimated by linear regression
      **Inference: *** p<0.01; ** p<0.05; * p<0.1

      Comment


      • #4
        Hi agbenyo did you run that after installing "diff"?

        I am assuming that you are looking at diff in means since you are comparing wages (continuous outcome) If you are looking at the DID in means have you tried "reg" in your command instead of diff, it should look as follows

        reg outcome time treated did, r

        where did is your interaction term

        Comment


        • #5
          ----------------------- copy starting from the next line -----------------------
          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input int id byte t long treated float fte byte(bk kfc roys wendys) float _diff
           1 0 1    31 1 0 0 0 0
           1 1 1    40 1 0 0 0 1
           2 0 1    13 1 0 0 0 0
           2 1 1  12.5 1 0 0 0 1
           3 0 1  12.5 0 1 0 0 0
           3 1 1   7.5 0 1 0 0 1
           4 0 1    16 0 0 1 0 0
           4 1 1    20 0 0 1 0 1
           5 0 1    20 0 0 1 0 0
           5 1 1    25 0 0 1 0 1
           6 0 1     3 0 0 1 0 0
           6 1 1     6 0 0 1 0 1
           8 0 1     . 0 0 0 1 0
           8 1 1  27.5 0 0 0 1 1
           9 0 1    32 1 0 0 0 0
           9 1 1    16 1 0 0 0 1
          10 0 1    25 1 0 0 0 0
          10 1 1  22.5 1 0 0 0 1
          11 0 1    25 1 0 0 0 0
          11 1 1    24 1 0 0 0 1
          12 0 1 18.25 1 0 0 0 0
          12 1 1  22.5 1 0 0 0 1
          13 0 1  12.5 0 1 0 0 0
          13 1 1   7.5 0 1 0 0 1
          14 0 1    14 0 1 0 0 0
          14 1 1  12.5 0 1 0 0 1
          15 0 1  15.5 0 0 1 0 0
          15 1 1    15 0 0 1 0 1
          16 0 1    17 0 0 1 0 0
          16 1 1  15.5 0 0 1 0 1
          17 0 1    10 0 0 1 0 0
          17 1 1  21.5 0 0 1 0 1
          18 0 1  27.5 0 0 1 0 0
          18 1 1    27 0 0 1 0 1
          19 0 1  19.5 1 0 0 0 0
          19 1 1    28 1 0 0 0 1
          21 0 1    11 0 1 0 0 0
          21 1 1   5.5 0 1 0 0 1
          22 0 1  10.5 0 0 1 0 0
          22 1 1  10.5 0 0 1 0 1
          23 0 1  12.5 1 0 0 0 0
          23 1 1    21 1 0 0 0 1
          24 0 1  22.5 1 0 0 0 0
          24 1 1    25 1 0 0 0 1
          26 0 1  37.5 1 0 0 0 0
          26 1 1    20 1 0 0 0 1
          27 0 1     9 0 1 0 0 0
          27 1 1   3.5 0 1 0 0 1
          28 0 1     7 0 1 0 0 0
          28 1 1     7 0 1 0 0 1
          29 0 1   3.5 0 1 0 0 0
          29 1 1   6.5 0 1 0 0 1
          30 0 1     8 0 1 0 0 0
          30 1 1   5.5 0 1 0 0 1
          31 0 1    12 0 1 0 0 0
          31 1 1  13.5 0 1 0 0 1
          32 0 1 20.25 0 0 1 0 0
          32 1 1  14.5 0 0 1 0 1
          33 0 1    22 0 0 1 0 0
          33 1 1  11.5 0 0 1 0 1
          34 0 1  12.5 0 0 1 0 0
          34 1 1  14.5 0 0 1 0 1
          35 0 1 28.25 0 0 0 1 0
          35 1 1    22 0 0 0 1 1
          36 0 1    14 0 0 0 1 0
          36 1 1  27.5 0 0 0 1 1
          37 0 0  25.5 1 0 0 0 0
          37 1 0  18.5 1 0 0 0 0
          38 0 1    25 1 0 0 0 0
          38 1 1    20 1 0 0 0 1
          39 0 0    17 1 0 0 0 0
          39 1 0  12.5 1 0 0 0 0
          40 0 0    20 1 0 0 0 0
          40 1 0  19.5 1 0 0 0 0
          41 0 0  13.5 1 0 0 0 0
          41 1 0    21 1 0 0 0 0
          42 0 0    19 1 0 0 0 0
          42 1 0    11 1 0 0 0 0
          45 0 0    12 1 0 0 0 0
          45 1 0    17 1 0 0 0 0
          46 0 0  37.5 1 0 0 0 0
          46 1 0    21 1 0 0 0 0
          47 0 0  32.5 1 0 0 0 0
          47 1 0  22.5 1 0 0 0 0
          48 0 0    16 1 0 0 0 0
          48 1 0    20 1 0 0 0 0
          49 0 0  9.75 0 1 0 0 0
          49 1 0   7.5 0 1 0 0 0
          50 0 0    11 0 1 0 0 0
          50 1 0    14 0 1 0 0 0
          51 0 0   7.5 0 1 0 0 0
          51 1 0  13.5 0 1 0 0 0
          56 0 0    30 0 0 0 1 0
          56 1 0    18 0 0 0 1 0
          57 0 0    35 0 0 0 1 0
          57 1 0    16 0 0 0 1 0
          58 0 0  20.5 0 0 0 1 0
          58 1 0    14 0 0 0 1 0
          59 0 0   7.5 0 0 0 1 0
          59 1 0     8 0 0 0 1 0
          end
          label values treated treated
          label def treated 0 "PA", modify
          label def treated 1 "NJ", modify
          ------------------ copy up to and including the previous line ------------------

          Hello, please can anyone help me with this problem? The data above is from http://fmwww.bc.edu/repec/bocode/c/CardKrueger1994.dta
          (Dataset from Card&Krueger (1994))
          When following their estimation in relation to DID with no covariates with the command diff fte, t(treated) p(t) their output reported the standard error of both control and treated group in the baseline(before) same as in the follow up(After) but using the same data and command in Stata 15 my output only report that of the standard errors of the differences without the standard errors of the control and treated groups.
          I want to find out if there is something I am not doing right and I need your help. thanks

          DIFFERENCE-IN-DIFFERENCES ESTIMATION RESULTS
          Number of observations in the DIFF-IN-DIFF: 801
          Before After
          Control: 78 77 155
          Treated: 326 320 646
          404 397
          --------------------------------------------------------
          Outcome var. | fte | S. Err. | |t| | P>|t|
          ----------------+---------+---------+---------+---------
          Before | | | |
          Control | 19.949 | | |
          Treated | 17.065 | | |
          Diff (T-C) | -2.884 | 1.135 | -2.54 | 0.011**
          After | | | |
          Control | 17.542 | | |
          Treated | 17.573 | | |
          Diff (T-C) | 0.030 | 1.143 | 0.03 | 0.979
          | | | |
          Diff-in-Diff | 2.914 | 1.611 | 1.81 | 0.071*
          --------------------------------------------------------
          R-square: 0.01
          * Means and Standard Errors are estimated by linear regression
          **Inference: *** p<0.01; ** p<0.05; * p<0.1

          Comment

          Working...
          X