rrp.class {rrp}R Documentation

Nonparametric nearest neighbor classification using RRP dissimilarity

Description

This method is a simple nearest neighbor based on the RRP dissimilarity matrix. It can be used also as a supervised method, i.e. using the class variable in the construction of the RRP dissimilarity matrix and by imputing missing values to the test set.

Usage

rrp.class(x, cl, train, test, k = 1)

Arguments

x a XPtr object
cl class vector, coerced to be of type factor
train the vecotr of indexes of the training set
test the vector of training indexes of test set
k number of nearest to consider

Details

From version 1.6 of the package the RRP matrix is stored as an external pointer to avoid duplications. This allow to work on bigger datasets. Hence this function no longer accepts dist objects.

Value

a vector of type factor with predicted classes.

Author(s)

S.M. Iacus

References

Iacus, S.M., Porro, G. (2006) Random Recursive Partitioning and its applications to missing data imputation, classification and average treatment effect estimation, submitted.

See Also

rrp.dist

Examples

data(iris)
X <- iris[,-5]
n <- dim(X)[1]

set.seed(123)
test <- sample(1:n, 10)
train <- (1:n)[-test]

## unsupervised
D <- rrp.dist(X)
pred <- rrp.class(D, iris[train,5], train, test)
table(pred, iris[test, 5])

# supervised
X <- iris
X[test,5] <- NA
D <- rrp.dist(X)
pred <- rrp.class(D, iris[train,5], train, test)
table(pred, iris[test, 5])

[Package rrp version 2.6 Index]