predict.fenn: Classify Multivariate Observations

Description Usage Arguments Details Value Examples

View source: R/fenn.R

Description

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

Usage

1
2
predict.fenn(object, newdata, prior = object$prior, dimen,
                              method = c("knn", "lda"), ...)

Arguments

object

Object of class "fenn".

newdata

Data frame of cases to be classified or, if object has a formula, a data frame with columns of the same names as the variables used. A vector will be interpreted as a row vector. If newdata is missing, an attempt will be made to retrieve the data used to fit the fenn object.

method

This determines how the parameter estimation is handled. With "plug-in" (the default) the usual unbiased parameter estimates are used and assumed to be correct. With "debiased" an unbiased estimator of the log posterior probabilities is used, and with "predictive" the parameter estimates are integrated out using a vague prior.

...

Arguments based from or to other methods

reduce.dm

The dimension of the data will be reduced before performing knn.

Details

This function is a method for the generic function predict() for class "fenn". It can be invoked by calling predict(x) for an object x of the appropriate class, or directly by calling predict.fenn(x) regardless of the class of the object.

Missing values in newdata are handled by returning NA if the scaled linear discriminants cannot be evaluated. If newdata is omitted and the na.action of the fit omitted cases, these will be omitted on the prediction.

This version centres the scaled linear discriminants so that the weighted mean (weighted by prior) of the group centroids is at the origin.

Value

A list with components:

class

The MAP classification (a factor).

posterior

If classification method is lda, the posterior probabilities for the classes in the tilde transformed space will be returned.

Examples

1
2
3
4
5
6
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 <- fenn(train, cl)
predict(z, test)$class

kouroshz/fenn documentation built on Dec. 4, 2020, 12:54 a.m.