This page was automatically generated by NetLogo 5.0.3.

The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.

Clicking the “setup” button will initialize the model and clicking the “go” button will run it. Here, stress is depicted using shading rather than "bars" as in model 1. The plot shows depressive symptom levels as they evolve over time, the threshold for diagnosis and that for remission. The simulation occurs over 730 days, as represented on the horizontal axis. If the applet runs too fast or too slow, it can be slowed down or speeded up using the slider at the top of the interface. To adjust the model parameters, use the “sliders” on the interface. When new settings are applied, the “setup” button should be clicked to initialize the model with the new settings before clicking “go.”

powered by NetLogo

view/download model file: model_2.nlogo


This model depicts a single agent (turtle) moving over an environmental surface ( patches), each with an associated stress level. The intention is to show that an interaction between a diathesis and a stressor can result, in the circumstances represented, in what appears to be an episodic pattern.


The stress level variable characterizing each patch is assigned a value randomly in a lognormal pattern by taking the inverse logarithm of a normal distribution having mean zero and standard deviation set by the user - using the slider on the interface: stress_sd. Depression is calculated in a way consistent with a diathesis-stress conceptualization (illustrated by model 1, as described in the manuscript): depressive symptoms are conceived as an activation of stress responses, represented as a product of the stress level and the strength of diathesis owned by each turtle as it moves over each patch. There is an adaptation to the stressors - but the rate at which this occurs is inversely proportional to the diathesis (as quantified also by a proportionality constant (see manuscript, and description of model 1). This constant is called the “durationconstant” which can be set using a slider. The actual level of depressive symptoms is calculated as a fourteen day running average.

The user can also set a threshold value using another slider - which would be the point at which the past 2-week experience may be considered diagnostic of a depressive episode (similar to the 2-week approach in contemporary psychiatric diagnostic systems: DSM-IV and ICD-10). An episode is typically determined to have ended when there is a sustained period below some threshold that is lower than the diagnostic threshold, e.g. 50% of the threshold level if the parameter is set to 0.5. The stringency of the remission definition refers to the extent of resolution of symptoms that is required in order to conclude that an episode has terminated. This parameter can also be adjusted using a slider. “Episodes” can the be easily identified from the output. They consist of the amount of time following exceeding of a diagnostic threshold before the symptom level drops to a level indicative of remission.

This model simulates the experience of a person (agent, “turtle”) over a period of time that consists of 730 days (2 years).


When the diathesis is very low, and the threshold is fairly high, even the more extreme stressors do not exceed the threshold. However, at higher levels of diathesis they do. At very high levels of diathesis the symptom level will consistently exceed the thresholds (both for diagnosis and remission), as occurs in chronic depression.


turtles-own [days stressactivation stressadaptation stressburden tminus14 timinus13 tminus12 tminus11 tminus10 tminus9 tminus8 tminus7 tminus6 tminus5 tminus4 tminus3 tminus2 tminus1 today runningaverage]
patches-own [stress]

To setup
  ;; the following command asisgns a value to the stress variable, owned by the patches.
  ask patches [set stress e ^ random-normal 0 stress_sd set pcolor scale-color red stress 0 20]
  ;; as this simulation uses only one turtle, the turtle is created in the set-up part of the program.
  crt 1 [setxy 0 random-ycor set color yellow set heading 90 set days 0 set size 20 set stressburden stress * diathesis]
  ;; the following command initializes the stressactivation variable as the product of diathesis and stress.
  ask turtles [set stressburden diathesis * stress ]
  ;; the following commands result in the output of the simulation run being recorded in a data file.

To go
  ask turtles [fd 1 display]
  ;; days into the simulation is recorded and counted up by one with each "tick."
  ask turtles [set days days + 1]
  ;; stressactivation is the product of diathesis and stress.
  ask turtles [set stressactivation diathesis * stress]
  ;; there is a daily degree of adaptation to stress, inversly proportional to diathesis (and a proportionality constant for calibration purposes).
  ;; one is added to the denominator to create a situation where a zero diathesis would result fully effective stress adaptation.
  ask turtles [set stressadaptation stressburden * (1 / ( 1 + diathesis * durationconstant))]
  ;; the following command resets stress burden with the change being the difference between the extent of activation and adaptation.
  ask turtles [set stressburden stressburden + stressactivation - stressadaptation]
  ;; to be consistent with psychiatric tradition, the level of depression is a two week running average of the level of stress activation.
  ask turtles [set tminus14 timinus13 set timinus13 tminus12 set tminus12 tminus11 set tminus11 tminus10 set tminus10 tminus9 set tminus9 tminus8 set tminus8 tminus7]
  ask turtles [set tminus7 tminus6 set tminus6 tminus5 set tminus5 tminus4 set tminus4 tminus3 set tminus3 tminus2 set tminus2 tminus1 set tminus1 stressburden]
  ask turtles [set runningaverage ((tminus14 + timinus13 + tminus12 + tminus11 + tminus10 + tminus9 + tminus8 + tminus7 + tminus6 + tminus5 + tminus4 + tminus3 + tminus2 + tminus1) / 14)]
  ;; this command ends the simulation after 2 years (730 days). 
  ask turtles [if days > 730 [die]]
  if not any? turtles [ stop ]
  ask turtles [do-plotting]

To do-plotting
  set-current-plot-pen "threshold"
  plotxy ticks threshold
  set-current-plot-pen "symptom level"
  plotxy ticks runningaverage 
  set-current-plot-pen "remission threshold"
  plotxy ticks remissionstringency * threshold