EasyModelAnalysis.bayesian_datafitMethod
bayesian_datafit(prob, p, t, data)
bayesian_datafit(prob, p, data)

Calculate posterior distribution for parameters p given data measured at times t.

Data Definition

The data definition is given as a vctor of pairs. If t is specified globally for the datafit, then those time series correspond to the time points specified. For example,

[x => [11.352378507900013, 11.818374125301172, -10.72999081810307]
 z => [2.005502877055581, 13.626953144513832, 5.382984515620634, 12.232084518374545]]

then if datafit(prob, p, t, data), t must be length 3 and these values correspond to x(t[i]).

If datafit(prob, p, data), then the data must be a tuple of (t, timeseries), for example:

[x => ([1.0, 2.0, 3.0], [11.352378507900013, 11.818374125301172, -10.72999081810307])
 z => ([0.5, 1.5, 2.5, 3.5],
     [2.005502877055581, 13.626953144513832, 5.382984515620634, 12.232084518374545])]

where this means x(2.0) == 11.81...

EasyModelAnalysis.create_sensitivity_plotMethod
create_sensitivity_plot(prob, t, x, pbounds)

Creates bar plots of the first, second and total order Sobol indices that quantify sensitivity of the solution at time t and state x to the parameters in pbounds.

See also get_sensitivity

EasyModelAnalysis.datafitMethod
datafit(prob, p, t, data)
datafit(prob, p, data)

Fit parameters p to data measured at times t.

Arguments

  • prob: ODEProblem
  • p: Vector of pairs of symbolic parameters and initial guesses for the parameters.
  • t: Vector of time-points
  • data: Vector of pairs of symbolic states and measurements of these states at times t.

Keyword Arguments

- `loss`: the loss function used for fitting. Defaults to `EasyModelAnalysis.l2loss`,
  with an alternative being `EasyModelAnalysis.relative_l2loss` for relative weighted error.

p does not have to contain all the parameters required to solve prob, it can be a subset of parameters. Other parameters necessary to solve prob default to the parameter values found in prob.p. Similarly, not all states must be measured.

Data Definition

The data definition is given as a vctor of pairs. If t is specified globally for the datafit, then those time series correspond to the time points specified. For example,

[x => [11.352378507900013, 11.818374125301172, -10.72999081810307]
 z => [2.005502877055581, 13.626953144513832, 5.382984515620634, 12.232084518374545]]

then if datafit(prob, p, t, data), t must be length 3 and these values correspond to x(t[i]).

If datafit(prob, p, data), then the data must be a tuple of (t, timeseries), for example:

[x => ([1.0, 2.0, 3.0], [11.352378507900013, 11.818374125301172, -10.72999081810307])
 z => ([0.5, 1.5, 2.5, 3.5],
     [2.005502877055581, 13.626953144513832, 5.382984515620634, 12.232084518374545])]

where this means x(2.0) == 11.81...

EasyModelAnalysis.ensemble_weightsMethod
ensemble_weights(sol::EnsembleSolution, data_ensem)

Returns the weights for a linear combination of the models so that the prediction = sum(weight[i] * modelprediction[i]) where sol is the ensemble solution and `dataensem` is the dataset on which the ensembler should be trained on.

Arguments

  • sol: the ensemble solution of the prediction data
  • data_ensem: a vector of pairs from the symbolic states to the measurements
Note

This function currently assumes that sol.t matches the time points of all measurements in data_ensem!

EasyModelAnalysis.get_max_tMethod
get_max_t(prob, sym)
get_max_t(sol, sym)

Returns (t,max) where t is the timepoint where sym reaches its maximum max in the interval prob.tspan.

EasyModelAnalysis.get_min_tMethod
get_min_t(prob, sym)
get_min_t(sol, sym)

Returns (t,min) where t is the timepoint where sym reaches its minimum min in the interval prob.tspan.

EasyModelAnalysis.get_sensitivityMethod
get_sensitivity(prob, t, x, pbounds)

Returns the Sobol Indices that quantify the uncertainty of the solution at time t and observation x to the parameters in pbounds.

Arguments

  • t: The time of observation, the solution is stored at this time to obtain the relevant observed variable.
  • x: The observation symbolic expression or a function that acts on the solution object.
  • pbounds: An array with the bounds for each parameter, passed as a pair of parameter expression and a vector with the upper and lower bound.

Keyword Arguments

  • samples: Number of samples for running the global sensitivity analysis.

Returns

  • A dictionary with the first, second and total order indices for all parameters (and pairs in case of second order).
