Skip to content

dealing with no never treated units in data#229

Merged
pedrohcgs merged 4 commits intobcallaway11:masterfrom
marcelortizv:origin/nt-units-faster-mode-debug
Jun 12, 2025
Merged

dealing with no never treated units in data#229
pedrohcgs merged 4 commits intobcallaway11:masterfrom
marcelortizv:origin/nt-units-faster-mode-debug

Conversation

@marcelortizv
Copy link
Copy Markdown
Contributor

@marcelortizv marcelortizv commented May 31, 2025

This PR supersedes PR#220 and implements two minor improvements in did:

  1. Handling Missing Never-Treated Groups:
    When the data contain no never-treated units but the user specifies "nevertreated" as the control group, did now issues a warning instead of throwing an error. In this situation, the last treated cohort (as defined by gname) is used as a “synthetic” never-treated group. We then drop all observations from periods ≥ latest_g. This behavior applies in both the regular and fast estimation modes. Unit tests verify that a warning is raised and that both modes produce identical treatment‐effect estimates.

Unit test in test-att_gt.R, Lines 215-226

# try to use never treated group as comparison group, should warn
expect_warning(nonev_orig <- att_gt(yname="Y", xformla=~X, data=data, tname="period",
                    control_group="nevertreated",
                    gname="G", est_method="dr", panel=FALSE, faster_mode = FALSE))

# try to use never treated group as comparison group with faster mode, should warn
expect_warning(nonev_faster <- att_gt(yname="Y", xformla=~X, data=data, tname="period",
                      control_group="nevertreated",
                      gname="G", est_method="dr", panel=FALSE, faster_mode = TRUE))

# make sure both methods give same ATT(g,t) with no never treated group
expect_equal(nonev_orig$att, nonev_faster$att)
  1. Suppressing Warnings for Unbalanced Panels/RCS:
    To prevent spurious warnings in unbalanced panels or repeated cross‐section settings, I’ve added a fill = TRUE argument when constructing the influence‐function matrix. The warning previously read:

Column 3 ['value'] of item 2 is missing in item 1. Use fill=TRUE to fill with NA (NULL for list columns), or use.names=FALSE to ignore column names. use.names='check' (default from v1.12.2) emits this message and proceeds as if use.names=FALSE for backwards compatibility. See news item 5 in v1.12.2 for options to control this message.

All unit tests are passing from my end
image

@pedrohcgs pedrohcgs merged commit ea052c4 into bcallaway11:master Jun 12, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants