lhs.design {DoE.wrapper} | R Documentation |

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.

```
lhs.design(nruns, nfactors, type="optimum", factor.names=NULL, seed=NULL, digits=NULL,
nlevels = nruns, default.levels = c(0, 1), randomize = FALSE, ...)
lhs.augment(lhs, m=1, type="optAugment", seed=NULL, ...)
```

`nruns` |
number of runs in the latin hypercube sample; |

`nfactors` |
number of factors in the latin hypercube sample |

`type` |
character string indicating the type of design or augmentation method;
defaults are “optimum” for |

`seed` |
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. |

`factor.names` |
list of scale end values for each factor;
names are used as variable names; |

`digits` |
digits to which the design columns are rounded; one single value
(the same for all factors) or a vector of length |

`nlevels` |
used for type |

`default.levels` |
scale ends for all factors; convenient, if all factors have the same scaling that deviates from the default 0/1 scale ends. |

`randomize` |
logical that prevents randomization per default. The option has an effect
for types |

`lhs` |
design generated by function |

`m` |
integer number of additional points to add to design |

`...` |
additional arguments to the functions from packages lhs
or DiceDesign.
Refer to their documentation. |

Function `lhs.design`

creates a latin hypercube sample,
function `lhs.augment`

augments an existing latin hypercube sample (or in case of
type `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
class `design`

.

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
packages `lhs`

and `DiceDesign`

.

Both functions return a data frame of S3 class `design`

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.

Function `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.

The attribute `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=fact`

or `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
randomization.

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.

The attribute `design.info`

is a list of various design properties, with type resolving to “lhs”.
In addition to the standard list elements (cf. `design`

), the `subtype`

element indicates the type of latin hypercube designs and possibly additional augmentations, the element
`quantitative`

is a vector of `nfactor`

logical TRUEs,
and the `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 `design.info`

.

`randomize`

is always TRUE for designs generated by random sampling, but may be FALSE for
designs created with `type=fact`

or `type=faure`

.

`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 `design`

.

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 `randomize`

.

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.

Ulrike Groemping

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.

See Also `compare`

for comparing optimality criteria for various
designs,

`lhs-package`

and
`DiceDesign-package`

for the packages that do the calculations,

`FrF2`

, `oa.design`

,
`fac.design`

, `pb`

for other possibilites of generating designs

```
## 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)
```

[Package *DoE.wrapper* version 0.11 Index]