iRBCrd for Stata/Mata 2.1 -- October 28, 2026

Implements the current R 2.1 design and interface specification in a separate
local version. The 2.0 source folder and published website are unchanged.

Features
- Sharp, fuzzy, covariate-adjusted sharp, and covariate-adjusted fuzzy kink RD.
- Default p=2 for kinks, p=1 for levels; user-supplied orders remain available.
- Sample Qn and order/kernel-specific asymptotic kink Q, independently of fast.
- Shared coefficient maps for kink bias, variance, and bootstrap statistics.
- Level iRBC-HCk and CCT-HCk residuals in every kink design.
- Bootstrap covariate refits in adjusted sharp and fuzzy designs.
- All four fixed/bootstrap fuzzy and gamma weighting combinations, including kinks.
- Singular bootstrap covariate refits are omitted draw by draw.
- boot_keep defaults off and controls retained bootstrap statistics/diagnostics.

Interface
R argument             Stata option
h                      h(# [#]), left then right
c                      c(#)
p                      p(#)
kernel                 kernel(name [name]), left then right
fuzzy                  fuzzy(varname)
kink                   kink (omission means FALSE)
covs                   covs(varlist)
res                    res(name)
alpha                  alpha(#)
bwcheck                bwcheck(#), with 0 for NULL
fast                   fast
boot.ci                boot_ci
boot.B                 boot_b(#)
boot.seed              boot_seed(#)
boot.wild              boot_wild(name)
boot.keep              boot_keep
q.method               q_method(name)
fuzzy.boot.weights     fuzzy_boot_weights(name)
gamma.boot.weights     gamma_boot_weights(name)

Removed old Stata options: gloo, hleft, hright, kleft, kright, residuals,
qmethod, level, noregularize, bootstrap, reps, seed, wild, fuzzyweights,
gammaweights, nokeep, and the public drawmatrix testing hook.
res(loo) remains a residual choice, as in R; it is not a bias-correction switch.
The low-level Mata irbc_compute() retains supplied multiplier support for
deterministic cross-language checks, outside the public command.

Results
- e(h) is the requested pair; e(h_minus)/e(h_plus) are effective bandwidths.
- Public names use res, kernel_minus, kernel_plus, boot_wild, and other R names
  with dots changed to underscores.
- Do not expose Q, q_method, boot_success, boot_mhat, or boot_probs in e().
- Both analytic and bootstrap estimates report the same corrected estimate.
- Return component, covariance, residual, kink, and retained-bootstrap details.

Stata-specific conventions
- if/in, complete-case omission, e(sample), and nodisplay remain available.
- Stata flags replace R logical arguments; bandwidth/kernel pairs are positional.
- RNG streams differ between R and Stata even with an identical numeric seed.
- R nested component lists are represented by labeled component matrices.

Native validation fixes
- Use lowercase syntax declarations for option names containing underscores.
- Initialize Mata globals without invalid top-level declarations and avoid
  using the reserved word local for the bootstrap observation mask.
- Test empty kink-constant cache matches by length, including a one-row cache.
- Add reproducible R comparisons with identical data and wild multipliers,
  plus public-result checks. Detailed results are in tests/VALIDATION.txt.
