rrda {rchemo}R Documentation

RR-DA models

Description

Discrimination (DA) based on ridge regression (RR).

Usage


rrda(X, y, weights = NULL, lb = 1e-5)

## S3 method for class 'Rrda'
predict(object, X, ..., lb = NULL) 

Arguments

For rrda:

X

For the main function: Training X-data (n, p). — For the 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).

lb

A value of regularization parameter lambda. If lb = 0, a pseudo-inverse is used in the RR.

object

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

...

For the auxiliary function: Optional arguments. Not used.

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 ridge regression (RR) 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 rrda:

fm

List with the outputs of the RR ((V): eigenvector matrix of the correlation matrix (n,n); (TtDY): intermediate output; (sv): singular values of the matrix (1,n); (lb): value of regularization parameter lambda; (xmeans): the centering vector of X (p,1); (ymeans): the centering vector of Y (q,1) ; (weights): the weights vector of X-variables (p,1).

lev

classes

ni

number of observations in each class

For predict.Rrda:

pred

matrix or list of matrices (if lb is a vector), with predicted class for each observation

posterior

matrix or list of matrices (if lb is a vector), 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]

lb <- 1
fm <- rrda(Xtrain, ytrain, lb = lb)
predict(fm, Xtest)

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

predict(fm, Xtest, lb = 0:2)
predict(fm, Xtest, lb = 0)


[Package rchemo version 0.1-1 Index]