# Bootstrap in Global Sensitivity Analysis (GSA)

**URL:** <https://discourse.julialang.org/t/bootstrap-in-global-sensitivity-analysis-gsa/103045>\
**Category:** Modelling & Simulations\
**Tags:** bootstrap\
**Created:** [August 21, 2023, 6:23pm UTC](https://discourse.julialang.org/t/bootstrap-in-global-sensitivity-analysis-gsa/103045 "2023-08-21T18:23:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xztt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xztt/32/33843_2.png) [@xztt](https://discourse.julialang.org/u/xztt)\
**Post date:** [August 21, 2023, 6:23pm UTC](https://discourse.julialang.org/t/bootstrap-in-global-sensitivity-analysis-gsa/103045/1 "2023-08-21T18:23:50Z")

</div>

Hi There,

Running the basic example below the bootstrapping just returns

```julia
nothing

```

So no standard errors are returned at all. Playing with sobolsensitivity.jl package if I go in and hard code nboot I can return bootstrapped runs it appears the nboot keyword is not recognised in the package. I have tried my best at having a crack at this but I think I have become stuck in how to fix this.

I am sorry I could not help more, MWE is down below

Cheers,  
Harry

```julia
using GlobalSensitivity, Statistics, OrdinaryDiffEq, QuasiMonteCarlo, Plots

function f(du,u,p,t)
    du[1] = p[1]*u[1] - p[2]*u[1]*u[2] #prey
    du[2] = -p[3]*u[2] + p[4]*u[1]*u[2] #predator
end

u0 = [1.0;1.0]
tspan = (0.0,10.0)
p = [1.5,1.0,3.0,1.0]
prob = ODEProblem(f,u0,tspan,p)
t = collect(range(0, stop=10, length=200))

f1 = function (p)
    prob1 = remake(prob;p=p)
    sol = solve(prob1,Tsit5();saveat=t)
    [mean(sol[1,:]), maximum(sol[2,:])]
end

samples = 10000
lb = [1.0, 1.0, 1.0, 1.0]
ub = [5.0, 5.0, 5.0, 5.0]
sampler = SobolSample()
A,B = QuasiMonteCarlo.generate_design_matrices(samples,lb,ub,sampler)

sobol_result = gsa(f1,Sobol(),A,B, nboot = 1000)

sobol_result.S1
sobol_result.S1_Conf_Int

```

---

<div class="post-metadata">

**Author:** ![algunion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/algunion/32/51630_2.png) [@algunion](https://discourse.julialang.org/u/algunion)\
**Post date:** [August 22, 2023, 12:46am UTC](https://discourse.julialang.org/t/bootstrap-in-global-sensitivity-analysis-gsa/103045/2 "2023-08-22T00:46:39Z")

</div>

`gsa` for `Sobol` (also) uses `nboot` set via `Sobol(...)` and the reason you get `nothing` is that the default of `Sobol`’s `nboot` is equal to `1`. You can still set a `nboot` for `gsa` which is independent of the `nboot` passed to `Sobol` constructor. However, if you only pass `nboot` via `Sobol`, then the `gsa`’s `nboot` will be set to the same value. I hope this makes sense to you.

Try alter the relevant line in the following way:

```julia
# your previous code here

# please note `nboot` keyword in `Sobol` constructor
sobol_result = gsa(f1, Sobol(nboot=1000), A, B)

# you'll get a Matrix{Float64} here
sobol_result.S1_Conf_Int

```

Have fun.
