A simple example of a deterministic simulation. When trying out a new
model it’s a very good idea to first try to simulate - with the
parameter values. The simulation of the model output should be realistic
and comparable with the observations. Once the model, with parameter
values, provides a good simulation, then it’s time to move on to
estimation.

Using another optimizer for the parameter estimation can be really
useful. In this example the nlminb() function is used. The negative
log-likelihood is calculated in an R function, which is then passed to
the optimizer. It’s also seen how actually a robust version of the
negative log-likelihood is calculated.

An example of different ways to realize stochastic simulation.

Using the tikz package circutikz in LaTeX to generate RC-digrams.