EasyModelAnalysis.get_sensitivity_of_maximumMethod
get_sensitivity_of_maximum(prob, t, x, pbounds; samples = 1000)

Returns the Sobol Indices that quantify the uncertainty of the solution at time t and maximum of observation x to the parameters in pbounds.

Arguments

  • t: The time of observation, the solution is stored at this time to obtain the relevant observed variable.
  • x: The observation symbolic expression.
  • pbounds: An array with the bounds for each parameter, passed as a pair of parameter expression and a vector with the upper and lower bound.

Keyword Arguments

  • samples: Number of samples for running the global sensitivity analysis.

Returns

  • A dictionary with the first, second and total order indices for all parameters (and pairs incase of second order).
EasyModelAnalysis.get_thresholdMethod
get_threshold(prob, obs, threshold)

Returns the value t for the time point where the solution of the model prob has the observation obs hit the threshold value.

EasyModelAnalysis.get_uncertainty_forecastMethod
get_uncertainty_forecast(prob, sym, t, uncertainp, samples)

Get the ensemble of time-series of state sym evaluated at times t for solutions with uncertain parameters specified according to the distributions in uncertainp. The distributions are specified in the form [sym1 => dist1, sym2 => dist2] where dist is a Distributions.jl distribution. Samples is the number of trajectories to run.

EasyModelAnalysis.get_uncertainty_forecast_quantilesFunction

getuncertaintyforecast_quantiles(prob, sym, t, uncertainp, samples, quants = (0.05, 0.95))

Get the ensemble of time-series of state sym evaluated at times t for solutions with uncertain parameters specified according to the distributions in uncertainp. The distributions are specified in the form [sym1 => dist1, sym2 => dist2] where dist is a Distributions.jl distribution. Samples is the number of trajectories to run.

Returns a tuple of arrays for the quantiles quants which defaults to the 95% confidence intervals.

EasyModelAnalysis.global_datafitMethod
global_datafit(prob, pbounds, t, data; maxiters = 10000)
global_datafit(prob, pbounds, data; maxiters = 10000)

Fit parameters p to data measured at times t.

Arguments

  • prob: ODEProblem
  • pbounds: Vector of pairs of symbolic parameters to vectors of lower and upper bounds for the parameters.
  • t: Vector of time-points
  • data: Vector of pairs of symbolic states and measurements of these states at times t.

Keyword Arguments

  • maxiters: how long to run the optimization for. Defaults to 10000. Larger values are slower but more robust.
  • loss: the loss function used for fitting. Defaults to EasyModelAnalysis.l2loss, with an alternative being EasyModelAnalysis.relative_l2loss for relative weighted error.

p does not have to contain all the parameters required to solve prob, it can be a subset of parameters. Other parameters necessary to solve prob default to the parameter values found in prob.p. Similarly, not all states must be measured.

Data Definition

The data definition is given as a vctor of pairs. If t is specified globally for the datafit, then those time series correspond to the time points specified. For example,

[x => [11.352378507900013, 11.818374125301172, -10.72999081810307]
 z => [2.005502877055581, 13.626953144513832, 5.382984515620634, 12.232084518374545]]

then if datafit(prob, p, t, data), t must be length 3 and these values correspond to x(t[i]).

If datafit(prob, p, data), then the data must be a tuple of (t, timeseries), for example:

[x => ([1.0, 2.0, 3.0], [11.352378507900013, 11.818374125301172, -10.72999081810307])
 z => ([0.5, 1.5, 2.5, 3.5],
     [2.005502877055581, 13.626953144513832, 5.382984515620634, 12.232084518374545])]

where this means x(2.0) == 11.81...

EasyModelAnalysis.model_forecast_scoreMethod
model_forecast_score(probs::AbstractVector, ts::AbstractVector, dataset::AbstractVector{<:Pair})

Compute the L2 distance between each problem and the dataset.

Arguments:

  • probs: a vector of problems to simulate.
  • ts: time points of the dataset.
  • dataset: dataset of the form of [S => zeros(n), I => zeros(n)].

Output: the L2 distance from the dataset for each problem.

EasyModelAnalysis.optimal_parameter_intervention_for_reachFunction
optimal_parameter_intervention_for_reach(prob, obs, reach, cost, ps,
    lb, ub, intervention_tspan, duration; ineq_cons = nothing, maxtime=60)

