Stata Technical Bulletin
19
t sort num
. by num: gen dev2=sum(dev*dev) if _n==l
. egen DEV=sum(dev2)
The statistic follows a χ2 distribution with degrees of freedom equal to J — (p + 1), where J is the number of distinct
covariate patterns and p is the number of predictor variables in the model. The Ifit command will provide you with the number
of model covariate patterns as well as the correct degrees of freedom. However, if you have used the above command list to
obtain DEV, you can also type ‘display num [_N] ’ to determine the number of covariate patterns.
I have created a command to be used after logistic, similar to lfit, that yields the DEV statistic, significance, etc.
Simply type ldev. (The program is on the STB-8 diskette.)
. logistic low age amoke race2 race3
(output omitted )
. Idev
Logistic estimate for low, goodness-of-fit test
no. of observations = 189
no. of covariate patterns = 82
Deviance chi2(77) = 96.50
P>chi2 = 0.0658
ssi3 Continuous dynamic system modeling and simulation with Stata
Francesco Danuso, Dipartimento di Produzione Vegetale, Udine, Italy. FAX (011)-39-432-558603
Introduction
Any set composed of elements that exchange material and information and is able to regulate itself by feedback loops, can
be defined as a system. This paper provides and describes the utilization of a new Stata command (simula.ado) that allows
the simulation of continuous dynamic systems. Simulation is the calculation process performed on a mathematical model for
representing a particular system behavior. Models, coded in observations of a string variable in a .dta file, are parsed and then
simulated by simula. simula is a small language pseudo-interpreter for model listings, providing a simple tool to study the
dynamic behavior of systems.
Overview on system modeling and simulation
Often, systems show complex variations that are not easily understood. System analysis is a powerful and general method
devised for the system representation and the simulation of the dynamics. This method leads to system modeling by means
of mathematical equations. Modeling techniques have been applied to systems of very different kinds. For example, many
applications are in the social-economical (Meadows and Meadows 1972; Meadows et al. 1973), ecological (Brennan et al. 1970;
de Wit and Goudriaan 1978), physiological (Smerage 1979), and agricultural (Dent and Blackie 1978) fields.
System modeling has been useful both for many practical and research purposes (examples of the former include system
behavior forecasting, system control, and stability under disturbances; examples of the latter include exploration of hypothetical
systems, thorough and critical review of knowledge concerning the system, and simulation experiments). The major contribution
to system analysis and modeling was made by J. W. Forrester (1968) who stated the “Principles of systems.” His approach deals
particularly with “conservative” systems, in which matter and energy are neither created nor destroyed. His viewpoint, following
a hydraulic analogy, conceives the systems conditions (called system states or levels) as water levels in reservoirs. Levels are the
“memories” of the system and can vary, with time, in relation to their incoming and outcoming fluxes. The system conditions
(state variables), and the parameters and the variables generated outside the system bounds (external inputs) control the fluxes
(rate variables). Parameters are quantities that maintain a constant value during a simulation.
System analysis identifies the state variables, the change rate of each state variable (rates) and the relationships among state
variables, rate variables and exogenous variables. Calculations of state variables proceed, starting from their initial values, by
accumulation (integration) for small time increments of the incoming and outcoming rates. Rate variables depend only on state
and exogenous variables but not on the other rates; state variables depend on rate variables.
When the system conditions control their rate of change, there is a feedback loop; this can be positive, when the state
variable diverges from an initial value, or negative if the state variable converges toward a goal. “Delays” are other important
aspects of the system dynamics. The integration of rates in a state variable can happen after a time span (material delay) or the
control mechanism perceives the system conditions which retard (information delay: the present rate depends on past levels).