Learn R Programming

shipunov (version 1.3)

BootRF: Bootstrap with 'randomForest()'

Description

How to bootstrap with 'randomForest()'

Usage

BootRF(data, classes, sub="none", nsam=4, nboot=1000, misclass=TRUE)

Arguments

data

Data frame to classify

classes

Character vector of class names

sub

Subsample to use (see example)

nsam

Number of training items from each level of grouping factor, default 4

nboot

Number of iterations

misclass

Calculate misclassification table?

Value

Returns all predictions as character matrix, each boot is a column

Details

This an example of how to bootstrap with 'randomForest::randomForest()'.

Samples equal numbers ('nsam') of training items from each level of grouping factor.

Allows to use subset of data which will be used for sub-sampling of training data.

See Also

randomForest::randomForest, Dev

Examples

Run this code
# NOT RUN {
iris.sub <- 1:nrow(iris) %in% seq(1, nrow(iris), 5)
# }
# NOT RUN {
## could be slow
iris.bootrf <- BootRF(iris[, -5], iris[, 5], sub=iris.sub)
iris.bootrf <- BootRF(iris[, -5], iris[, 5])
## naturally, in the second case misclassification rate is lower
# }

Run the code above in your browser using DataLab