Learn R Programming

supclust (version 1.1-1)

predict.wilma: Predict Method for Wilma

Description

Yields fitted values or predicted class labels for training and test data, which are based on the supervised gene clusters wilma found, and on a choice of four different classifiers: the nearest-neighbor rule, diagonal linear discriminant analysis, logistic regression and aggregated trees.

Usage

# S3 method for wilma
predict(object, newdata = NULL, type = c("fitted", "class"),
              classifier = c("nnr", "dlda", "logreg", "aggtrees"),
              noc = object$noc, ...)

Arguments

object

an R object of class "wilma", typically the result of wilma().

newdata

numeric matrix with the same number of explanatory variables as the original x-matrix (\(p\) variables in columns, \(r\) cases in rows). For example, these can be additional microarray gene expression data which should be predicted.

type

character string describing whether fitted values "fitted" or predicted class labels "class" should be returned.

classifier

character string specifying which classifier should be used. Choices are "nnr", the 1-nearest-neighbor-rule; "dlda", diagonal linear discriminant analysis; "logreg", logistic regression; "aggtrees" aggregated trees.

noc

integer specifying how many clusters the fitted values or class label predictions should be determined. Also numeric vectors are allowed as an argument. The output is then a numeric matrix with fitted values or class label predictions for a multiple number of clusters.

further arguments passed to and from methods.

Value

Depending on whether noc is a single number or a numeric vector. In the first case, a numeric vector of length \(r\) is returned, which contains fitted values for noc clusters, or class label predictions with noc clusters.

In the latter case, a numeric matrix with length(noc) columns, each containing fitted values for noc clusters, or class label predictions with noc clusters, is returned.

Details

If newdata = NULL, then the in-sample fitted values or class label predictions are returned.

See Also

wilma also for references, and for the four classifiers nnr, dlda, logreg, aggtrees.

Examples

Run this code
# NOT RUN {
## Working with a "real" microarray dataset
data(leukemia, package="supclust")

## Generating random test data: 3 observations and 250 variables (genes)
set.seed(724)
xN <- matrix(rnorm(750), nrow = 3, ncol = 250)

## Fitting Wilma
fit  <- wilma(leukemia.x, leukemia.y, noc = 3, trace = 1)

## Fitted values and class predictions for the training data
predict(fit, type = "cla")
predict(fit, type = "fitt")

## Predicting fitted values and class labels for test data
predict(fit, newdata = xN)
predict(fit, newdata = xN, type = "cla", classifier = "nnr", noc = c(1,2,3))
predict(fit, newdata = xN, type = "cla", classifier = "dlda", noc = c(1,3))
predict(fit, newdata = xN, type = "cla", classifier = "logreg")
predict(fit, newdata = xN, type = "cla", classifier = "aggtrees")
# }

Run the code above in your browser using DataLab