Learn R Programming

ParamHelpers (version 1.3)

generateDesign: Generates a statistical design for a parameter set.

Description

The following types of columns are created: ll{ numeric(vector) numeric integer(vector) integer discrete(vector) factor (names of values = levels) logical(vector) logical } If you want to convert these, look at convertDataFrameCols. Dependent parameters whose constraints are unsatisfied generate NA entries in their respective columns.

Currently only lhs designs are supported.

The algorithm currently iterates the following steps:

  1. We create a space filling design for all parameters, disregardingrequires, atrafoor the forbidden region.
Forbidden points are removed. Parameters are trafoed (maybe); dependent parameters whose constraints are unsatisfied are set to NA entries. Duplicated design points are removed. Duplicated points are not generated in a reasonable space-filling design, but the way discrete parameters and also parameter dependencies are handled make this possible. If we removed some points, we now try to augment the design in a space-filling way and iterate.

Usage

generateDesign(n = 10L, par.set, fun, fun.args = list(), trafo = FALSE,
  augment = 20L)

Arguments

n
[integer(1)] Number of samples in design. Default is 10.
par.set
[ParamSet] Parameter set.
fun
[function] Function from package lhs. Possible are: maximinLHS, randomLHS, geneticLHS
fun.args
[list] List of further arguments passed to fun.
trafo
[logical(1)] Transform all parameters by using theirs respective transformation functions. Default is FALSE.
augment
[integer(1)] Duplicated values and forbidden regions in the parameter space can lead to the design becoming smaller than n. With this option it is possible to augment the design again to size n. It is not guaranteed

Value

  • The created design is a data.frame. Columns are named by the ids of the parameters. If the par.set argument contains a vector parameter, its corresponding column names in the design are the parameter id concatenated with 1 to dimension of the vector. The result will have an logical(1) attribute trafo, which is set to the value of argument trafo.

Examples

Run this code
ps = makeParamSet(
  makeNumericParam("x1", lower = -2, upper = 1),
  makeIntegerParam("x2", lower = 10, upper = 20)
)
# random latin hypercube design with 5 samples:
generateDesign(5, ps)

# with trafo
ps = makeParamSet(
  makeNumericParam("x", lower = -2, upper = 1),
  makeNumericVectorParam("y", len = 2, lower = 0, upper = 1, trafo = function(x) x/sum(x))
)
generateDesign(10, ps, trafo = TRUE)

Run the code above in your browser using DataLab