v1.1.3 — Critical MLE Bug Fixes & Numerical Corrections
What's Changed
Critical Bug Fixes
llgkw()invalid parameter return — fixed returningR_NegInfinstead ofR_PosInffor invalid parameters. Gradient-based MLE optimizers treat −∞ as a global minimum, causing silent convergence to invalid boundaries.gkwinitdelta=0 rejection —gkw_pdf()incorrectly rejecteddelta = 0(valid for EKw, Kw sub-families) due to a strictdelta <= 0guard that should have beendelta < 0.gkwinitEKw/Kw sub-family mapping —ekw_pdf()andkw_pdf()passeddelta = 1instead of the correctdelta = 0, producing wrong starting values for MLE of these families.hsbkw()Hessian error for β < 1 — ternary expression(beta > 1.0) ? v_beta/v : 1.0returned 1.0 for all β ≤ 1, yielding wrong second derivatives and incorrect standard errors when β ∈ (0, 1).
Numerical Corrections
safe_exp()10× scaling error — moderate-underflow branch computed10 × exp(x)instead ofexp(x)due to use ofDBL_MIN_SAFE = 10 × DBL_MINin the scaling expression.dgkw()silent boundary truncation removed — a block silently returned density = 0 for valid data near x = 0 or x = 1 without warning; removed since log-space arithmetic handles these values correctly.llekw()/grekw()lambda clamping removed — arbitrarymin(lambda_factor, 1000)cap distorted gradients and Hessians for λ > 1000.
Code Quality
- Hessian accumulation in
hsgkw()/hsekw()refactored to build upper triangle only and symmetrize once witharma::symmatu(). - Removed spurious
try/catchblocks ingrbkw()/hsbkw()aroundRcpp::as<arma::vec>conversions that cannot throw. - Removed
using namespace Rcpp;fromgkwinit.cpp; added NA/NaN filtering before moment computation. - Added UB guard in
vec_safe_pow()forstatic_cast<int>when exponent >INT_MAX. - Added SIMD-friendly fast path
arma::exp(y * arma::log(x))invec_safe_pow()for the common case (y > 0, all x > 0).
Build
R CMD check --as-cran: 0 errors | 0 warnings | 0 notes
Tests: 342/342 pass