Learn R Programming

pse (version 0.3.0)

LHS: Latin Hypercube Sampling for uncertainty and sensitivity analyses

Description

Generates the Latin Hypercube sampling for uncertainty and sensitivity analyses. A Latin Hypercube of size N is generated from the desired quantile distribution functions and corrected to have a correlation matrix similar to the prescribed by the parameter COR.

The specified model is run with the data from the LHS. If repetitions is set to more than one, the model will be run several times for each data point.

Partial rank correlation coefficients are estimated.

When the LHS function is called with no model (i.e., with argument model=NULL), it generates an incomplete object storing the Latin Hypercube samples, and allowing the user to run the simulation model independently. The method tell allows to pass the simulation results to the incomplete object.

Usage

LHS(model = NULL, factors, N, q, q.arg, res.names = NULL, 
	COR, eps = 5e-04, nboot = 0, repetitions=1)
## S3 method for class 'LHS':
tell(x, y, res.names = NULL, nboot = 0, \dots)
## S3 method for class 'LHS':
print(x, \dots)

Arguments

model
The function to be run, representing the model or simulation. If NULL, no function is run and the object generated is incomplete, see also the tell method.
factors
The names of the input variables (used for naming the 'data' data.frame and in plotting) Either a vector of strings or a single number representing the number of factors
N
The size of the hypercube, i.e., how many samples are generated. Must be at least the number of factors plus 2.
q
The quantile functions to be used. If only one is provided, it will be used for all parameters. Defaults to "qunif".
q.arg
A list containing the arguments for the 'q' functions. Each parameter must be specified by a named list, containing all of the arguments for the quantile distribution. If unsupplied, default values for the parameters are used.
res.names
Optional: what are the names of the model results? (Used mainly for plotting)
COR
The desired correlation matrix between the model variables. If none is provided, the function will generate a zero-correlation Latin Hypercube.
eps
The tolerance between the prescribed correlation and the actual correlation present in the generated Latin Hypercube.
nboot
Number of bootstrap replicates for calculating the PRCC.
repetitions
The number of model repetitions to be run for a single data point. See the vignette on stochastic models for details
x
An incomplete LHS object (created with model=NULL)
y
A data.frame containing the model responses
...
Currently ignored

Value

  • An object of the class LHS.

Warning

NOTE: the tell method from sensitivity objects (like 'fast99') modifies the object passed as argument as a side effect. This is NOT the case with the LHS tell method.

References

McKay, M.D. and Beckman, R.J. A comparison of three methods for selecting values of input variables in the analysis of output from a computer code, Technometrics. 1979, 21: 239-244

Examples

Run this code
completelHS <- LHS(model=function(x) x[,1]+x[,2]*x[,3], factors=3, N=20)
incompleteLHS <- LHS(factors=5, N=30)
incompleteLHS <- tell(incompleteLHS, seq(1,30))

Run the code above in your browser using DataLab