Announcement

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

  • Why Do These Identical Implementations of DID Produce Different Standard Errors?

    Consider the code

    Code:
    clear *
    
    u "https://github.com/jgreathouse9/FDIDTutorial/raw/main/basque.dta", clear
    
    cls
    xtreg gdpcap i.treat i.year, fe vce(r)
    xtdidregress (gdpcap) (treat), group(id) time(year) vce(r)
    
    qui {
    keep id year gdpcap
    
    qui reshape wide gdpcap, j(id) i(year)
    
    order gdpcap5, a(year)
    
    egen ymean = rowmean(gdpcap1-gdpcap17)
    
    drop gdpcap1-gdpcap17
             
    }     
    
    g ydiff = gdpcap5-ymean
    
    qui reg ydiff if year < 1975
    
    
    loc alpha = e(b)[1,1]
    
    g cf = ymean + `alpha'
    
    g post = cond(year>=1975,1,0)
    
    reg ydiff post, vce(r)
    In all three cases, I estimate difference in differences, one via xtreg, the next via xtdidregress and the other using a manual demeaning approach, using robust SEs each time. Only the first two match with one another. The ATTs are identical, but the standard errors are not. Why?

  • #2
    If you carefully read the full documentation for -xtreg, fe- you will se that it says
    vce(robust) is equivalent to specifying vce(cluster panelvar).
    .

    I believe it was back at version 13 that StataCorp announced that the use of non-cluster robust standard errors with -xtreg- is not appropriate, and to avoid breaking everybody's legacy code, it reprogrammed -xtreg- to automatically substitute -vce(cluster panelvar)- whenever the code specified robust standard errors. I am confident that -xtdidregress-, behind the scenes, does the same thing. The regression with de-meaned variables, however does not substitute cluster robust standard errors, so it gives different, presumably incorrect, results.

    Comment


    • #3
      Oh. Well that makes perfect sense then. You're also correct that under the hood xtdidregress does exactly that (I looked in the ado file, and I'm pretty sure the help confirms this)

      Comment

      Working...
      X