predict.teigen {teigen}R Documentation

predict.teigen: Predicting Function for tEIGEN Objects

Description

Provides the fuzzy probability matrix and classification vector for inputted observations assuming the model provided by the teigen object.

Usage

## S3 method for class 'teigen'
predict(object, newdata=NULL, modelselect="BIC", ...) 

Arguments

object

An object of class teigen

newdata

Data frame or matrix of new observations on the same variables used in the fitting of the teigen object. For predicting one observation, a vector is permitted. If NULL, then the observations used in the fitting of the teigen object are inputted.

modelselect

A character string of either "BIC" (default) or "ICL" indicating the desired model-selection criteria to apply to the teigen object.

...

Arguments to be passed to other functions.

Details

Note that the scale argument from the teigen object is passed along to the predictfunction. See examples below for plotting.

Value

fuzzy

Matrix of fuzzy classification probabilities

classification

Vector of maximum a posteriori classifications

Author(s)

Jeffrey L. Andrews

See Also

teigen

Examples

set.seed(2521)
ind <- sample(1:nrow(faithful), 20)
set.seed(256)
tfaith_unscaled <- teigen(faithful[-ind,], models = "UUUU", Gs = 2, verbose = FALSE, scale=FALSE)
pred_unscaled <- predict(tfaith_unscaled, faithful[ind,])
set.seed(256)
tfaith_scaled <- teigen(faithful[-ind,], models = "UUUU", Gs = 2, verbose = FALSE, scale=TRUE)
pred_scaled <- predict(tfaith_scaled, faithful[ind,])
identical(pred_unscaled$classification, pred_scaled$classification)

##Plotting UNSCALED
plot(tfaith_unscaled, what="contour")
points(faithful[ind,1], faithful[ind,2], pch=15)
plotcolours <- rainbow(tfaith_unscaled$G)
points(faithful[ind,1], faithful[ind,2], pch=20, col=plotcolours[pred_unscaled$classification])

##Plotting SCALED
plot(tfaith_scaled, what="contour")
points((faithful[ind,1]-tfaith_scaled$info$scalemeans[1])/tfaith_scaled$info$scalesd[1],
       (faithful[ind,2]-tfaith_scaled$info$scalemeans[2])/tfaith_scaled$info$scalesd[2],
       pch=15)
plotcolours <- rainbow(tfaith_scaled$G)
points((faithful[ind,1]-tfaith_scaled$info$scalemeans[1])/tfaith_scaled$info$scalesd[1],
       (faithful[ind,2]-tfaith_scaled$info$scalemeans[2])/tfaith_scaled$info$scalesd[2],
       pch=20, col=plotcolours[pred_scaled$classification])


[Package teigen version 2.2.2 Index]