Dear list,

I would like to calculate Sobol indices (first-order and total indices) with the sobol2002 function in the 'sensitivity' package for a hydrologic model. The input of my model consists of a parameter vector, the output of a single value (agreement between observed and simulated stream flow). I cannot run my model for a parameter matrix (each line = parameter vector); therefore, I need a loop over lines.
However, sobol2002 does not seem to work for loops (see simplified code below).

#parameter dataframes
library(sensitivity)
n <- 10
X1 <- data.frame(matrix(runif(2 * n), nrow = n))
X2 <- data.frame(matrix(runif(2 * n), nrow = n))

#Function without loop
FUN1 <- function(X)
    {
        OUT <- X[,1]   
        OUT
    }
        
x_FUN1 <- sobol2002(model = FUN1, X1 = X1, X2 = X2, nboot = 100) ##works! 

#Function with loop
FUN2 <- function(X)
    {
        OUT <- rep(NA, n)
        for (i in 1:n) {OUT[i] <- X[i,1]}    
        OUT
    }
        
x_FUN2 <- sobol2002(model = FUN2, X1 = X1, X2 = X2, nboot = 100) ##fails! 

I am grateful for any hints, how I can use sobol2002 for a model based on a parameter vectors!
Regards,
Haeru



      
	[[alternative HTML version deleted]]


