You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix GitHub issue #32: Remove inconsistent missing data handling
- Remove problematic conditional block in vim-factors.R (lines 181-186)
- Fix inconsistent behavior where cleanup only ran with <10 missing values
- Allow proper delta missingness estimation as intended by TODO comment
- Add comprehensive tests to reproduce and verify the fix
The bug caused TMLE estimation to fail when there were ≥10 missing Y values
because the cleanup code wouldn't run, leaving missing values in the data.
This fix ensures consistent behavior regardless of missing value count.
Co-authored-by: openhands <openhands@all-hands.dev>
for (iin1:10) X[sample(nrow(X), 1), sample(ncol(X), 1)] <-NA
99
+
100
+
# Add missing data to Y - this triggers the bug (11 missing values)
101
+
Y[c(4,6,7,8,11,15,20,21,28,32,72)] <-NA
102
+
103
+
# This should fail with the current code
104
+
library(varimpact)
105
+
vim<- varimpact(Y=Y, data=X)
106
+
```
107
+
108
+
## Technical Details
109
+
110
+
### Why the Bug Occurs
111
+
112
+
1.`deltat = as.numeric(!is.na(Yt) & !is.na(At))` creates a vector where 1 = non-missing, 0 = missing
113
+
2.`sum(deltat == 0)` counts the number of missing observations
114
+
3. When this count is ≥ 10, the cleanup code is skipped
115
+
4. TMLE estimation receives data with missing values and fails
116
+
117
+
### The Inconsistency
118
+
119
+
The condition `sum(deltat == 0) < 10` creates an arbitrary threshold that leads to:
120
+
- Inconsistent data preprocessing
121
+
- Unpredictable failures based on the number of missing values
122
+
- Violation of the principle that similar inputs should produce similar behavior
123
+
124
+
### Proper Solution
125
+
126
+
Remove the entire conditional block (lines 181-186) to ensure consistent handling of missing data through the delta missingness estimation approach mentioned in the TODO comment.
0 commit comments