Repository navigation
Review follow-ups: LP-DiD non-absorbing rules, collinear shocks, first-stage fixes - #5
Merged
Merged
Conversation
…t-stage fixes LP-DiD (estimates change on panels with gaps, missing treatment values, or units treated from their first row; nothing changes on balanced panels whose units all start untreated). - Switches are counted between consecutive observed treatment values. Summed from the observed first differences, as lpdid does, a switch in a gap was not seen: a unit observed untreated and then treated could be a not-yet-treated control, its next switch counted as the first, and an absorbing treatment switching off in a gap was accepted. - A control is a row with ΔD = 0: the first-treatment estimator no longer keeps the rows where a unit treated from its first row switches off (regressor −1). - LPDiD(compat = :lpdid) reproduces the Stata command where it differs, including the reweighting count of 0.2.1; reweight = :lpdid is short for reweight = true, compat = :lpdid. The lpdid cross-check runs with it (and checks that the defaults agree on the balanced panel). - A response with a lag inside is read at its own periods; a clear error when no horizon has both treated rows and clean controls. The three behaviours that 0.2.1 reported and left as they were. - A shock in the span of the other regressors is :singular whatever the formula's order. - Clustered(:unit, :time; ssc = :mss) with a negative factor gives a NaN variance (psd = :raw still clips it, as the authors' code). - With a tol looser than the default, nearly absorbed columns are re-absorbed at the default tolerance before the absorbed-column screen. Other fixes from the black-box review. - CDOLS(): the checks crashed with a path term before the shock. - A lead of a path term cannot be the shock (a clear error). - firststage with Homoskedastic() is the classical first-stage variance (it returned NaN); a first-stage variance that is exactly zero gives NaN with the warning, not F ≈ 1e33. - synthetic on a weighted fit says why it has no series. - Docs: the pmd base needs k + L − 1 clean periods with nonabsorbing = L; nonabsorbing = 0 is 1; audit and deviations pages list the new differences from lpdid. - Tests: the runner only takes the items of this repository's test/ directory. Pkg.test() passes on Julia 1.13.3 and 1.10.13 (45,789 tests); format, fixtures and the docs build are clean. The changes are under "Unreleased" in the CHANGELOG; the version stays 0.2.1. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-ups to 0.2.1 from the last part of the package review: the fourth lens (black-box use and documentation), which had not reported when 0.2.1 went out, and the three behaviours that 0.2.1 listed as "reported and left as they are". The version stays 0.2.1; the changes are under "Unreleased" in the CHANGELOG.
Estimates change in the cases below. On balanced panels without missing values whose units all start untreated, LP-DiD results are unchanged.
LP-DiD: non-absorbing rules
Both problems were inherited from the Stata command
lpdid, whose output the implementation matched.firsttreatandcontrol = :notyetor:nevertreated, a unit treated from its first row that later exits entered the regression with a regressor of −1 (on a noise-free panel with a true effect of 2, the estimate was 1.05). A control is now a row with ΔD = 0.LPDiD(compat = :lpdid)reproduces the command where it differs, including the reweighting count of 0.2.1;reweight = :lpdidstill works, as a shorthand. Thelpdidcross-check runs with it and also checks that the defaults agree with it on the balanced panel.ldiff(lags(y, 1))) is read at its own periods; a clear error when no horizon has both treated rows and clean controls.The three behaviours 0.2.1 left as they were
:singular, whatever the order of the formula. Before,x + x2(withx2 = 2x) gave the shock a coefficient andx2 + xan error.Clustered(:unit, :time; ssc = :mss)with a negative factor gives a NaN variance with a warning.psd = :rawstill clips it, as the authors' code does.tollooser than the default, nearly absorbed columns are re-absorbed at the default tolerance before the absorbed-column screen. Without it, an aggregate regressor with time effects gets a coefficient on a slowly mixing panel (about 12 on the test panel).Other fixes
CDOLS(): the checks crashed with a path termleads(z)written before the shock.firststage(r; vcov = Homoskedastic())returned NaN; it is now the classical first-stage variance (its F equals the Cragg–Donald F with one endogenous regressor).firststagewith a first-stage variance that is exactly zero reported an F of order 1e33; it is NaN with the warning.syntheticon a weighted fit says why it has no series.pmdbase needs k + L − 1 clean periods withnonabsorbing = L;nonabsorbing = 0is 1; the audit and deviations pages list the new differences fromlpdid.test/directory.Test plan
Pkg.test()on Julia 1.13.3 and 1.10.13: 45,789 tests pass, including the local MSS and Ilzetzki itemstoltest was checked to fail without the fixlpdidcross-check (47 option sets × 2 panels) passes withcompat = :lpdiddev/format.jl --check,dev/make_fixtures.jl --check, docs build🤖 Generated with Claude Code