bootsample: Draw bootstrap samples

Description Usage Arguments Value Examples

View source: R/utility.R

Description

Draws n samples in the range 1:n with replacement. Provides the out-of-bag samples for testing.

Usage

1
bootsample(n, b = 1000)

Arguments

n

The size of the data set to draw samples from

b

Number of bootstrap resamples to draw

Value

Returns an object of class "bootsample" which is a list of b lists with the following two attributes:

sample

a n-vector containting a bootstrap sample.

oob

a vector that contains the data points not in sample. Can for eg be used as test set.

Examples

1
2
3
4
5
6
7
8
9
data("iris")
nsamples <- nrow(iris)
bs <- bootsample(nsamples, 1)  # draw a single bootstrap sample

## split into training and test sets based on the bootstrap resampling
train_idx <- bs[[1]]$sample
test_idx <- bs[[1]]$oob
train <- iris[train_idx, ]
test <- iris[test_idx, ]

3inar/einr documentation built on May 5, 2019, 10:43 a.m.