Learn R Programming

sensitivity (version 1.30.1)

sobolroalhs: Sobol' Indices Estimation Using Replicated OA-based LHS

Description

sobolroalhs implements the estimation of the Sobol' sensitivity indices introduced by Tissot & Prieur (2015) using two replicated designs (Latin hypercubes or orthogonal arrays). This function estimates either all first-order indices or all closed second-order indices at a total cost of \(2 \times N\) model evaluations. For closed second-order indices \(N=q^{2}\) where \(q \geq d-1\) is a prime number corresponding to the number of levels of the orthogonal array, and where \(d\) indicates the number of factors.

Usage

sobolroalhs(model = NULL, factors, N, p=1, order, tail=TRUE, conf=0.95, nboot=0, ...)
# S3 method for sobolroalhs
tell(x, y = NULL, ...)
# S3 method for sobolroalhs
print(x, ...)
# S3 method for sobolroalhs
plot(x, ylim = c(0,1), ...)
# S3 method for sobolroalhs
ggplot(data, mapping = aes(), ylim = c(0, 1), ..., environment
                 = parent.frame())

Value

sobolroalhs returns a list of class "sobolroalhs", containing all the input arguments detailed before, plus the following components:

call

the matched call.

X

a data.frame containing the design of experiments (row concatenation of the two replicated designs).

y

the responses used.

OA

the orthogonal array constructed (NULL if order=1).

V

the estimations of Variances of the Conditional Expectations (VCE) with respect to each factor.

S

the estimations of the Sobol' indices.

Arguments

model

a function, or a model with a predict method, defining the model to analyze.

factors

an integer giving the number of factors, or a vector of character strings giving their names.

N

an integer giving the size of each replicated design (for a total of \(2 \times N\) model evaluations).

p

an integer giving the number of model outputs.

order

an integer giving the order of the indices (1 or 2).

tail

a boolean specifying the method used to choose the number of levels of the orthogonal array (see "Warning messages").

conf

the confidence level for confidence intervals.

nboot

the number of bootstrap replicates.

x

a list of class "sobolroalhs" storing the state of the sensitivity study (parameters, data, estimates).

data

a list of class "sobolroalhs" storing the state of the sensitivity study (parameters, data, estimates).

y

a vector of model responses.

ylim

y-coordinate plotting limits.

mapping

Default list of aesthetic mappings to use for plot. If not specified, must be supplied in each layer added to the plot.

environment

[Deprecated] Used prior to tidy evaluation.

...

any other arguments for model which are passed unchanged each time it is called.

Warning messages

"The value entered for N is not the square of a prime number. It has been replaced by: "

when order\(=2\), the number of levels of the orthogonal array must be a prime number. If N is not a square of a prime number, then this warning message indicates that it was replaced depending on the value of tail. If tail=TRUE (resp. tail=FALSE) the new value of N is equal to the square of the prime number preceding (resp. following) the square root of N.

"The value entered for N is not satisfying the constraint \(N \geq (d-1)^2\). It has been replaced by: "

when order\(=2\), the following constraint must be satisfied \(N \geq (d-1)^{2}\) where \(d\) is the number of factors. This warning message indicates that N was replaced by the square of the prime number following (or equals to) \(d-1\).

Author

Laurent Gilquin

Details

sobolroalhs automatically assigns a uniform distribution on [0,1] to each input. Transformations of distributions (between U[0,1] and the wanted distribution) have to be realized before the call to tell() (see "Examples").

Missing values (i.e NA values) in outputs are automatically handled by the function.

This function also supports multidimensional outputs (matrices in y or as output of model). In this case, aggregated Sobol' indices are returned (see sobolMultOut).

References

A.S. Hedayat, N.J.A. Sloane and J. Stufken, 1999, Orthogonal Arrays: Theory and Applications, Springer Series in Statistics.

F. Gamboa, A. Janon, T. Klein and A. Lagnoux, 2014, Sensitivity indices for multivariate outputs, Electronic Journal of Statistics, 8:575-603.

J.Y. Tissot and C. Prieur, 2015, A randomized orthogonal orray-based procedure for the estimation of first- and second-order Sobol' indices, J. Statist. Comput. Simulation, 85:1358-1381.

See Also

sobolmara, sobolroauc, sobolMultOut

Examples

Run this code
library(boot)
library(numbers)

####################
# Test case: the non-monotonic Sobol g-function

# The method of sobol requires 2 samples
# (there are 8 factors, all following the uniform distribution on [0,1])

# first-order sensitivity indices
x <- sobolroalhs(model = sobol.fun, factors = 8, N = 1000, order = 1, nboot=100)
print(x)
plot(x)

library(ggplot2)
ggplot(x)

# closed second-order sensitivity indices
x <- sobolroalhs(model = sobol.fun, factors = 8, N = 1000, order = 2, nboot=100)
print(x)
ggplot(x)

####################
# Test case: dealing with non-uniform distributions

x <- sobolroalhs(model = NULL, factors = 3, N = 1000, order =1, nboot=0)

# X1 follows a log-normal distribution:
x$X[,1] <- qlnorm(x$X[,1])

# X2 follows a standard normal distribution:
x$X[,2] <- qnorm(x$X[,2])

# X3 follows a gamma distribution:
x$X[,3] <- qgamma(x$X[,3],shape=0.5)

# toy example
toy <- function(x){rowSums(x)}
y <- toy(x$X)
tell(x, y)
print(x)
ggplot(x)

####################
# Test case : multidimensional outputs

# \donttest{
toy <- function(x){cbind(x[,1]+x[,2]+x[,1]*x[,2],2*x[,1]+3*x[,1]*x[,2]+x[,2])}
x <- sobolroalhs(model = toy, factors = 3, N = 1000, p=2, order =1, nboot=100)
print(x)
ggplot(x)
# }

Run the code above in your browser using DataLab