Skip to contents

An S4 class to represent a sampling methodology.

The object consists of 7 slots

Constructor for the S4 Sampler object.

Usage

Sampler(
  method = c("random", "bootstrap", "cv"),
  N = integer(),
  n = 10L,
  k = 10L,
  strata = NULL,
  balance = FALSE,
  logger = Logger()
)

Arguments

method

The sampling strategy to use. The available options are:

'random'

random sampling

'cv'

k-fold cross-validation

'bootstrap'

bootstrap (sampling with replacement)

N

the population size

n

the sample size for method = "random" and method = "bootstrap"

k

the number of folds for method = "cv", or the number of repeats formethod = "random" and method = "bootstrap"

strata

(optional) vector of stratification variables. If provided must be of length N

balance

logical, whether to (try to) balance the strata frequency in the output sample. Used only if strata is provided when method = "random" or method = "bootstrap"

logger

a Logger

Value

a Sampler object

Slots

method

The sampling strategy to use. The available options are:

'random'

random sampling

'cv'

k-fold cross-validation

'bootstrap'

bootstrap (sampling with replacement)

N

a length-one integer vector, the population size

n

a length-one integer vector, the sample size for method = "random" and method = "bootstrap"

k

a length-one integer vector, the number of folds for method = "cv", or the number of repeats for method = "random" and method = "bootstrap"

strata

(optional) vector of stratification variables. If provided must be of length N

balance

a length-one logical vector, whether to (try to) balance the strata frequency in the output sample. Used only if strata is provided when method = "random" or method = "bootstrap"

logger

a Logger

Author

Alessandro Barberis