Learn R Programming

mt (version 2.0-1.20)

predict.pcalda: Predict Method for Class 'pcalda'

Description

Prediction of test data using pcalda.

Usage

# S3 method for pcalda
predict(object, newdata,...)

Value

A list with components:

class

The predicted class (a factor).

posterior

The posterior probabilities for the predicted classes.

x

The rotated test data by the projection matrix of LDA.

Arguments

object

Object of class pcalda.

newdata

A matrix or data frame of cases to be classified.

...

Arguments based from or to other methods.

Author

Wanchang Lin

Details

This function is a method for the generic function predict() for class pcalda. If newdata is omitted, the results of training data in pcalda object will be returned.

See Also

pcalda, plot.pcalda

Examples

Run this code
data(iris3)

tr    <- sample(1:50, 25)
train <- rbind(iris3[tr,,1], iris3[tr,,2], iris3[tr,,3])
test  <- rbind(iris3[-tr,,1], iris3[-tr,,2], iris3[-tr,,3])
cl    <- factor(c(rep("s",25), rep("c",25), rep("v",25)))

z     <- pcalda(train, cl)
pred  <- predict(z, test)

## plot the projected data.
grpplot(pred$x, pred$class, main="PCALDA: Iris") 

Run the code above in your browser using DataLab