Hi Hana,
I can't see anything wrong in the code you posted, except I am not totally sure about the definition of the objective, but I think it should work.
So unless there is something in your "modx" that is not right then I am not sure.
I had the following in my code (which looks very similar):
# redefine the model, but with ranges of parameters
CMod <- hydromad(CoolacData[1:2000], sma="gr4j", routing="gr4jrouting",
etmult=c(0.05,0.5),x1 = c(100,1500), x2 = c(-30,20),
x3 =c(5,500), x4 = c(0.5,10))
# again of samples from the parameter sets
n <- 1000
# Find the parameter ranges from your model
# Make sure you define the right model!
X1 <- hydromad::parameterSets(getFreeParsRanges(CMod),n)
X2 <- hydromad::parameterSets(getFreeParsRanges(CMod),n)
# run the sensitivity
Sob_sens <- sobol2002(model = evalPars,
# using these parameter ranges
X1 = X1, X2 = X2,
# relates to the boot strapping in the analysis
nboot = 100,
# The model to use
object=CMod,
# The objective function to use
objective=~hmadstat("r.squared")(Q,X)
)
# Show output
Sob_sens
Willem