Learn R Programming

np

This is the R package np (Nonparametric Kernel Methods for Mixed Datatypes) written and maintained by Jeffrey S. Racine ([email protected]) and co-authored by Tristen Hayfield ([email protected]).

Installation

You can install the stable version on CRAN:

install.packages('np', dependencies = TRUE)

Or download the zip ball or tar ball, decompress and run R CMD INSTALL on it.

Alternatively, you can install the development version but before doing so Windows users have to first install Rtools, while macOS users have to first install Xcode and the command line tools (once you have Xcode installed, open a terminal and run xcode-select --install). Note also that versions of e.g. Rtools are paired with versions of R so ensure you have the latest version of R installed prior to commencing this process.

After installing Rtools/Xcode and devtools (via install.packages("devtools")), install the development package using the following command:

library(devtools); install_github('JeffreyRacine/R-Package-np')

Note also that if you wish a fast install without the building of vignettes (or if you do not have TeX installed on your system), add the option build_vignettes=FALSE to the install_github() call.

Note that if you wish to install the MPI-enabled development version of the package (i.e. the package npRmpi), you can add the option ref='npRmpi' to the install_github() call above, presuming that your system has a working MPI subsystem installed. See WORKTREES.md and BUILD.md in this repo for local build details.

Quick Start

library(np)
set.seed(1)
x <- runif(200)
y <- sin(2*pi*x) + rnorm(200, sd = 0.2)
bw <- npregbw(y ~ x, regtype = "ll", bwmethod = "cv.ls")
fit <- npreg(bws = bw)
summary(fit)
plot(fit)

For prediction, no-search refitting with standard errors or gradients, and the 0.70-5 migration guide, use vignette("np_getting_started", package = "np"). The Gallery FAQ and runnable quickstarts provide further examples.

For more information on this project please visit the maintainer's website (https://experts.mcmaster.ca/people/racinej).

Canonical Implementation Directive (2026-03-05)

This repository follows a strict canonical execution rule:

  1. One canonical implementation per method (outside explicit np.tree branching).
  2. Unsupported configurations must fail fast with explicit stop(...) diagnostics.
  3. No silent remap/coercion of user-selected options (for example bwmethod, regtype, kernels, cv.iterate, or bounds transforms).
  4. No hidden alternate execution paths for the same method semantics.
  5. All fit-defining options (for example degree, basis, bernstein.basis, kernels, and bounds) must be propagated and used by the canonical path.
  6. np.tree="auto" is the default; when np.tree=TRUE, behavior must remain semantics-preserving and option-compatible with the canonical path.
  7. Remove or reject legacy/debug compatibility branches that add redundant runtime overhead once canonical behavior exists.

Copy Link

Version

Install

install.packages('np')

Monthly Downloads

8,172

Version

0.80-2

License

GPL

Issues

Pull Requests

Stars

Forks

Maintainer

Jeffrey Racine

Last Published

November 13th, 2026

Functions in np (0.80-2)

np

Nonparametric Kernel Smoothing Methods for Mixed Data Types
Italy

Italian GDP Panel
wage1

Cross-Sectional Data on Wages
dimBS

Local-Polynomial Basis Dimension Helper
cps71

Canadian High School Graduate Earnings
Engel95

1995 British Family Expenditure Survey
oecdpanel

Cross Country Growth Panel
np-data-interfaces

Formula Data and Explicit Native Inputs
gradients

Extract Gradients
b.star

Compute Optimal Block Length for Stationary and Circular Bootstrap