Announcement

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

  • time trends by group with new HDFE commands

    Hi everyone,

    I'm using the new version of areg in Stata Now 19.5, and I am wondering if anyone has an idea of how I could take advantage of this command to absorb group specific time trends, just like reghdfe from SSC. I want to run something like this:

    Code:
    areg y x, absorb(i.group#c.time)
    Where
    time is any kind of time variable. The problem is that none of the new high-dimensional fixed effects (HDFE) commands allow factor-variable and time-series operators in absorb.

    If I add these time trends as variables, all the speed gains of the new HDFE commands disappear. Here is an example based on the HDFE announcement page:

    Code:
    webuse hdfe, clear
    
    timer clear
    
    timer on 1
    areg y x, absorb(id a1 a2)
    est sto m1
    timer off 1
    
    timer on 2
    reghdfe y x, abs(id a1 a2)
    est sto m2
    timer off 2
    
    timer list
    For me, the runtime of areg is 1/10 of the one of reghdfe. However, if I create a time variable, and add time trends for each group of the variable a1, then areg's runtime becomes 17 times the time that reghdfe takes to run:

    Code:
    bys id: gen time=_n
    timer on 3
    qui reghdfe y x, abs(id i.a1#c.time)
    timer off 3
    
    timer on 4
    qui areg y x i.a1#c.time, abs(id)
    timer off 4
    
    timer list
    Any ideas of how I could the new HDFE commands to add these time trends?
Working...
X