Nonparametric Kernel Smoothing Methods for Mixed Data Types
Overview
Nonparametric (and semiparametric) kernel methods that seamlessly handle a mix of continuous, unordered, and ordered factor data types. We would like to gratefully acknowledge support from the Natural Sciences and Engineering Research Council of Canada (NSERC, https://www.nserc-crsng.gc.ca/), the Social Sciences and Humanities Research Council of Canada (SSHRC, https://www.sshrc-crsh.gc.ca/), and the Shared Hierarchical Academic Research Computing Network (SHARCNET, https://sharcnet.ca/). We would also like to acknowledge the contributions of the GNU GSL authors. In particular, we adapt the GNU GSL B-spline routine gsl_bspline.c adding automated support for quantile knots (in addition to uniform knots), providing missing functionality for derivatives, and for extending the splines beyond their endpoints.
- Corrected the heteroskedasticity-robust Ichimura index-coefficient covariance returned by
vcov(npindex(..., gradients = TRUE))when the model has more than one free index coefficient. Link-gradient and residual weights are now applied observation by observation. Fits with one free coefficient remain exactly unchanged, as do beta, bandwidth, objective, fitted-value, residual, and gradient results. - Repaired finite-support bounded continuous-kernel normalization for all supported Gaussian, Epanechnikov, uniform, and truncated-Gaussian kernels. The centered normalization now avoids tail cancellation, uses the platform C99 error function where appropriate, and preserves the uniform-density limit as the bandwidth tends to infinity.
- Replaced the bounded distribution operator with the mathematically correct observation-centered truncated-kernel CDF. Analytic centered interval primitives and hoisted invariant work preserve exact support endpoints, numerical accuracy, and the finite-support large-bandwidth uniform limit.
Show all changes in 0.70-5Hide the rest of the changes in 0.70-5
- Corrected
transform.bounds = TRUEinitialization for regression initial starts and multistarts and for later conditional-distribution multistarts. External bandwidth starts are now inverse-mapped before transformed Powell search; the public default remainsFALSE. - Clarified optimizer summaries so objective-cache lookups, NOMAD point lookups, family-native R-
optimrefinement, and total function-evaluation accounting are labelled consistently without implying that their denominators are interchangeable. - Clarified bandwidth-object replay documentation across estimator families. Stored bandwidth objects retain search and fit metadata but do not silently materialize or expand training data; callers must provide data again where the documented replay route requires it.
- Standardized the public
nomad.optscontract across supported bandwidth selectors and hardened native NOMAD callback cleanup, nearest-neighbor cache release, and native allocation-dimension guards. - Reworked
npindexbw()/npindex()internals after 0.70-4. Ichimura and Klein-Spady single-index objectives now reuse the establishednpregleave-one-out backend where applicable, preserving the public estimator contract while materially improving high-dimensional and local-polynomial objective evaluation. The single-index formula/materialization routes were tightened so formula-selected variables, explicit bandwidth objects, and direct formula calls with explicit smoothing parameters reenter consistently. - Added user documentation for
npindex()optimizer choice and beta interpretation. The documentation now gives practical guidance on when derivative-free Nelder-Mead remains a reasonable low-dimensional default and when BFGS is useful for higher-dimensional index searches, and it explains the relative interpretation of normalized single-index beta coefficients. - Hardened single-index fit, evaluation, plotting, and summary behavior. Bounded continuous-kernel options are now carried consistently through objective, fit, evaluation, variance, and bootstrap routes; Klein-Spady confusion-matrix output is guarded against out-of-range fitted values; and large-bandwidth shortcuts are restricted to kernel/order combinations whose constant-weight approximation was validated.
- Repaired single-index plot bootstrap memory usage. Wild-bootstrap self-maps now avoid public-facing
O(n^2)kernel-weight allocations for the ordinary large-sample plot route, while preserving the public fitted and plotting contracts. - Repaired generalized-nearest-neighbor local-polynomial derivative ownership across
npreghat()and related public routes. Mixed-degree local-polynomial fits now route available derivative components through the correct owner, preserveapply == H %*% ycontracts, and report unavailable derivative components consistently rather than silently applying the wrong operator. - Repaired local-constant derivative ownership in
npreghat()so degree-zero local-polynomial derivative requests use the analytic local-constant derivative contract only when that contract is mathematically available. Scalar, matrix, and multi-column apply routes were validated separately. - Improved conditional mixed-degree local-polynomial gradients for
npcdens()/npcdist()and public conditional-gradient accessors. The partial-availability contract now matches the regression-family policy: available components are returned, unavailable components are represented asNA, and incoherent metadata fails clearly. - Repaired formula/data reentry contracts across density, distribution, conditional density, conditional distribution, single-index, smooth coefficient, partially linear, quantile, conditional-mode, copula, and significance-test routes. Explicit estimator
data=now overrides stored bandwidth-object data where that public call shape is supported, formulanewdatais validated against fitted RHS variables, and direct formula calls with numeric smoothing parameters no longer misroute formula objects as native data. - Repaired unconditional density and distribution edge contracts. Ordered kernel-code selection is now consistent between conditional bandwidth selection and fitting where normalization is required, all-NA input is rejected before native calls, training and evaluation omission metadata are retained separately where needed, categorical zero-bandwidth standard-error handling is consistent across categorical configurations, and unsupported bandwidth-selection method codes fail clearly.
- Clarified normal-reference bandwidth documentation for density and distribution routes. The rule-of-thumb formulas are documented as fast exploratory Silverman-style heuristics, not production substitutes for cross-validation or likelihood-based selection.
- Hardened
npcdistbw()normal-reference method handling so the R method code and native C method code stay aligned, avoiding accidental fall-through to an unintended bandwidth-selection branch. - Repaired and hardened public estimator contracts found during adversarial audits of
npscoef,npplreg,npqreg,nplsqreg,npconmode,npcopula,npreg,npcdens,npcdist,npudens, andnpudist. Repairs includenpscoefiterated backfit behavior, partially-linear fit reentry, quantile inversion/clamping contracts, conditional-mode probability/tie handling, copula sample reentry, regression tree/large-h predicate alignment, and density/distribution formula/native argument consistency. - Plot-bootstrap memory hardening now covers single-index, conditional-mode, and partially-linear plot routes. The default plot evaluation grids remain linear in the training sample size, and explicit
neval == ntrainstyle requests remain user-controlled. - Categorical-gradient and derivative workspace handling were repaired so no-gradient and gradient calls can be mixed safely in one session without stale native derivative workspace state affecting later calls.
- Native shadow-object and cache lifecycles were hardened. Conditional-density shadow pointers, native objective-cache state, and regression large-h / large-lambda caches are cleared at the appropriate top-level lifecycle boundary so pointer-keyed helper state cannot leak across independent calls or datasets.
npksum()numeric-bandwidth dispatch now constructs data-aware bandwidth objects for mixed continuous/categorical data instead of falling back to a default-typed object. The serial and MPI packages now share the same public behavior for numeric smoothing parameters.- The local-polynomial regression CVKS low-support objective path now uses a named bandwidth-method code and aligns the R and C routing contracts, reducing the risk of drift between search metadata and native objective handling.
- Expanded focused tests, demos, benchmarks, and release-protocol sentinels across the public exported surface. The release protocol now requires an explicit public-exported-surface inventory, estimator-family sentinels, documentation/demo/benchmark smoke coverage, and installed package proof before release-ready claims.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-06-09
- ERROR12 OK, 1 ERROR2026-06-08
- OK14 OK2026-03-10
Documentation
- Help pages
- 60includes a package overview page
- Examples that run
- 19%11 run in a plain check · 46 never run
- Exported functions with examples
- 98%
- Documented parameters
- 87%
- Return-value docs
- 98%
- Help pages citing references
- 78%
Also includes 3 demo scripts (run with demo())
Downloads
Repository
- PRs merged (all time)
- 86%
- Median days to close, 50 most recently updated closed issues
- 7
- Median days to close, 50 most recently updated closed PRs
- 0
Stars over time
Forks over time
Issues over time
PRs over time
Commits over time
Checks run against github.com/jeffreyracine/r-package-np on 2026-10-11.
No development-tooling practices detected in the upstream repository.
Dependencies
Installing np adds 7 packages (6 with compiled code, 8.0 MB of source tarballs). Heaviest: cubature 3.2 MB, Rcpp 1.8 MB, crs 1.5 MB.
Show all 43 packagesHide all 43 packages
Code & Tests
Datasets
People & History
Pick two releases to compare their code metrics.
- 0.70-5Latest
- 0.70-42026-06-26 · diff ↗
- 0.70-3
- 0.70-2
- 0.70-12026-05-02 · diff ↗ ·
removed 1 export
npplotadded 11 exports
dimBS, npudenshat, npudisthat, npreghat, npindexhat, npplreghat, npscoefhat, npcdenshat, npcdisthat, np.pairs, np.pairs.plot - RR 4.6.0 released · 2026-04-24
- 0.60-202026-02-12 · diff ↗
- 0.60-192026-01-29 · diff ↗
- RR 4.5.0 released · 2025-04-11
- 0.60-182024-12-10 · diff ↗
- RR 4.4.0 released · 2024-04-24
- RR 4.3.0 released · 2023-04-21
- 0.60-172023-03-13 · diff ↗
- 0.60-162022-10-19 · diff ↗
- 0.60-152022-10-09 · diff ↗
- 0.60-142022-09-05 · diff ↗
Show 67 earlier eventsHide 67 earlier events
- 0.60-132022-08-16 · diff ↗
- RR 4.2.0 released · 2022-04-22
- 0.60-112021-06-14 · diff ↗
- RR 4.1.0 released · 2021-05-18
- RR 4.0.0 released · 2020-04-24
- 0.60-102020-02-06 · diff ↗
- RR 3.6.0 released · 2019-04-26
- 0.60-92018-10-25 · diff ↗
- 0.60-82018-06-04 · diff ↗
- 0.60-7
- RR 3.5.0 released · 2018-04-23
- 0.60-62018-01-13 · diff ↗
- 0.60-5
- 0.60-42017-12-04 · diff ↗
- 0.60-32017-04-29 · diff ↗
- RR 3.4.0 released · 2017-04-21
- RR 3.3.0 released · 2016-05-03
- RR 3.2.0 released · 2015-04-16
- 0.60-22014-06-28 · diff ↗
- 0.60-0
- RR 3.1.0 released · 2014-04-10
- RR 3.0.0 released · 2013-04-03
- 0.50-1
- RR 2.15.0 released · 2012-03-30
- 0.40-13
- 0.40-122011-11-25 · diff ↗
- RR 2.14.0 released · 2011-10-31
- 0.40-112011-10-25 · diff ↗
- 0.40-102011-10-24 · diff ↗
- 0.40-92011-07-30 · diff ↗
- 0.40-72011-06-09 · diff ↗
- 0.40-6
- 0.40-52011-04-26 · diff ↗
- RR 2.13.0 released · 2011-04-13
- 0.40-42011-01-21 · diff ↗
- RR 2.12.0 released · 2010-10-15
- 0.40-32010-07-24 · diff ↗
- 0.40-12010-06-04 · diff ↗
- 0.40-02010-05-26 · diff ↗
- 0.30-92010-05-17 · diff ↗
- RR 2.11.0 released · 2010-04-22
- 0.30-82010-04-20 · diff ↗
- 0.30-7
- 0.30-6
- 0.30-5
- 0.30-4
- RR 2.10.0 released · 2009-10-26
- 0.30-32009-06-02 · diff ↗
- 0.30-22009-04-19 · diff ↗
- RR 2.9.0 released · 2009-04-17
- 0.30-12009-01-29 · diff ↗
- 0.30-0
- 0.20-42008-11-20 · diff ↗
- 0.20-32008-11-14 · diff ↗
- 0.20-22008-11-02 · diff ↗
- RR 2.8.0 released · 2008-10-20
- 0.20-12008-08-13 · diff ↗
- 0.20-02008-07-28 · diff ↗
- 0.14-32008-05-02 · diff ↗
- RR 2.7.0 released · 2008-04-22
- 0.14-22008-01-11 · diff ↗
- 0.14-1
- RR 2.6.0 released · 2007-10-03
- 0.13-12007-05-03 · diff ↗
- RR 2.5.0 released · 2007-04-24
- 0.12-12006-11-19
- RR 2.4.0 released · 2006-10-03
Package metadata
- First published
- 2006-11-19
- Total releases
- 57 / 20 yrs
- License
- GPL
- Minimum R
- ≥ 3.5.0
- Bundled data
- 101 KB / 5 files
- Download size
- 1.5 MB
Cite
Cite this package
Run in R for the authors' entry:
citation("np")The package provides a citation file, so citation() returns the authors' own entry.
It points to 10.18637/jss.v027.i05.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-18, which the citation names so these numbers can be found later. More on citing and the projects behind them.