crs-package: Nonparametric Regression Splines with Continuous and...

Description Details Author(s) References


This package provides a method for nonparametric regression that combines the (global) approximation power of regression splines for continuous predictors (‘x’) with the (local) power of kernel methods for categorical predictors (‘z’). The user also has the option of instead using indicator bases for the categorical predictors. When the predictors contain both continuous and categorical (discrete) data types, both approaches offer more efficient estimation than the traditional sample-splitting (i.e. ‘frequency’) approach where the data is first broken into subsets governed by the categorical z.

To cite the crs package type: ‘citation("crs")’ (without the single quotes).

For a listing of all routines in the crs package type: ‘library(help="crs")’.

For a listing of all demos in the crs package type: ‘demo(package="crs")’.

For a ‘vignette’ that presents an overview of the crs package type: ‘vignette("crs")’.


For the continuous predictors the regression spline model employs the B-spline basis matrix using the B-spline routines in the GNU Scientific Library (

The function is used to construct multivariate tensor spline bases when basis="tensor" and uses additive B-splines otherwise (i.e. when basis="additive").

For the discrete predictors the product kernel function is of the ‘Li-Racine’ type (see Li and Racine (2007) for details) which is formed by constructing products of one of the following univariate kernels:

(z is discrete/nominal)

l(z[i],z,lambda) = 1 if z[i] = z, and lambda if z[i] != z. Note that lambda must lie between 0 and 1.

(z is discrete/ordinal)

l(z[i],z,lambda) = 1 if |z[i] - z| = 0, and lambda^|z_i-z| if |z[i] - z|>=1. Note that lambda must lie between 0 and 1.

Alternatively, for the ordinal/nominal predictors the regression spline model will use indicator basis functions.


Jeffrey S. Racine and Zhenghua Nie

Maintainer: Jeffrey S. Racine

I would like to gratefully acknowledge support from the Natural Sciences and Engineering Research Council of Canada (, the Social Sciences and Humanities Research Council of Canada (, and the Shared Hierarchical Academic Research Computing Network (


Li, Q. and J.S. Racine (2007), Nonparametric Econometrics: Theory and Practice, Princeton University Press.

Ma, S. and J.S. Racine and L. Yang (2015), “Spline Regression in the Presence of Categorical Predictors,” Journal of Applied Econometrics, Volume 30, 705-717.

Ma, S. and J.S. Racine (2013), “Additive Regression Splines with Irrelevant Categorical and Continuous Regressors,” Statistica Sinica, Volume 23, 515-541.

crs documentation built on Feb. 2, 2021, 5:13 p.m.