Learn R Programming

propagate (version 1.3-0)

sobol: Sobol' sensitivity indices from a propagate object or sample matrices

Description

Computes first-order and total-order Sobol' sensitivity indices from an object returned by propagate, using its Monte Carlo simulated samples, or from two external sample matrices and an expression.

Usage

sobol(prop = NULL, A = NULL, B = NULL, expr = NULL, 
        method = c("jansen", "saltelli", "sobol", "homma"))

Value

A list with the following components:

S

vector of first-order indices \(S_i\) (NA for method = "homma").

ST

vector of total-order indices \(S_{T_i}\).

method

the method used.

N

the number of rows \(M\) used, after removal of non-finite evaluations.

V

the pooled output variance \(V\).

f0

the pooled output mean before centring.

Arguments

prop

a propagate object.

A

an \(M \times N\) matrix of Monte Carlo samples with column names matching the variables in expr. Only used together with B and expr.

B

a second \(M \times N\) matrix, sampled independently of A from the same distributions, with identical dimensions and column names.

expr

an expression to be evaluated on the rows of A, B and the hybrid matrices.

method

the estimator(s) for the sensitivity indices. See 'Details'.

Author

Andrej-Nikolai Spiess

Details

Sampling design: \(\mathbf{A}\) and \(\mathbf{B}\) are two independent \(M \times N\) sample matrices of the inputs. For each input \(X_i\), the hybrid matrix \(\mathbf{A}_B^{(i)}\) equals \(\mathbf{A}\) except for column \(i\), which is taken from \(\mathbf{B}\). The model is evaluated on \(\mathbf{A}\), \(\mathbf{B}\) and all \(N\) hybrid matrices, i.e. \(M(N + 2)\) evaluations in total (Saltelli 2002; Saltelli et al. 2010).

If prop is supplied, \(\mathbf{A}\) and \(\mathbf{B}\) are the two independent copula draws prop$datSIM and prop$datSIM2. For type = "sim" objects, which contain only the user-supplied samples, the rows are split into two halves that serve as \(\mathbf{A}\) and \(\mathbf{B}\). This requires the rows to be independent draws.

Mean, variance and centring: All model outputs are first centred on their pooled mean. This leaves every estimator unchanged in expectation, but it is essential for the product-type estimators ("sobol", "saltelli" first-order, "homma"): without centring, their Monte Carlo variance scales with \(f_0^2\) and they become unusable when \(|f_0| \gg \sigma_Y\), the typical situation in metrology (see 'Examples'). The pooled mean and variance of the centred outputs are $$ f_0 = \frac{1}{2M} \sum_{v=1}^{M} \left[ f(\mathbf{A})_v + f(\mathbf{B})_v \right], \quad V = \frac{1}{2M - 1} \sum_{v=1}^{M} \left[ \left( f(\mathbf{A})_v - f_0 \right)^2 + \left( f(\mathbf{B})_v - f_0 \right)^2 \right]. $$ Rows for which any of the \(N + 2\) evaluations is not finite are removed from all of them.

Estimators: All sums run over \(v = 1, \ldots, M\). The first-order index \(S_i\) is the fraction of the output variance explained by \(X_i\) alone; the total-order index \(S_{T_i}\) additionally includes all interactions of \(X_i\) with the other inputs.

method = "jansen" (default), Jansen (1999) for both indices: $$ S_i = \frac{V - \frac{1}{2M} \sum_v \left[ f(\mathbf{B})_v - f(\mathbf{A}_B^{(i)})_v \right]^2}{V}, \quad S_{T_i} = \frac{\frac{1}{2M} \sum_v \left[ f(\mathbf{A})_v - f(\mathbf{A}_B^{(i)})_v \right]^2}{V} $$ Both estimators are built from squared differences only and are therefore insensitive to the output mean even without centring.

method = "saltelli", Saltelli et al. (2010) for \(S_i\) and Jansen (1999) for \(S_{T_i}\), the combination recommended by Saltelli et al. (2010): $$ S_i = \frac{\frac{1}{M} \sum_v f(\mathbf{B})_v \left[ f(\mathbf{A}_B^{(i)})_v - f(\mathbf{A})_v \right]}{V}, \quad S_{T_i} \textrm{ as for Jansen (1999).} $$

method = "sobol", Sobol' (1993) for \(S_i\) and Sobol' (2001) for \(S_{T_i}\): $$ S_i = \frac{\frac{1}{M} \sum_v f(\mathbf{B})_v \, f(\mathbf{A}_B^{(i)})_v - f_0^2}{V}, \quad S_{T_i} = \frac{\frac{1}{M} \sum_v f(\mathbf{A})_v \left[ f(\mathbf{A})_v - f(\mathbf{A}_B^{(i)})_v \right]}{V} $$ Sobol' (1993) is usually written with the pair \(f(\mathbf{A})_v f(\mathbf{B}_A^{(i)})_v\). Here the mirror pair \(f(\mathbf{B})_v f(\mathbf{A}_B^{(i)})_v\) is used, which also shares \(X_i\) and differs in all other inputs, so that no second set of hybrid matrices is needed.

method = "homma", Homma & Saltelli (1996), total-order index only (S is NA): $$ S_{T_i} = \frac{V - \frac{1}{M} \sum_v f(\mathbf{A})_v \, f(\mathbf{A}_B^{(i)})_v + f_0^2}{V} $$

