model is a function or a predictor (a class with a
predict method) computing the response y based on the
sample given by x. If no model is specified, the indices will be
computed when one gives the response. The Monte Carlo estimation requires two independent random samples
x1 and x2. They must have the same dimensions.
The computing scheme is based on replacement of a column of a sample
by the corresponding one of the other sample. We note
${x1,i,x2}$ the sample where all the columns are taken
from x1, except the i-th one that is taken from x2.
Then, the first order index corresponding to the i-th factor is given
by:
$$S_i=\frac{D_i}{\mathrm{Var}(Y)}$$
where
$$D_i = \frac{1}{n-1} \sum_{j=1}^n f(x2_j) f({x1,i,x2}_j)
- \frac{1}{n} \sum_{j=1}^n f(x1_j) f(x2_j)$$
and the total order index is given by:
$$St_i=1 - \frac{Dt_i}{\mathrm{Var}(Y)}$$
where
$$Dt_i = \frac{1}{n-1} \sum_{j=1}^n f(x1_j) f({x1,i,x2}_j)
- \left[ \frac{1}{n} \sum_{j=1}^n f(x1_j) \right]^2$$
With this method, the estimation of all the first order indices and
total indices require $n(p+2)$ calls to the model,
with $n$ the length of the samples x1 and x2,
and $p$ the number of factors.