You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Import the ODEModel classfrompySODM.models.baseimportODEModel# Define the model equationsclassODE_SIR(ODEModel):
""" Simple SIR model without dimensions """state_names= ['S','I','R']
parameter_names= ['beta','gamma']
@staticmethoddefintegrate(t, S, I, R, beta, gamma):
# Calculate total populationN=S+I+R# Calculate differentialsdS=-beta*S*I/NdI=beta*S*I/N-1/gamma*IdR=1/gamma*IreturndS, dI, dR# Define parameters and initial conditionparams={'beta':0.35, 'gamma':5}
init_states= {'S': 1000, 'I': 1}
# Initialize modelmodel=ODE_SIR(states=init_states, parameters=params)
# Define datasetdata=[d, ]
states= ["I",]
log_likelihood_fnc= [ll_negative_binomial,]
log_likelihood_fnc_args= [alpha,]
# Calibated parameters and boundspars= ['beta',]
labels= ['$\\beta$',]
bounds= [(1e-6,1),]
# Setup objective function (no priors --> uniform priors based on bounds)objective_function=log_posterior_probability(model, pars, bounds, data, states, log_likelihood_fnc, log_likelihood_fnc_args, labels=labels)
Proposed implementation
Define what states are observed, and what statistical process underpins the observations in the model declaration. Then provide the parameters of the observation process (if any) upon model declaration. When simulating the model, automatically add the observation noise to the observed states, thus avoiding the use of add_gaussian_noise() or add_poisson_noise(). This further simplifies the call to log_posterior_probability.
# Import the ODEModel classfrompySODM.models.baseimportODEModel# Define the model equationsclassODE_SIR(ODEModel):
""" Simple SIR model without dimensions """state_names= ['S','I','R']
observed_state_names= ['I']
observation_process= ['negative_binomial']
parameter_names= ['beta','gamma']
@staticmethoddefintegrate(t, S, I, R, beta, gamma):
# Calculate total populationN=S+I+R# Calculate differentialsdS=-beta*S*I/NdI=beta*S*I/N-1/gamma*IdR=1/gamma*IreturndS, dI, dR# Define parameters and initial conditionparams={'beta':0.35, 'gamma':5}
init_states= {'S': 1000, 'I': 1}
# Define the parameters of the observation processobservation_process_params= {'I': 0.04} # overdispersion parameter `alpha` # Initialize modelmodel=ODE_SIR(states=init_states, parameters=params, observation_parameters=observation_process_params)
# Define datasetdata=[d, ]
states=[I,]
# Calibated parameters and boundspars= ['beta',]
labels= ['$\\beta$',]
bounds= [(1e-6,1),]
# Setup objective function (no priors --> uniform priors based on bounds)objective_function=log_posterior_probability(model, pars, bounds, data, states, labels=labels)
The text was updated successfully, but these errors were encountered:
Current implementation
Proposed implementation
Define what states are observed, and what statistical process underpins the observations in the model declaration. Then provide the parameters of the observation process (if any) upon model declaration. When simulating the model, automatically add the observation noise to the observed states, thus avoiding the use of
add_gaussian_noise()
oradd_poisson_noise()
. This further simplifies the call tolog_posterior_probability
.The text was updated successfully, but these errors were encountered: