Description Usage Arguments Details Value Warning Note Author(s) References See Also Examples
Functions for comfortably accessing latin hypercube sampling designs from package lhs or space-filling designs from package DiceDesign, which are useful for quantitative factors with many possible levels. In particular, they can be used in computer experiments. Most of the designs are random samples.
1 2 3
number of runs in the latin hypercube sample;
number of factors in the latin hypercube sample
character string indicating the type of design or augmentation method;
defaults are “optimum” for
seed for random number generation; latin hypercube samples from package lhs are random samples. Specifying a seed used to make the result reproducible for early versions of package lhs - lately, results are reproducible within a package version, but reproducibility between package versions cannot be guaranteed.
list of scale end values for each factor;
names are used as variable names;
digits to which the design columns are rounded; one single value
(the same for all factors) or a vector of length
used for type
scale ends for all factors; convenient, if all factors have the same scaling that deviates from the default 0/1 scale ends.
logical that prevents randomization per default. The option has an effect
design generated by function
integer number of additional points to add to design
additional arguments to the functions from packages lhs
Refer to their documentation.
lhs.design creates a latin hypercube sample,
lhs.augment augments an existing latin hypercube sample (or in case of
optSeeded takes the existing sample as the starting point but potentially modifies it).
In comparison to direct usage of package lhs, the functions add the possibility
of recoding lhs samples to a desired range, and they embed the lhs designs into
Range coding is based on the recoding facility from package rsm and the
factor.names parameter used analogously to packages DoE.base and FrF2.
The lhs designs are useful for quantitative factors, if it is considered desirable to uniformly distribute design points over a hyperrectangular space. This is e.g. considered interesting for computer experiments, where replications of the same settings are often useless.
Supported design types are described in the documentation for
Both functions return a data frame of S3 class
with attributes attached.
The data frame contains the experimental settings as recoded to the scale ends defined in factor.names (if given),
rounded to the number of digits given in
digits (if given).
The experimental factors in the matrix
desnum attached as attribute
desnum contain the
design in the unit cube (all experimental factors ranging from 0 to 1) as
returned by packages lhs or DiceDesign.
lhs.augment preserves additional variables (e.g. responses) that
have been added to the design
lhs before augmenting. Note, however, that
the response data are NOT used in deciding about which points to augment the design with.
run.order is not very useful for most of these designs, as there is no standard order.
It therefore is present for formal reasons only and contains three identical columns of 1,2,...,nruns.
For designs created with
type=faure, the standard order is the order
in which package DiceDesign creates the design, and the actual run order may be different in case of
In case of
lhs.augment, if the design to be augmented had been reordered before,
the augmented design preserves this reorder and also the respective numbering of the design.
design.info is a list of various design properties, with type resolving to “lhs”.
In addition to the standard list elements (cf.
element indicates the type of latin hypercube designs and possibly additional augmentations, the element
quantitative is a vector of
nfactor logical TRUEs,
digits elements indicates the digits to which the data were rounded.
For designs created with package DiceDesign, special list elements from this package are also added to
randomize is always TRUE for designs generated by random sampling, but may be FALSE for
designs created with
coding provides formulae for making the designs comfortably usable with
standard second order methodology implemented in package rsm.
replications is always 1 and
repeat.only is always FALSE;
these elements are only present to fulfill the formal requirements for class
Since R version 3.6.0, the behavior of function
sample has changed
(correction of a biased previous behavior that should not be relevant for the randomization of designs).
For using code that randomizes a design interchangeably between a new R version (3.6.0 or later)
and an older one, please follow the steps described with the argument
Note also: Package lhs does not promise to keep designs reproducible between package versions. Thus, please make sure to store important designs for the future, if needed (of course, this is always wise anyway!).
This package is still under (slow) development. Reports about bugs and inconveniences are welcome.
Beachkofski, B., Grandhi, R. (2002) Improved Distributed Hypercube Sampling. American Institute of Aeronautics and Astronautics Paper 1274.
Currin C., Mitchell T., Morris M. and Ylvisaker D. (1991) Bayesian Prediction of Deterministic Functions With Applications to the Design and Analysis of Computer Experiments, Journal of the American Statistical Association 86, 953–963.
Santner T.J., Williams B.J. and Notz W.I. (2003) The Design and Analysis of Computer Experiments, Springer, 121–161.
Shewry, M. C. and Wynn and H. P. (1987) Maximum entropy sampling. Journal of Applied Statistics 14, 165–170.
Fang K.-T., Li R. and Sudjianto A. (2006) Design and Modeling for Computer Experiments, Chapman & Hall.
Stein, M. (1987) Large Sample Properties of Simulations Using Latin Hypercube Sampling. Technometrics 29, 143–151.
Stocki, R. (2005) A method to improve design reliability using optimal Latin hypercube sampling. Computer Assisted Mechanics and Engineering Sciences 12, 87–105.
compare for comparing optimality criteria for various
DiceDesign-package for the packages that do the calculations,
pb for other possibilites of generating designs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
## maximin design from package lhs plan <- lhs.design(20,7,"maximin",digits=2) plan plot(plan) cor(plan) y <- rnorm(20) r.plan <- add.response(plan, y) ## augmenting the design with 10 additional points, default method plan2 <- lhs.augment(plan, m=10) plot(plan2) cor(plan2) ## purely random design (usually not ideal) plan3 <- lhs.design(20,4,"random", factor.names=list(c(15,25), c(10,90), c(0,120), c(12,24)), digits=2) plot(plan3) cor(plan3) ## optimum design from package lhs (default) plan4 <- lhs.design(20,4,"optimum", factor.names=list(torque=c(10,14),friction=c(25,35), temperature=c(-5,35),pressure=c(20,50)),digits=2) plot(plan4) cor(plan4) ## dmax design from package DiceDesign ## arguments range and niter_max are required ## ?dmaxDesign for more info plan5 <- lhs.design(20,4,"dmax", factor.names=list(torque=c(10,14),friction=c(25,35), temperature=c(-5,35),pressure=c(20,50)),digits=2, range=0.2, niter_max=500) plot(plan5) cor(plan5) ## Strauss design from package DiceDesign ## argument RND is required ## ?straussDesign for more info plan6 <- lhs.design(20,4,"strauss", factor.names=list(torque=c(10,14),friction=c(25,35), temperature=c(-5,35),pressure=c(20,50)),digits=2, RND = 0.2) plot(plan6) cor(plan6) ## full factorial design from package DiceDesign ## mini try-out version plan7 <- lhs.design(3,4,"fact", factor.names=list(torque=c(10,14),friction=c(25,35), temperature=c(-5,35),pressure=c(20,50)),digits=2) plot(plan7) cor(plan7) ## Not run: ## full factorial design from package DiceDesign ## not as many different levels as runs, but only a fixed set of levels ## caution: too many levels can easily bring down the computer ## above design with 7 distinct levels for each factor, ## implying 2401 runs plan7 <- lhs.design(7,4,"fact", factor.names=list(torque=c(10,14),friction=c(25,35), temperature=c(-5,35),pressure=c(20,50)),digits=2) plot(plan7) cor(plan7) ## equivalent call plan7 <- lhs.design(,4,"fact",nlevels=7, factor.names=list(torque=c(10,14),friction=c(25,35), temperature=c(-5,35),pressure=c(20,50)),digits=2) ## different number of levels for each factor plan8 <- lhs.design(,4,"fact",nlevels=c(5,6,5,7), factor.names=list(torque=c(10,14),friction=c(25,35), temperature=c(-5,35),pressure=c(20,50)),digits=2) plot(plan8) cor(plan8) ## equivalent call (specifying nruns, not necessary but a good check) plan8 <- lhs.design(1050,4,"fact",nlevels=c(5,6,5,7), factor.names=list(torque=c(10,14),friction=c(25,35), temperature=c(-5,35),pressure=c(20,50)),digits=2) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.