Announcement

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

  • HonestDiD when I am interested in the average over the two post-treatment periods

    Hi everyone,

    I have the following problem when I try to run the honestdid package (I am using Stata 17). I am not using the default option of the first post-treatment period, but the average over the two post-treatment periods. The error that arises is:

    4 child processes encountered errors. Throwing last error.
    (note: error during parallel run; falling back on sequential execution)
    *: 3200 conformability error
    _honestRMConditionalCS(): - function returned error
    HonestSensitivityHelper(): - function returned error
    HonestSensitivityResults(): - function returned error
    HonestDiD(): - function returned error
    <istmt>: - function returned error

    Here is an example with simulated data with the same structure than my own data (staggered treatment) illustrating my process: * Set the number of units and periods
    Code:
     local num_units = 100 local num_periods = 10
    * Create base data
    Code:
     clear set obs `num_units' gen id = _n expand `num_periods' bysort id: gen time = _n
    * Create the time variable as a date
    Code:
     gen date = mdy(1, 1, 2000) + (time - 1) * 30 format date %td
    * Randomly assign the treatment start time for each treated unit
    Code:
     gen treatment_start = . replace treatment_start = 5 + int(runiform() * 5) if id <= `num_units'/2
    * Create the post variable indicating if treatment is received
    Code:
     gen post = 0 bysort id: replace post = 1 if time >= treatment_start & !missing(treatment_start)
    * Create the empleo_formal (dummy) variable
    Code:
     gen empleo_formal = 0
    Code:
     replace empleo_formal = 1 if runiform() > 0.5
    * Adjust empleo_formal based on treatment
    Code:
     replace empleo_formal = 1 if post == 1 & runiform() > 0.3 replace empleo_formal = 0 if post == 1 & runiform() <= 0.3
    * Create gvar (time of treatment)
    Code:
     sort id time
    Code:
     by id: gen first_change = post == 1 & post[_n-1] == 0 if _n == 1 | post[_n-1] == 0
    Code:
     by id: egen period_start = min(cond(first_change == 1, time, .))
    Code:
     drop first_change
    Code:
     gen gvar = cond(period_start == ., 0, period_start)
    Code:
     label variable gvar "Treatment activation period"
    [CODE] tab gvar [/ CODE]
    Code:
     drop period_start treatment_start
    * List some observations to verify the data
    Code:
     list id time date post empleo_formal gvar in 1/20
    * Estimation with csdid2 and sensitivity with HonestDiD
    Code:
     csdid2 empleo_formal, ivar(id) time(time) gvar(gvar) agg(event) long2
    Code:
     estat event, estore(csdid)
    Code:
     estimates restore csdid
    Code:
     matrix define l_vec = 0.5 \ 0.5
    Code:
     matlist l_vec
    * But when I try this, the error above arises:
    Code:
     honestdid, l_vec(l_vec) pre(3/8) post(9/14) mvec(0.2(0.1)1.5) coefplot xtitle(Mbar) ytitle(95% Robust CI)
    Any help would be greatly appreciated!
    Last edited by Nicolas Campos; 21 Jun 2024, 07:02.
Working...
X