Learn R Programming

biotools (version 1.2)

findSubsample: Finding an Optimized Subsample

Description

It allows one to find an optimized (minimized or maximized) numeric subsample according to a statistic of interest. For example, it might be of interest to determine a subsample whose standard deviation is the lowest among all of those obtained from all possible subsamples of the same size.

Usage

findSubsample(x, size, fun = sd, minimize = TRUE, niter = 10000)

Arguments

x
a numeric vector.
size
an integer; the size of the subsample.
fun
an object of class function; the statistic at which to evaluate the subsample.
minimize
logical; if TRUE (default) findSubsample will find a subsample that minimizes stat.
niter
an integer indicating the number of iterations, i.e., the number of subsamples to be selected (without replacement) from the original sample, x. The larger is this number, the more optimized is the subsample to be found, but this also imp

Value

  • A list of
  • datanamea character.
  • niterthe number of iterations.
  • funthe objective function.
  • statthe achieved statistic for the optimized subsample.
  • criteriona character indicating the type of optimization.
  • subsamplea numeric vector; the optimized subsample.
  • labelsa string containg the labels of the subsample values.

See Also

sample, creategroups

Examples

Run this code
# Example 1
y <- rnorm(40, 5, 2)
findSubsample(x = y, size = 6)

# Example 2
f <- function(x) diff(range(x)) # max(x) - min(x)
findSubsample(x = y, size = 6, fun = f, minimize = FALSE, niter = 20000)

# End (not run)

Run the code above in your browser using DataLab