np function

Creates design matrices for univariate and bivariate applications

Creates design matrices for univariate and bivariate applications

np accepts one or two numeric vectors of equal length as inputs. From these inputs, univariate or bivariate smoothing design matrices are produced. Currently available basis functions are truncated polynomials and thin plate splines. When bivariate smoothing is selected, np calls create_bivariate_design.

np(x1, x2 = NULL, num_knots = NULL, knots = NULL, basis = "tps", degree = 3)

Arguments

  • x1: numeric vector
  • x2: optional vector for bivariate non-parametric function
  • num_knots: optional number of knots
  • knots: optional numeric vector of knots
  • basis: character vector for basis function. tps for thin-plate spline and trunc.poly for truncated polynomial
  • degree: for truncated polynomial basis function

Returns

list with the following elements:

  • X parametric design matrix
  • Z non-parametric design matrix
  • knots numeric vector of knots for the model
  • Xnms names of parameters passed to np
  • basis selected basis function
  • degree degree for truncated polynomial basis function

Examples

x1 <- rnorm(100) res <- np(x1, num_knots=10, basis="trunc.poly", degree=2) res

References

Ruppert, David, Matt P. Wand, and Raymond J. Carroll. Semiparametric Regression. No. 12. Cambridge university press, 2003. Section 5.6.

Matt Wand (2018). SemiPar: Semiparametric Regression. R package version 1.0-4.2.

  • Maintainer: Samuel Thomas
  • License: GPL-3
  • Last published: 2022-03-17

Useful links