Announcement

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

  • Power analysis for difference-in-difference

    Hi everybody

    I would like to calculate the power of my difference-in-difference estimation. So far, I have only managed to calculate the power by comparing the posttreatment difference in means using this code:
    Code:
    power twomeans 43183.2 44557.72, sd1(19151.54) sd2(16492.9) n1(2926) n2(279) graph onesided
    *the first mean is the controlgroup and the second mean is the treatmentgroup
    I have looked at the different stata options for calculating power, but I cannot find anything about diff-in-diff. If anyone could help me out, I would be very grateful.

    The pretreatment numbers are:
    controlgroup:
    mean: 41878.44, sd: 18931.28

    treatmentgroup:
    mean: 40983.5, sd: 19267.45
    There are 12 observations per individual in eachtime period.


    Best,
    Gustav









  • #2
    Gustav, a difference-in-differences estimation can be implemented with a multiple linear regression. Assume y is the dependent variable, d is the treatment group dummy, p is the post-treatment dummy, and w = d*p. Then the DiD estimate would be the coefficient of w in the following regression.

    Code:
    regress y d p w
    For power calculation, you may use command -power pcorr-.

    Code:
    power pcorr r2_p, ntested(1) ncontrol(2) n(sample_size)
    where "sample_size" is the sample size of the linear regression, "r2_p" is the squared partial correlation between y and w and can be obtained from -pcorr-, as below.

    Code:
    pcorr y d p w

    Comment


    • #3
      Hi Fei

      Thanks for the reply. I have two questions. Regarding:

      Code:
      power pcorr r2_p, ntested(1) ncontrol(2) n(sample_size)
      Do I have to specify that indviduals are clustered? In my study, n is 76.920 with 3205 clusters.

      And also could you explain why you specify:
      Code:
      ncontrol(2)
      Is it because I need to specify that d and p is in the model?

      Best, Gustav
      Last edited by Gustav Egede Hansen; 28 Jun 2022, 01:27.

      Comment


      • #4
        Do I have to specify that indviduals are clustered? In my study, n is 76.920 with 3205 clusters.
        The sample size is the total number of individual observations.

        Is it because I need to specify that d and p is in the model?
        Yes.

        Comment


        • #5
          Alright thank you Fei. I really appreciate you taking the time.


          Best,
          Gustav

          Comment

          Working...
          X