X2s {ppls} | R Documentation |
This function transforms each column of a matrix using a set of B-splines functions.
X2s(X, Xtest = NULL, deg = 3, nknot = NULL,reduce.knots=FALSE)
X |
A data matrix with rows corresponding to observations and columns to variables. |
Xtest |
An optional matrix of test data with the same number of columns as X . |
deg |
The degree of the splines. Default value is 3. |
nknot |
A vector of length ncol(X) . The jth entry
determines the number of knots to be used for the jth column
of X . Default value is rep(20,ncol(X)) . |
reduce.knots |
Logical variable. If TRUE , the function
ensures that the transformed data does not contain any constant
column. See below for more details. Default value is FALSE . |
Each column of the matrix X
represents one variable. For
each variable, we consider the set of B-splines functions
phi_1,...,phi_K that are determined by the degree deg
of the splines and the number nknot
of knots. The knots are
equidistantly based on the range of the variable. The data and – if
available – the test data is transformed nonlinearly using the
B-splines functions.
For a large amount of knots, it is possible that some columns of the
transformed matrix Z
only contain zeroes. If this is the case for
one variable and if reduce.knots=TRUE
, the amount of knots is reduced until this does
not occur anymore. Note that the
penalized PLS algorithm runs correctly for constant columns in
Z
, unless you scale the
columns of the data.
Z |
The matrix of transformed data with ncol(X) x (nknot -deg -1) columns. |
Ztest |
The matrix of test data, if provided. Otherwise, the transformed training data is returned. |
sizeZ |
A vector of length ncol(X) , where each component contains the
number of basis functions for each column of X . |
Depending on the degrees of the splines - there
must be minimum number of knots. If nknot
contains too few knots,
the function automatically increases the number.
Nicole Kraemer
C. de Boor (1978) "A practical guide to splines", Springer.
N. Kraemer, A.-L. Boulesteix, G. Tutz (2007) "Penalized Partial Least Squares with Applications to B-Splines Transformations and Functional Data", preprint
available at http://ml.cs.tu-berlin.de/~nkraemer/publications.html
X<-matrix(rnorm(100),ncol=5) Xtest<-matrix(rnorm(300),ncol=5) dummy<-X2s(X,Xtest)