Commit aeca1d8
Fix CI review R5: survey TWFE math consistency + zero-weight row filter
- P1 #1: _compute_twfe_diagnostic now uses cell_weight (w_gt when
available, else n_gt) for FE regressions, the normalization
denominator, contribution weights, and the Corollary 1 observation
shares. On survey-backed inputs the outputs now match the
observation-level pweighted TWFE estimand; non-survey path is
byte-identical.
- P1 #2: Zero-weight rows are dropped before the groupby in
_validate_and_aggregate_to_cells when weights are provided, so that
d_min/d_max/n_gt reflect the effective sample. Prevents zero-weight
subpopulation rows from tripping the fuzzy-DiD guard or inflating
downstream n_gt counts.
- P2: 2 new regression tests in test_survey_dcdh.py —
TestSurveyTWFEOracle.test_survey_twfe_matches_obs_level_pweighted_ols
verifies beta_fe matches an observation-level pweighted OLS under
survey (would fail if n_gt was still used), and
TestZeroWeightSubpopulation.test_mixed_zero_weight_row_excluded_from_validation
verifies an injected zero-weight row with opposite treatment value
doesn't trip the within-cell constancy check.
All 256 targeted tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 97789f5 commit aeca1d8
2 files changed
Lines changed: 131 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
213 | 225 | | |
214 | 226 | | |
215 | 227 | | |
| |||
4828 | 4840 | | |
4829 | 4841 | | |
4830 | 4842 | | |
4831 | | - | |
| 4843 | + | |
| 4844 | + | |
| 4845 | + | |
| 4846 | + | |
| 4847 | + | |
| 4848 | + | |
| 4849 | + | |
| 4850 | + | |
| 4851 | + | |
| 4852 | + | |
4832 | 4853 | | |
4833 | 4854 | | |
4834 | 4855 | | |
| |||
4837 | 4858 | | |
4838 | 4859 | | |
4839 | 4860 | | |
4840 | | - | |
| 4861 | + | |
4841 | 4862 | | |
4842 | 4863 | | |
4843 | 4864 | | |
4844 | 4865 | | |
4845 | 4866 | | |
4846 | | - | |
| 4867 | + | |
4847 | 4868 | | |
4848 | 4869 | | |
4849 | 4870 | | |
| |||
4866 | 4887 | | |
4867 | 4888 | | |
4868 | 4889 | | |
4869 | | - | |
| 4890 | + | |
4870 | 4891 | | |
4871 | 4892 | | |
4872 | | - | |
| 4893 | + | |
4873 | 4894 | | |
4874 | | - | |
| 4895 | + | |
| 4896 | + | |
| 4897 | + | |
4875 | 4898 | | |
4876 | 4899 | | |
4877 | 4900 | | |
| |||
4880 | 4903 | | |
4881 | 4904 | | |
4882 | 4905 | | |
4883 | | - | |
| 4906 | + | |
4884 | 4907 | | |
4885 | 4908 | | |
4886 | 4909 | | |
| |||
4897 | 4920 | | |
4898 | 4921 | | |
4899 | 4922 | | |
4900 | | - | |
| 4923 | + | |
| 4924 | + | |
| 4925 | + | |
4901 | 4926 | | |
4902 | | - | |
4903 | | - | |
4904 | | - | |
4905 | | - | |
| 4927 | + | |
| 4928 | + | |
| 4929 | + | |
| 4930 | + | |
4906 | 4931 | | |
4907 | 4932 | | |
4908 | 4933 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
725 | 725 | | |
726 | 726 | | |
727 | 727 | | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
0 commit comments