26
Stata Technical Bulletin
STB-8
At the end of simulation it draws a graph of the state variables versus time. For all the time steps required, the state, rate
and auxiliary variable values, the exogenous variables and the .time variable are available in memory.
It is possible to modify the relations or parameters interactively using ‘replace -model="statement'1 in #’.
The syntax of the simula command is
simula [, dt(#) tstart(#) tspan(#) exovar filename) graph-options
pnam("p#amal=e2pname2=# ...") ivals"arrιrl=SV svar2=# ...") ]
The options are
dt(#) specifies the integration time step (time units). The default is 1.
start (#) specifies the time at which the simulation starts. The default value is 0.
tspan(#) specifies the simulation length. The default value is 30.
exovar filename) requests a file that will be merged to the model file in memory. This file must contain the exogenous variables
used in the model. This option is needed when an exogenous variable statement is declared in -model.
parv() allows the modification of parameter values, overriding the values specified in the .model statements. pname is a
parameter name.
ival() allows the modification of the initial values of the state variables, overriding the values specified in the .model statements.
same is a name of a state variable.
graph-options are any of the graph, twoway options. For example, ylog could be useful when the expected increase is explosive;
saving() can be useful for saving the resulting graph, and so on.
Time solution step (dt)
To ensure a stable solution, a good rule is to keep dt() between one-half and one-tenth of the smallest time coefficient
in the model (Richardson and Pugh 1981). Frequently, it is suggested we have a dt() value of one-fourth to one-fifth of the
smallest time coefficient (Ferrari 1978). Values higher than one-half allow computational inaccuracies while values lower than
one-tenth require much computer time. Moreover, a too small dt() value can also increase the round-off error because the rate
values added to the state variables becomes very small.
It is useful, in any case, to try a smaller dt() value to check for the amount of error. The solution is correct if a small
change in the time step does not affect the simulation results.
The choices of time step and starting time must allow the merging of the exogenous variables; the .time variable created
by simula must have the values present in the .time variable of the exovar file (not only those, however). If the values of the
two .time variables do not match, the exogenous variables are not merged. For example, let the .time values in the exovar file
be 0, 1, 2, 3, and 4 and let the choices be dt(.4), tspan(8), and tstart(l). The values for the .time variable created by
simula will be 1, 1.4, 1.8, 2.2, 2.6, 3.0, 3.4, and 3.8. The program merges only the exovar values corresponding to time 1 and
3.
Exogenous variables
When the exogenous variables’ data are available with a lower frequency than specified by the time solution step, then the
command generates the missing data. The initial and final values are generated by repetition of the nearest value, the intermediate
ones by linear interpolation.
Parameters and initial values
It is possible to override the parameter and initial values coded in the model file by specifying them in the command options
(parv() and ival()). Indeed, while it is a good practice to indicate such values in the model file, the parv() and ival()
options provide a faster method to analyze the model sensitivity and the effects of the initial condition variations.
Delays
The delay functions apply to all the state variables of the equation. If in a rate equation there are state variables with
different delay time, it is better to use more than one rate equation for the same process. Note that the effect of IDL and MDL is
the same until the delay time (dly) is a constant. If dly is changing, the retarded information is lost while the retarded material
is conserved. Only the rate equations may contain the delay functions.