The estimators and their notation follow Tables 1 and 2 of Puy et al. (2022). Jansen (1999) is recommended as the default because it is robust and needs no \(f_0\) correction. The estimators differ in their Monte Carlo variance, not in their expectation, so all methods converge to the same indices with increasing \(M\).

Dependent inputs: Sobol' indices are based on the functional ANOVA decomposition, which assumes independent inputs. With correlated inputs (a correlated Gaussian copula, cov = "full" or an external covariance matrix in propagate), the hybrid matrices \(\mathbf{A}_B^{(i)}\) no longer follow the joint input distribution, and the indices lose their interpretation as shares of the output variance. sobol warns if any empirical input correlation exceeds \(4/\sqrt{M}\) in absolute value (about four standard errors under independence). Inputs from mc.margins = "mvt" always trigger a warning, because the multivariate t-distribution couples all inputs through a common chi-square variable even when they are uncorrelated.

References

Sensitivity estimates for nonlinear mathematical models.
Sobol IM.
Math Model Comput Exp (1993), 1: 407-414.

Global sensitivity indices for nonlinear mathematical models and their Monte Carlo estimates.
Sobol IM.
Math Comp Sim (2001), 55: 271-280.

Importance measures in global sensitivity analysis of nonlinear models.
Homma T, Saltelli A.
Rel Eng Sys Safety (1996), 52: 1-17.

Analysis of variance designs for model output.
Jansen MJW.
Comp Phys Comm (1999), 117: 35-43.

Making best use of model evaluations to compute sensitivity indices.
Saltelli A.
Comp Phys Comm (2002), 145: 280-297.

Variance based sensitivity analysis of model output. Design and estimator for the total sensitivity index.
Saltelli A, Annoni P, Azzini I, Campolongo F, Ratto M, Tarantola S.
Comp Phys Comm (2010), 181: 259-270.

sensobol: an R package to compute variance-based sensitivity indices.
Puy A, Lo Piano S, Saltelli A, Levin SA.
J Stat Softw (2022), 102(5): 1-37.

An importance quantification technique in uncertainty analysis for computer models.
Ishigami T, Homma T.
Proceedings of the First International Symposium on Uncertainty Modeling and Analysis (1990): 398-403.

See Also

propagate, stochContr.

Examples

Run this code
## Example from 'propagate', independent inputs.
EXPR1 <- expression(x/y)
x <- c(5, 0.01, 12)
y <- c(1, 0.01, 5)
DF1 <- cbind(x, y)
RES1 <- propagate(expr = EXPR1, data = DF1, type = "stat", nsim = 10000, check = FALSE)
sobol(RES1)

## Classical Ishigami function (a = 7, b = 0.1) for gauging.
## Analytical values:
##   S  = 0.3139, 0.4424, 0
##   ST = 0.5576, 0.4424, 0.2437
## Homma & Saltelli (1996), Table 4, total-order: 0.557, 0.444, 0.241
set.seed(123)
N <- 1e5
A <- cbind(x1 = runif(N, -pi, pi), x2 = runif(N, -pi, pi), x3 = runif(N, -pi, pi))
B <- cbind(x1 = runif(N, -pi, pi), x2 = runif(N, -pi, pi), x3 = runif(N, -pi, pi))
EXPR2 <- expression(sin(x1) + 7 * (sin(x2))^2 + 0.1 * x3^4 * sin(x1))
sobol(A = A, B = B, expr = EXPR2, method = "jansen")
sobol(A = A, B = B, expr = EXPR2, method = "saltelli")
sobol(A = A, B = B, expr = EXPR2, method = "sobol")
sobol(A = A, B = B, expr = EXPR2, method = "homma")

## Same function with a large offset, as for a measurand whose mean is
## much larger than its uncertainty. Thanks to the internal centring,
## all methods return the same indices as above.
EXPR3 <- expression(1E4 + sin(x1) + 7 * (sin(x2))^2 + 0.1 * x3^4 * sin(x1))
sobol(A = A, B = B, expr = EXPR3, method = "saltelli")

## Simulated inputs (type = "sim"): GUM Supplement 1, 9.3, mass calibration.
## The simulated rows are split into A and B. The constants Pa0 and Mnom get
## first-order indices within Monte Carlo noise of 0 (here about 0.006) and
## total indices exactly 0. Pa and Pw have S about 0 but ST about 0.5:
## they act only through their interaction (Pa - Pa0) * (1/Pw - 1/Pr).
EXPR4 <- expression((Mrc + dMrc) * (1 + (Pa - Pa0) * ((1/Pw) - (1/Pr))) - Mnom)
Mrc <- rnorm(1E5, 100000, 0.050)
dMrc <- rnorm(1E5, 1.234, 0.020)
Pa <- runif(1E5, 1.10, 1.30)
Pw <- runif(1E5, 7000, 9000)
Pr <- runif(1E5, 7950, 8050)
Pa0 <- 1.2
Mnom <- 100000
DF4 <- cbind(Mrc, dMrc, Pa, Pw, Pr, Pa0, Mnom)
RES4 <- propagate(expr = EXPR4, data = DF4, type = "sim", check = FALSE)
sobol(RES4)

Run the code above in your browser using DataLab