Arguments

  • prob: An ODEProblem.
  • obs: The observation symbolic expression.
  • reach: The reach for the observation, i.e., the constraint enforces that obs reaches reach.
  • cost: the cost function for minimization, e.g. α + 20 * β. It could be a tuple where the first argument is a symbol object in terms of parameters, and the second entry of the tuple could be an arbitrary function that takes a solution object and returns a real scalar.
  • ps: the parameters that appear in the cost, e.g. [α, β].
  • lb: the lower bounds of the parameters e.g. [-10, -5].
  • ub: the upper bounds of the parameters e.g. [5, 10].
  • intervention_tspan: intervention time span, e.g. (20.0, 30.0). Defaults to prob.tspan.
  • duration: Duration for the evaluation of intervention. Defaults to prob.tspan[2] - prob.tspan[1].

Keyword Arguments

  • maxtime: Maximum optimization time. Defaults to 60.
  • ineq_cons: a vector of symbolic expressions in terms of symbolic parameters. The optimizer will enforce ineq_cons .< 0.

Returns

  • opt_p: Optimal intervention parameters.
  • (s1, s2, s3): Pre-intervention, intervention, post-intervention solutions.
  • ret: Return code from the optimization.
EasyModelAnalysis.optimal_parameter_intervention_for_thresholdFunction
optimal_parameter_intervention_for_threshold(prob, obs, threshold, cost, ps,
    lb, ub, intervention_tspan, duration; ineq_cons = nothing, maxtime=60)

Arguments

  • prob: An ODEProblem.
  • obs: The observation symbolic expression.
  • threshold: The threshold for the observation.
  • cost: the cost function for minimization, e.g. α + 20 * β.
  • ps: the parameters that appear in the cost, e.g. [α, β].
  • lb: the lower bounds of the parameters e.g. [-10, -5].
  • ub: the upper bounds of the parameters e.g. [5, 10].
  • intervention_tspan: intervention time span, e.g. (20.0, 30.0). Defaults to prob.tspan.
  • duration: Duration for the evaluation of intervention. Defaults to prob.tspan[2] - prob.tspan[1].

Keyword Arguments

  • maxtime: Maximum optimization time. Defaults to 60.
  • ineq_cons: a vector of symbolic expressions in terms of symbolic parameters. The optimizer will enforce ineq_cons .< 0.

Returns

  • opt_p: Optimal intervention parameters.
  • (s1, s2, s3): Pre-intervention, intervention, post-intervention solutions.
  • ret: Return code from the optimization.
EasyModelAnalysis.optimal_parameter_thresholdMethod
optimal_parameter_threshold(prob, obs, threshold, cost, ps, lb, ub; ineq_cons = nothing, maxtime = 60, kw...)

Arguments

  • prob: An ODEProblem.
  • obs: The observation symbolic expression.
  • threshold: The threshold for the observation.
  • cost: the cost function for minimization, e.g. α + 20 * β.
  • ps: the parameters that appear in the cost, e.g. [α, β].
  • lb: the lower bounds of the parameters e.g. [-10, -5].
  • ub: the upper bounds of the parameters e.g. [5, 10].

Keyword Arguments

  • maxtime: Maximum optimization time. Defaults to 60.
  • ineq_cons: a vector of symbolic expressions in terms of symbolic parameters. The optimizer will enforce ineq_cons .< 0.

Returns

  • opt_p: Optimal intervention parameters.
  • sol: Solution with the optimal intervention parameters.
  • ret: Return code from the optimization.
EasyModelAnalysis.optimal_threshold_interventionMethod
optimal_threshold_intervention(prob, [p1 = prob.p], p2, obs, threshold, duration; maxtime)

Arguments

  • p1: parameters for the pre-intervention scenario. Defaults to prob.p.
  • p2: parameters for the pose-intervention scenario.
  • obs: The observation symbolic expression.
  • threshold: The threshold for the observation.
  • duration: Duration for the evaluation of intervention.

Keyword Arguments

  • maxtime: Maximum optimization time. Defaults to 60.

Returns

  • opt_tspan: Optimal intervention time span.
  • (s1, s2, s3): Pre-intervention, intervention, post-intervention solutions.
  • ret: Return code from the optimization.
EasyModelAnalysis.phaseplot_extremaMethod
phaseplot_extrema(prob, sym, plotsyms)

Plots the phase plot solution of the observable sym along with showcasing time points where it obtains its maximum and minimum values. plotsyms should be given as the tuple of symbols for the observables that define the axis of the phase plot.

EasyModelAnalysis.plot_extremaMethod
plot_extrema(prob, sym)

Plots the solution of the observable sym along with showcasing time points where it obtains its maximum and minimum values.