Skip to contents

Takes a random sample of size N-p from the population. See the Details section below for further information.

Usage

leavePOutSample(N, p, prob = NULL)

Arguments

N

positive integer value, the population size

p

integer, the number of elements to holdout

prob

(optional) N-length vector of positive numeric values, the probability weights for obtaining the N elements

Value

A vector of length N-p containing the index of the computed random set of observations.

Details

A random sample of size p is taken from the population and used as holdout data. This function returns a sample of size N-p obtained by removing the holdout sample from the population.

Author

Alessandro Barberis

Examples

#Set seed for reproducibility
set.seed(seed = 5381L)

#Take one sample leaving out p elements
leavePOutSample(N = 5, p = 2)
#> [1] 2 3 4

#Equivalent to leave-one-out
leavePOutSample(N = 5, p = 1)
#> [1] 1 3 4 5