rrp.class: Nonparametric nearest neighbor classification using RRP...

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

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

1
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. (2009) Random Recursive Partitioning: a matching method for the estimation of the average treatment effect, Journal of Applied Econometrics, 24, 163-185.

Iacus, S.M., Porro, G. (2007) Missing data imputation, matching and other applications of random recursive partitioning, Computational Statistics and Data Analysis, 52, 2, 773-789.

See Also

rrp.dist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
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])

rrp documentation built on May 31, 2017, 3:29 a.m.

Related to rrp.class in rrp...