Solved – Understanding Sobol in R Package Sensitivity

Sobol method quantifies the contributions of input variance to output variance. For example, given a model with two inputs and one output, one might find that 70% of the output variance is caused by the variance in the first input, 20% by the variance in the second, and 10% due to interactions between the two.

In R package "Sensitivity", a sample script of implementing Sobol method as below

``library("sensitivity") n<-1000 X1<-data.frame(matrix(runif(8*n), nrow=n)) X2<-data.frame(matrix(runif(8*n), nrow=n)) sa<-sobol2002(model=NULL, X1, X2, nboot=10) ``

I thought X1 is output matrix, and X2 is input matrix, so I could run analysis on different dimension of X1 and X2. but the function requires the same dimension of X1 and X2.

May I get intuitive explanation on what are X1 and X2?

Contents

Best Answer

X1 and X2 are both a subset of your input matrix. The method requires two samples. If your model runs in R you can use the model = your.model. Example from the package, slightly adapted

``n <- 1000 X1 <- data.frame(matrix(runif(8 * n), nrow = n)) X2 <- data.frame(matrix(runif(8 * n), nrow = n))  # Sensitivity analysis x <- sobol2002(model = sobol.fun, X1, X2, nboot = 100) print(x) plot(x) ``

if your model runs in a different programm you need to use the function tell. You have to set the model=NULL

``n <- 1000 X1 <- data.frame(matrix(runif(8 * n), nrow = n)) X2 <- data.frame(matrix(runif(8 * n), nrow = n))  #Sensitivity analysis x <- sobol2002(model = NULL, X1, X2, nboot = 100) y <- ishigami.fun(x\$X) tell(x,y) print(x) plot(x) ``

Rate this post