darr: DA using Ridge or Kernel Ridge Regression on the Y-Dummy...

View source: R/darr.R

darrR Documentation

DA using Ridge or Kernel Ridge Regression on the Y-Dummy table

Description

DA-RR or DA-KRR

1- The class membership y (unidimensional variable) for the reference (= training) observations is firstly transformed (with function dummy) to a table Ydummy containing a number of nclas dummy variables, where nclas is the number of classes in y.

2- Then, a linear ridge regression (RR) or a kernel ridge regression (KRR = LS-SVM) model is fitted between the X-data and each of the dummy variables (i.e. each column of the dummy table Ydummy).

3- For a given new observation, the final prediction (a class) corresponds to the dummy variable for which the prediction is the highest.

When the number of classes is higher than two, this method can be affected by a masking effect (see eg. Hastie et al. 2009, section 4.2): some class(es) can be masked (therefore not well predicted) if more than two classes are aligned in the X-space. Caution should therefore be taken about such eventual masking effects.

Row observations can eventually be weighted with a priori weights (using argument weights).

Note: An alternative to dakrr is to run a "direct" kernel approach (e.g. Bennett & Embrechts 2003), i.e. to build preliminary kernel Gram matrices (such as doing a pre-processing on X), and then to run a DA-RR on them. See examples in function kgram.

See also the tuning facility with splitpar.

Usage


darr(Xr, Yr, Xu, Yu = NULL, lambda = 0, unit = 1, 
                 weights = NULL)
                 
dakrr(Xr, Yr, Xu, Yu = NULL, lambda = 0, unit = 1, 
                 kern = kpol, weights = NULL, print = TRUE, ...)                 
                 

Arguments

Xr

A n x p matrix or data frame of reference (= training) observations.

Yr

A vector of length n, or a n x 1 matrix, of reference (= training) responses (class membership).

Xu

A m x p matrix or data frame of new (= test) observations to be predicted.

Yu

A vector of length m, or a m x 1 matrix, of the true response (class membership). Default to NULL.

lambda

A value, or vector of values, of the regularization parameter lambda.

unit

A scalar. Unit used for lambda (Default to unit = 1). For instance, lambda = 12, unit = 1e-6, ... means that lambda = 12e-6.

kern

For dakrr. A function defining the considered kernel (Default to kpol). See kpol for syntax and other available kernel functions.

weights

A vector of length n defining a priori weights to apply to the training observations. Internally, weights are "normalized" to sum to 1. Default to NULL (weights are set to 1 / n).

print

For dakrr. Logical (default = TRUE). If TRUE, fitting information are printed.

...

For dakrr. Optionnal arguments to pass in the kernel function defined in kern. The value set in the kernel parameters (e.g. degree for kpol) can be a scalar or a vector of several values.

Value

A list of outputs, such as:

y

Responses for the test data.

fit

Predictions for the test data.

r

Residuals for the test data.

Examples


data(datforages)

Xr <- datforages$Xr
yr <- datforages$yr

Xu <- datforages$Xu
yu <- datforages$yu

lambda <- 10^(-15:5) ; unit <- 1
fm <- darr(Xr, yr, Xu, yu, lambda = lambda)
z <- err(fm, ~ lambda + unit)
z[z$errp == min(z$errp), ][1, ]
z$log.lambda <- log(z$lambda, base = 10)
plotmse(z, namx = "log.lambda", nam = "errp")

lambda <- 10^(-15:5) ; unit <- 1
fm <- dakrr(Xr, yr, Xu, yu, lambda = lambda, degree = 1:5)
z <- err(fm, ~ lambda + unit + degree)
z[z$errp == min(z$errp), ][1, ]
z$log.lambda <- log(z$lambda, base = 10)
group <- paste("degree=", z$degree, sep = "")
plotmse(z, namx = "log.lambda", nam = "errp", group = group)

lambda <- 10^(-15:5) ; unit <- 1
fm <- dakrr(Xr, yr, Xu, yu, lambda = lambda, kern = krbf, sigma = 10^(-3:3))
z <- err(fm, ~ lambda + unit + sigma)
z[z$errp == min(z$errp), ][1, ]
z$log.lambda <- log(z$lambda, base = 10)
group <- paste("sigma=", z$sigma, sep = "")
plotmse(z, namx = "log.lambda", nam = "errp", group = group)


mlesnoff/rnirs documentation built on April 24, 2023, 4:17 a.m.