kplsrda {rchemo}R Documentation

KPLSR-DA models

Description

Discrimination (DA) based on kernel PLSR (KPLSR)

Usage


kplsrda(X, y, weights = NULL, nlv, kern = "krbf", ...)

## S3 method for class 'Kplsrda'
predict(object, X, ..., nlv = NULL) 

Arguments

X

For main function: Training X-data (n, p). — For auxiliary function: New X-data (m, p) to consider.

y

Training class membership (n). Note: If y is a factor, it is replaced by a character vector.

weights

Weights (n) to apply to the training observations for the PLS2. Internally, weights are "normalized" to sum to 1. Default to NULL (weights are set to 1 / n).

nlv

For main function: The number(s) of LVs to calculate. — For auxiliary function: The number(s) of LVs to consider.

kern

Name of the function defining the considered kernel for building the Gram matrix. See krbf for syntax, and other available kernel functions.

...

Optional arguments to pass in the kernel function defined in kern (e.g. gamma for krbf).

object

For auxiliary function: A fitted model, output of a call to the main functions.

Details

The training variable y (univariate class membership) is transformed to a dummy table containing nclas columns, where nclas is the number of classes present in y. Each column is a dummy variable (0/1). Then, a kernel PLSR (KPLSR) is run on the X-data and the dummy table, returning predictions of the dummy variables. For a given observation, the final prediction is the class corresponding to the dummy variable for which the prediction is the highest.

Value

For kplsrda:

fm

list with the kplsrda model: (X): the training X-data (n, p); (Kt): the Gram matrix; (T): X-scores matrix; (C): The Y-loading weights matrix; (U): intermediate output; (R): The PLS projection matrix (p,nlv); (ymeans): the centering vector of Y (q,1); (weights): vector of observation weights; (kern): kern function; (dots): Optional arguments.

lev

y levels

ni

number of observations by level of y

For predict.Kplsrda:

pred

predicted class for each observation

posterior

calculated probability of belonging to a class for each observation

Examples


n <- 50 ; p <- 8
Xtrain <- matrix(rnorm(n * p), ncol = p)
ytrain <- sample(c(1, 4, 10), size = n, replace = TRUE)
m <- 5
Xtest <- Xtrain[1:m, ] ; ytest <- ytrain[1:m]

nlv <- 2
fm <- kplsrda(Xtrain, ytrain, nlv = nlv)
names(fm)
predict(fm, Xtest)

pred <- predict(fm, Xtest)$pred
err(pred, ytest)

predict(fm, Xtest, nlv = 0:nlv)$posterior
predict(fm, Xtest, nlv = 0)$posterior

predict(fm, Xtest, nlv = 0:nlv)$pred
predict(fm, Xtest, nlv = 0)$pred


[Package rchemo version 0.1-1 Index]