  Stochastic compartmental models are important tools for understanding the
course of infectious diseases epidemics in populations and in prospective
evaluation of intervention policies. However, calculating the likelihood for
discretely observed data from even simple models -- such as the ubiquitous
susceptible-infectious-removed (SIR) model -- has been considered
computationally intractable, since its formulation almost a century ago.
Recently researchers have proposed methods to circumvent this limitation
through data augmentation or approximation, but these approaches often suffer
from high computational cost or loss of accuracy. We develop the mathematical
foundation and an efficient algorithm to compute the likelihood for discretely
observed data from a broad class of stochastic compartmental models. We also
give expressions for the derivatives of the transition probabilities using the
same technique, making possible inference via Hamiltonian Monte Carlo (HMC). We
use the 17th century plague in Eyam, a classic example of the SIR model, to
compare our recursion method to sequential Monte Carlo, analyze using HMC, and
assess the model assumptions. We also apply our direct likelihood evaluation to
perform Bayesian inference for the 2014-2015 Ebola outbreak in Guinea. The
results suggest that the epidemic infectious rates have decreased since October
2014 in the Southeast region of Guinea, while rates remain the same in other
regions, facilitating understanding of the outbreak and the effectiveness of
Ebola control interventions.
