This is a zip which includes RATS programs for simulation and estimation of various forms of the commonly used SEIR model for infections.
The first chapter works only with pure simulations. It first shows a deterministic model, a model with errors implied by the process and another deterministic model with an assumed model of changing behavior. In the simulation section, it shows a "shotgun" graph which shows various random simulations of the model and (in this case) demonstrates that a wide range of values is mainly due to differences in timing rather than actually differences in the ultimate effect. (Shotgun graphs have become increasingly popular in the VAR literature for showing impulse responses.)
The second chapter looks at the behavior of actual data (in this case from the state of Illinois in the U.S.). U.S. data has some rather strong day-of-the-week effects (which often differ from state to state); this looks at different ways to extract the signal out of observed data.
The third chapter looks at actually estimating a dynamic SEIR model given the data. This does four increasingly complex models: first with a transmission rate which is fixed across the sample; the second with an exogenously input change in the transmission rate, the third with an endogenously determined transmission rate, then finally a more complicated model that allows for a multiplicative day-of-the-week effect in the observed data.
The SEIR model is fundamentally non-linear, though not in a particularly complex way. The basic simulation models can be handled relatively easily with FORECAST or SIMULATE instructions. When attempting to fit them to actual data, however, one needs to use the non-linear (extended) Kalman filter to deal with multiplicative interactions among the states. The non-linear Kalman filter is covered in greater detail as part of the State Space Models/DSGE e-course.