Announcement

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

  • CSDID Omitted results.

    Hello,

    I am trying to use the csdid command (Callaway & Sant'Anna 2021) with a monthly panel dataset but all ATT(g,t) coefficients are returned as zero (omitted) and I cannot identify the cause.

    **Setup**
    - Stata 16.1
    - csdid and drdid installed from SSC
    - Panel data: borrower-level monthly observations
    - 6 treated cohorts entering the program in Jan–Jun 2025 (cohort_num 1–6)
    - 1 never-treated control group (cohort_num 0)
    - Time variable: sequential integer months (2024m7 = 1, 2024m8 = 2, ... 2025m11 = 17)
    - Data spans 2024m7 to 2025m11 (17 months total)

    **Variable construction**

    gen int ym_csdid = int(ym) - 772 // sequential: 2024m7=1 to 2025m11=17
    gen int entry_ym_csdid = 0
    replace entry_ym_csdid = int(ym(2025, cohort_num)) - 772 if cohort_num >= 1 & cohort_num <= 6
    // Results in: cohort1=7, cohort2=8, cohort3=9, cohort4=10, cohort5=11, cohort6=12

    xtset panel_id ym_csdid
    // panel variable: panel_id (unbalanced)
    // time variable: ym_csdid, 1 to 17, delta 1 unit

    **tab ym_csdid entry_ym_csdid (0.1% sample by cohort and control, ~5,000 obs)**

    Sequential |
    month: |
    2024m7=1, |
    2024m8=2, | entry_ym_csdid
    ... | 0 7 8 9 10 11 | Total
    -----------+------------------------------------------------------------------+----------
    1 | 191 24 29 22 16 12 | 304
    2 | 191 24 29 22 16 12 | 304
    3 | 191 24 29 22 16 12 | 304
    4 | 191 24 29 22 16 12 | 304
    5 | 190 24 29 22 16 12 | 303
    6 | 188 24 29 22 16 12 | 301
    7 | 184 24 29 22 16 12 | 297
    8 | 182 24 29 22 16 12 | 295
    9 | 182 24 29 22 16 12 | 295
    10 | 179 24 29 22 16 12 | 292
    11 | 178 24 29 22 16 12 | 291
    12 | 176 24 29 22 16 12 | 289
    13 | 176 23 29 22 16 12 | 288
    14 | 175 23 29 22 16 12 | 287
    15 | 175 23 29 22 16 12 | 287
    16 | 172 23 29 22 16 12 | 284
    17 | 172 23 29 22 16 12 | 284
    -----------+------------------------------------------------------------------+----------
    Total | 3,093 403 493 374 272 204 | 5,009


    Sequential |
    month: |
    2024m7=1, | entry_ym_c
    2024m8=2, | sdid
    ... | 12 | Total
    -----------+-----------+----------
    1 | 10 | 304
    2 | 10 | 304
    3 | 10 | 304
    4 | 10 | 304
    5 | 10 | 303
    6 | 10 | 301
    7 | 10 | 297
    8 | 10 | 295
    9 | 10 | 295
    10 | 10 | 292
    11 | 10 | 291
    12 | 10 | 289
    13 | 10 | 288
    14 | 10 | 287
    15 | 10 | 287
    16 | 10 | 284
    17 | 10 | 284
    -----------+-----------+----------
    Total | 170 | 5,009

    **Command used**

    csdid repayment, ivar(panel_id) time(ym_csdid) gvar(entry_ym_csdid) method(dripw) notyet

    **Result**

    All ATT(g,t) coefficients are 0 (omitted) across all 6 groups and all time periods. Number of obs = ~4,600. No x marks (estimation did not fail), but no estimates either.

    Number of obs = 4,694
    Outcome model : least squares
    Treatment model: inverse probability
    ------------------------------------------------------------------------------
    | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    g7 |
    t_1_2 | 0 (omitted)
    t_2_3 | 0 (omitted)
    t_3_4 | 0 (omitted)
    t_4_5 | 0 (omitted)
    t_5_6 | 0 (omitted)
    t_6_7 | 0 (omitted)
    t_6_8 | 0 (omitted)
    t_6_9 | 0 (omitted)
    t_6_10 | 0 (omitted)
    t_6_11 | 0 (omitted)
    t_6_12 | 0 (omitted)
    t_6_13 | 0 (omitted)
    t_6_14 | 0 (omitted)
    t_6_15 | 0 (omitted)
    t_6_16 | 0 (omitted)
    t_6_17 | 0 (omitted)
    -------------+----------------------------------------------------------------
    ----------and so on, so on--------------

    I have also tried:
    - never instead of notyet
    - Running without any covariates
    - Converting time and gvar to integer storage type (was float before)
    - Using the original %tm integer values (774–790) instead of sequential 1–17
    - Reducing to 0.1% stratified sample by cohort

    None of these resolved the issue.

    For reference, I confirmed csdid works correctly on the mpdta example dataset on a separate machine (Stata 14), producing real estimates with no omissions.

    The tab pattern looks similar to the working mpdta example. I cannot identify what structural difference in my data is causing all cells to be omitted.

    Any help would be greatly appreciated.

    Thank you.

  • #2
    That is a very odd situation, and no idea why it wouldnt work.
    As you suggest, this needs some manual exploration on the data, which could show some indications of where the error comes
    just to confirm, you are sure your panel id is correctly set up?
    can you try doing this manually? (even if for 1 unit

    you could also start by
    1)define your full panel data (manually)
    2) estimate your average output across time and cohort.

    Then try to do csdid again with this data.

    Other than that. not sure what else could be dirving the results

    Comment


    • #3
      For a particular problem, when I add control variables my z values blow up. I have looked at the data, and I cannot figure out what is going on. Any suggestions of what to check? Any potential fixes? (The number of observations, 18,246, does not change according specifications.)

      csdid cr if part == 1, ivar(fips) time(year) gvar(yy) method(drimp)

      g2008 |
      t_2000_2001 | .1672812 .0273656 6.11 0.000 .1136457 .2209167
      t_2001_2002 | -.1075658 .031715 -3.39 0.001 -.1697261 -.0454055

      csdid cr lpop pblack phisp if part == 1, ivar(fips) time(year) gvar(yy) method(drimp)
      t_2000_2001 | .1840816 . . . . .
      t_2001_2002 | 65.80876 3.57e-11 1.8e+12 0.000 65.80876 65.80876

      Comment


      • #4
        I did the same problem using xthdidregress, and I did not have this problem

        Comment


        • #5
          Need to use long2 option to match xthdidregress

          Comment


          • #6
            One detail to check in the posted code: subtracting 772 from Stata monthly dates gives 2 for July 2024 and 8 for January 2025. Your table shows 1 and 7. Shifting both time and cohort by the same amount leaves the comparisons unchanged. Use the cohort code in the data you actually passed to csdid. The code below uses 7 as shown in your table.

            For the first treated cohort, count borrowers with repayment observed both the month before treatment and the first month of treatment. The row totals in your table cannot tell you how many of the same borrowers have both outcomes. Start with never-treated controls for this check.

            Code:
            local g 7
            local b = `g' - 1
            isid panel_id ym_csdid
            preserve
            bysort panel_id (ym_csdid): assert entry_ym_csdid == entry_ym_csdid[1]
            keep if inlist(ym_csdid, `b', `g') & inlist(entry_ym_csdid, 0, `g')
            tempvar noutcomes
            bysort panel_id: egen byte `noutcomes' = total(!missing(repayment))
            display "Never-treated borrowers with outcomes in both months"
            count if ym_csdid == `g' & entry_ym_csdid == 0 & `noutcomes' == 2
            display "Treated borrowers with outcomes in both months"
            count if ym_csdid == `g' & entry_ym_csdid == `g' & `noutcomes' == 2
            restore
            If both counts are positive, compute the difference between the treated and control borrowers' mean repayment changes using those same pairs. That gives you a direct comparison to check against csdid with never-treated controls. Your original notyet fit can also use eligible later cohorts, so check their pair counts too. If a longer baseline-to-follow-up pair is thin, check whether shorter overlapping pairs have support.

            I maintain cdid for Stata, which is built for this type of incomplete panel. If a long pair is thin, cdid can recover the effect from supported shorter within-borrower changes under the parallel-trends and observation assumptions. If baseline borrower characteristics predict both who is observed in both months and how repayment changes, cdid can use observation weighting or change imputation if paired borrowers represent their cohort in mean repayment changes within those covariate groups. Its diagnostics show which comparisons have support. The pair-count check above uses built-in Stata commands. If you can use Stata 19.5 or later, here is the cdid guide: https://www.davidbenatia.com/tools/c...e-missingness/

            Install in Stata 19.5 (StataNow) or later from GitHub at https://github.com/dvbn/cdid-stata (or from SSC once listed).
            Code:
            net install cdid, from("https://raw.githubusercontent.com/dvbn/cdid-stata/main")
            mata: mata mlib index

            Comment

            Working...
            X