Learn R Programming

ppls (version 2.0.0)

X2s: Nonlinear Transformation via B-Splines

Description

Transforms each column of a numeric matrix (or vector) into a new basis defined by B-spline functions.

Usage

X2s(X, Xtest = NULL, deg = 3, nknot = NULL, reduce.knots = FALSE)

Value

A list containing:

Z

Design matrix for training data (B-spline coefficients).

Ztest

Design matrix for test data.

sizeZ

Vector of number of basis functions for each column.

Arguments

X

Numeric matrix or vector of input data.

Xtest

Optional numeric matrix or vector of test data. Defaults to X.

deg

Degree of the B-splines (default is 3).

nknot

Vector specifying the number of knots per column. Default is rep(20, ncol(X)).

reduce.knots

Logical. Reduces knots to avoid constant columns if TRUE (default is FALSE).

References

Kraemer, N., Boulesteix, A.-L., & Tutz, G. (2008). Penalized Partial Least Squares with Applications to B-Spline Transformations and Functional Data. Chemometrics and Intelligent Laboratory Systems, 94, 60-69. https://doi.org/10.1016/j.chemolab.2008.06.009

Examples

Run this code
X <- matrix(rnorm(100), ncol = 5)
Xtest <- matrix(rnorm(300), ncol = 5)
result <- X2s(X, Xtest)

Run the code above in your browser using DataLab