Announcement

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

  • csdid command with large dataset leads to "too many variables specified" error

    Hello,
    I am using the csdidcommand to estimate staggered difference-in-differences models. My dataset contains over 200,000 observations. I'm running the following command:
    csdid y, ivar(stock_code) time(virtual_time) gvar(event_point_zero) agg(simple) wboot(reps(10000)) rseed(42) long2

    Issue:
    During execution, the command prints many dots (.) and occasionally an "x". After a considerable time, the process fails with the error:

    too many variables specified

    Context and attempted solution:
    My data is at a monthly frequency.
    When I aggregate the data to a quarterly frequency, the same command runs successfully without error.

    Question:
    I am uncertain whether this is a limitation of my approach or a constraint of Stata (MP version) when handling a large number of time periods and groups. Could someone help me understand the cause and suggest a solution?

    Thank you.
    Last edited by Box Nop; 29 Jan 2026, 00:02.

  • #2
    Without covariates, csdid is just 2 x 2 differences-in-means where the period just before the intervention is the reference period. With 200,000 observations, I'm not sure why you're bootstrapping unless you have many different intervention dates and few treated units per date. Might you have some months where only one new unit is treated? That would be a problem; in fact, it would be a problem if you have only a few new treated units in some months. In any case, with a balanced panel and without controls, you can replicate csdid using a flexible TWFE regression. This is what jwdid does.

    Code:
    jwdid y ivar(stock_code) tvar(virtual_time) gvar(event_point_zero) never
    estat event
    estat simple
    If you add controls that don't change over time (typically recommended), jwdid reproduces csdid when you use method(reg) with csdid. But jwdid uses one long regression rather than many 2 x 2 regressions.

    Comment

    Working...
    X