Description Usage Arguments Details Value Author(s) References See Also Examples
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.
1 | rrp.class(x, cl, train, test, k = 1)
|
x |
a |
cl |
class vector, coerced to be of type |
train |
the vecotr of indexes of the training set |
test |
the vector of training indexes of test set |
k |
number of nearest to consider |
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.
a vector of type factor
with predicted classes.
S.M. Iacus
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.
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])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.