How to create interactive sliders in a Pluto plot for variables of an ODE function?

Hello Julia community, and obligatory I-am-new-to-Julia-so-I-apologise-if-my-question-is-silly.

I am attempting to build a basic SEIR epidemiological model of disease spread based off of this tutorial at Quant Econ.

In this, an Ordinary Differential Equation (ODE) problem is defined using OrdinaryDiffEq.jl and the solution is output and plotted on a graph to understand the dynamics of the change in the number of susceptible, exposed, infected and removed individuals as shown in the figure below.

I want to be able to use the variables nested inside the function (variables such as transmission rate, infection rate, recovery rate) as the Slider “children” in order to make the plot interactive and understand the dynamics of how that affects the Susceptible, Infected, Exposed and Removed individuals over time.

I understand that I would need to use PlutoUI for this, but I do not know or understand how to make sliders for variables in a function.

Any help would be greatly appreciated! Thank you.

1 Like

Maybe something like this

@bind slider1 Slider(0.0:0.01:1.0) 
@bind slider2... 
wrapped_simple(x, p, t) = F_simple(x, p, t; γ = slider1, R₀ = slider2, σ = slider3)
prob = ODEProblem(wrapped_simple, x_0, tspan)

Maybe something like this?
You create variables bound to your sliders using plutoui, and then you can easily create a wrapper around your initial function to create a new one that takes these variables as values. Now just use your wrapped function in the ode solver.

Don’t enclose then though, use them as parameter values.

I was thinking about that too since it feels like that is how DiffEq intends them to be used, but went with this because it was less changes for OP to make. Is there a difference in speed or is it just preferred because it is the interface that is used?

That QuantEcon tutorial should be changed as well