Learn R Programming

ParamHelpers (version 1.1-36)

generateDesign: Generates a statistical design for a parameter set.

Description

Currently only lhs designs are supported.

Usage

generateDesign(n = 10L, par.set, fun, fun.args = list(),
    trafo = FALSE, ints.as.num = FALSE,
    discretes.as.factor = TRUE, logicals.as.factor = FALSE)

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, genetic
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.
ints.as.num
[logical(1)] Should parameters of type integer or integervector generate numeric columns? Default is FALSE.
discretes.as.factor
[logical(1)] Should discrete parameters have columns of type factor in result? Otherwise character columns are generated. Default is TRUE.
logicals.as.factor
[logical(1)] Should logical parameters have columns of type factor in result? Otherwise logical columns are generated. Default is FALSE.

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 data type of a column is defined in the following way. Numeric parameters generate numeric columns, integer parameters generate numeric/integer columns, logical parameters generate logical/factor columns. For discrete parameters the value names are used and character or factor columns are generated. Dependent parameters whose constaints are unsatisfied generate NA entries in their respective columns. 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