Skip to content

fix: correct fuzzy design obs selection and denominator guard#27

Open
Davidvandijcke wants to merge 8 commits intomainfrom
fix/arch-p1
Open

fix: correct fuzzy design obs selection and denominator guard#27
Davidvandijcke wants to merge 8 commits intomainfrom
fix/arch-p1

Conversation

@Davidvandijcke
Copy link
Copy Markdown
Owner

Summary

  • Replace outcome-bandwidth proxy (w_plus[,1]/w_minus[,1]) with treatment-side Fortran WINT output (outTplus$WINT/outTminus$WINT) for e2_mat row selection in fuzzy designs — wrong observations were silently included/excluded in treatment residuals
  • Raise fuzzy denominator near-zero guard from 1e-14 to 1e-8, aligning with Stata; values in (1e-14, 1e-8) produced numerically unstable estimates instead of NA

Test plan

  • devtools::check() passes: 0 errors, 0 warnings
  • Fuzzy RDD tests in tests/testthat/test-r3d-features.R pass
  • Denominator guard behavior verified: near-zero first-stage returns NA consistently with Stata

🤖 Generated with Claude Code

Davidvandijcke and others added 8 commits March 5, 2026 00:35
…type

- Rename DLL init function to R_init_R3D so R_registerRoutines and
  R_useDynamicSymbols are called on load (CRAN --as-cran blocker)
- Change arg 7 of locweights from double* to int* to match Fortran
  INTEGER declaration for KERNEL_TYPE (type mismatch blocker)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nt (#5)

- Rename DLL init function to R_init_R3D so R's loader correctly
  invokes it on package load, registering native routines and applying
  R_useDynamicSymbols(dll, FALSE) — fixes CRAN policy violation.
- Add inline comment on the magic number 11 in R_FortranMethodDef
  listing all Fortran argument names for future editors.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…#7)

Add src/*.so, src/*.o, src/*.dll patterns to .Rbuildignore so platform-specific
binaries are never included in the R CMD build tarball (CRAN requirement).
.gitignore already excluded these files from version control.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- Add \donttest{} examples to r3d_bootstrap() and r3d_bwselect()
  (fixes CRAN ERROR for missing examples)
- Replace \dontrun{} with \donttest{} in r3d(), plot.r3d(),
  print.r3d(), and summary.r3d() examples (fixes CRAN NOTE)
- Add @nord to all @Keywords internal helpers in r3d_utils.R to
  suppress NOTE about documented non-exported objects
- Remove orphaned .Rd files for internal functions

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- F1: fix Gini test_crit to use abs(gini_diffs_boot) for consistent
  two-sided critical value
- F2: remove dead f_X_hat / sigma_X / h_bw / kernel computation
- F3: remove unused h_num assignment inside doOneDraw
- F4: remove no-op scaling_q / scaling_num / scaling_den constants
- F5: add clusterSetRNGStream after makeCluster for reproducible
  Windows parallel bootstrap
- F7: add inline comment on e2_w_plus[,1] usage
- tests: add Gini test_crit >= 0 / consistent-direction check (F1)
  and seeded-bootstrap reproducibility test (F5)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…scope, saving CI)

S1:  Fix double-dereference ``fuzzy'' / ``weights'' -> `fuzzy' / `weights'
S7:  Read r(pilot_den) and r(h_den) into locals immediately after Mata call
     before intervening commands can clear r() results
S8:  Track Mata loading success via local mata_loaded instead of ambient _rc
S18: Remove redundant tempvar drops in r3d_bwselect.ado
S21: saving() now writes bootstrap CB bounds instead of pointwise normal CI

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace w_plus[,1]/w_minus[,1] proxy with outTplus\$WINT/outTminus\$WINT
  for e2_mat row selection in fuzzy designs; outcome-bandwidth proxy
  silently included/excluded wrong observations in treatment residuals
- Raise fuzzy denominator near-zero threshold from 1e-14 to 1e-8,
  aligning with Stata; values in (1e-14, 1e-8) produced numerically
  unstable estimates instead of NA

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant