28
Stata Technical Bulletin
STB-8
The time coefficient of the rate equation is 1/RGR = 1/0.1 = 10. To ensure a stable solution, dt() should be less than
10 × (1/4) = 2.5.
. simula, dt (0.5) tspan(40)
Parsing:
Line : 1
Line : 2
Line : 3
Line: 4
Simulation:
Time=O
Time=.5
Time=I
Time=I.5
(output omitted)
Time=39.5
Time=40
The simulation determines an exponential growth of weight W shown in Figure 4 (curve a). Obviously, in this simple
model the same result could be obtained with calculus. The integration of the differential equation dW∕dt = RGR × I-F gives
the exponential growth equation W = Wq r exp(RGR × t), where TT7u is the initial value of W and t the time.
b) Negative feedback
If we decide to apply an asymptotic model having a goal, we modify the rate equation in line 2 adding a goal to the system
(Wmax). This requires also the Wmax value, declared in line 5 as follows:
. replace .model="R GR=RGR*(Wmax-W) Growth rate (g∕d)u in 2
(1 change made)
. replace .model="P Wmax=6
(1 change made)
Maximum weight (g),, in 5
. format .model ⅝ls
. list .model in 1/5
.model
1. S W=W+dt*GR Weight (g)
2. R GR=RGR*(Wmax-W) Growth rate (g∕d)
3. I W=5 Initial weight (g)
4. P RGR=0.1 Relat. growth rate (g∕g∕d)
5. P Wmax=6 Maximum weight (g)
Again, the simulation of the above model is performed by the command ‘simula, dt(.5) tspan(40)’. The simulation results
show an asymptotic exponential growth (Figure 4, curve b).
c) Physical limit to growth (rate switch-off)
If there are no growth limitations until a maximum is reached, the function SWTC is appropriate. The growth rate GR is
turned off when the control variable (W) reaches the upper limit (Wmax). To simulate this behavior we modify the second line
of the program as
. replace _model="R GR=SWTC[RGR*W,W,Z,Wmax]" in 2
(1 change made)
In simula we specify a new Wmax value and set Z to 0. Z is set to 0 to avoid the zeroing of the rate at low W values. Typing
‘simula, dt(0.5) tspan(20) par(Wmax=15 Z=0)’ performs the simulation. The results are plotted in Figure 5.
d) Start time to accumulation (rate switch-on)
If a rate must be integrated after a control variable reaches a threshold value, we can use the SWTC function in the switch-on
version. The growth rate GR is turned on when the control variable (for example, -time) reaches the threshold Thre). An
example is the growth of a plant, starting after the seedling exits the soil. To simulate this behavior, we modify the second line
of the program to be
. replace _model="R GR=SWTC[RGR*W,.time,Thre,H]" in 2
and the simulation is obtained by typing ‘simula, dt(0.5) tspan(20) par(Thre=7 H=21)’. In this case, H is so large as to
avoid the rate switch-off. Figure 5 plots the results.