predict.nlda: Classify Multivariate Observations by 'nlda'

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Classify multivariate observations in conjunction with nlda, and also project data onto the linear discriminants.

Usage

1
2
## S3 method for class 'nlda'
predict(object, newdata, dim2use = NULL, ...)

Arguments

object

Object of class nlda.

newdata

A matrix or data frame of cases to be classified.

dim2use

The dimension of rotated data set to be used in prediction.

...

Arguments passed to or from other methods.

Details

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

Value

A list with components:

class

The predicted class (a factor).

x

The projections of test data on discriminant variables.

prob

The posterior probabilities for the predicted classes.

xmeans

The group means obtained from training.

dim2use

The dimension of rotated data set to be used in prediction.

Author(s)

David Enot [email protected] and Wanchang Lin [email protected].

See Also

nlda, plot.nlda

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
data(abr1)
cl   <- factor(abr1$fact$class)
dat  <- abr1$pos

## divide data as training and test data
idx <- sample(1:nrow(dat), round((2/3)*nrow(dat)), replace=FALSE) 

## constrcuct train and test data 
train.dat  <- dat[idx,]
train.t    <- cl[idx]
test.dat   <- dat[-idx,]        
test.t     <- cl[-idx] 

## apply NLDA
model    <- nlda(train.dat,train.t)
pred.te  <- predict(model, test.dat)

## confusion matrix
table(test.t,pred.te$class)

wilsontom/FIEmspro documentation built on Feb. 19, 2018, 9:03 a.m.