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 were used in model 1. The plot shows depressive symptom levels as they evolve over time, the threshold for diagnosis and that for remission. The simulation can occur over intervals up to 5 years (1826 days), as represented on the horizontal axis, but the default value is 2 years (730 days). The duration of the simulation can be changed in this applet, using a slider on the interface. 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 other model parameters, use the appropriate “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_3.nlogo

WHAT IS IT?

The purpose of this model is to explore whether some of the apparent complexities of major depression epidemiology may merely be artifacts of the current strategy of making a diagnosis of a depressive disorder through application of a threshold-style definition of major depressive episode to what is essentially a fluctuating level of depression.

This model (model 3) builds from the two previously presented (models 1 and 2), which are intended to illustrate how the model works. Model three simulates the experience of multiple people (agents, “turtles”) allowing their diathesis to vary randomly according to a distribution set by the user. Different entities also experience a different pattern of stress, since the values for this variable (in NetLogo language, these are “owned” by the patches comprising the surface over which the agents move in the simulation.

HOW IT WORKS

The model represents a diathesis (vulnerability) - stress interaction. Each entity in the model (in NetLogo these are called “turtles”) is randomly assigned a value representing their diathesis. The entities then move along a “landscape” of stress - each “patch” in the landscape is assigned a stress value. There is an activation of simulated stress responses - depicted as the product of stress value and the diathesis. There is a counteracting value for stress adaptation - the stress activation declines at a rate that is inversely proportional to the diathesis (the relationship can be modified by manipulation of a constant (the durationconstant) that can be manipulated by the user on the interface. A 14-day running average of stress activation is taken as a level of depression over that two week period, and its average level is considered indicative of a more sustained mood state: a depressive episode if a threshold is exceeded. The episode remits when the level of depression goes below the threshold (when the remissionstringency parameter (see description of models 1 and 2) is one, or reaches a specified fraction of what that threshold value should be before remission is considered to have occurred.

HOW TO USE IT

The model does not produce an interesting animation. Instead, it simulates the experience of a series of entities and records data from this simulated sample in a comma separated values text file. This data can then be imported into a statistical program in order to explore its features. The model interface also reports certain output values as the model simulation unfolds. It is best to turn of the “view updates” option at the top of the screen so that the simulation can run faster.

In the paper, the simulation interval was set to 3651 in order produce a simulation of 10 years duration. This can be altered using a slider for “simulationdays” on the interface.

CODE

;; global variables include...
;; subjectcount: the total number of turtles in each simulation (their course is simulated one at a time).
;; totalcases: a count of the number of turtles exceeding the specified threshold during the simulation run.
;; periodprevalence: the ratio of totalcases to subjectcount
;; meanduration: the average number of days between when the threshold is exceeded (start of an episode) and when the criteria for remission (see below) are met.
;; fed_total: is a running total of first episode durations.
;; fed_mean: the mean first episode duration, among those with an episode.
;; epc_total: is a running total of episode counts.
;; epc_mean: is the mean number of episodes, among those having episodes.

globals [subjectcount totalcases periodprevalence meanduration fed_total fed_mean epc_total epc_mean maxticks] 

;; these are the turtle variables...
;; id: this is a consecutively assigned identification number for each turtle.
;; the simulation counts up by one day on each tick.
;; diathesis: as set by the user, the probability distribution for diathesis - inverse log of a normal distribution with mean 0 and sd as set on the interface.
;; stressactivtion: is the interaction of stress and diathesis, daily
;; stressadaptation: is the extent of downregulation, daily, represented by the proportion of activation that is eliminated, determined by the diathesis and the duration constant from the interface.
;; aoo: the day of onset of an initial episode - day at which the threshold is exceeded.
;; aoo_recorded: an indicator variable denoting that aoo has been recorded.
;; fer: day of first episode recovery - time between exceeding the threshold (aoo) and achieving a remission.
;; fer_recorded: an indicator variable that denotes when the first episode recovery date has been recorded.
;; fed: is the first episode duration.
;; epc: is a count of the number of episodes for that turtle
;; remitted: an indicator variable that assumes a value of 1 when a turtle has had a prior episode that has resolved.
;; tminus14, tminus13 etc.: the depression level is represented as a 14 day moving average of daily depression scores. At each tick the running average of scores is updated.

turtles-own [id days diathesis stressactivation stressadaptation stressburden aoo aoo_recorded fer fer_recorded fed epc remitted tminus14 timinus13 tminus12 tminus11 tminus10 tminus9 tminus8 tminus7 tminus6 tminus5 tminus4 tminus3 tminus2 tminus1 runningaverage epc_year_9 dep_year_9 dep_year_10]
patches-own [stress]

To setup
  clear-all
  ;; the next command assigns a stress level to each patch, and colors the patch using a scale proportional to the stress level.
  ask patches [set stress e ^ random-normal 0 stress_sd set pcolor scale-color red stress 0 20]
  ;;  the following commands initialize the global variables
  set subjectcount 0
  set totalcases 0
  set periodprevalence 0
  set meanduration 0
  set fed_total 0
  set fed_mean 0
  set epc_total 0
  set epc_mean 0
  reset-ticks
end

To go
  ;; the following command creates a new turtle when the previous one has died.
  if count turtles < 1 [crt 1 [set days 0 set id who + 1 setxy 0 random-ycor set color yellow set heading 90 set size 20 set diathesis e ^ random-normal 0 diathesis_sd set subjectcount subjectcount + 1 set epc 0 set fer 0 set epc_year_9 0 set dep_year_10 0 set aoo_recorded 0 set fer_recorded 0 set remitted 0 set stressburden diathesis * stress]]
  ask turtles [fd 1 display]
  ask turtles [set days days + 1]
  ;; the following commands calculate stress activation and stress adaptation according to the specified parameters and then calculate a running average over 14 days.
  ask turtles [set stressactivation diathesis * stress]
  ask turtles [set stressadaptation stressburden * (1 / ( 1 + (durationconstant * diathesis)))]
  ask turtles [set stressburden stressburden + stressactivation - stressadaptation]
  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)]
  ;; the following command identifies the onset of the first episode during the simulated interval.
  ask turtles [if runningaverage > threshold and epc = 0 [set aoo days set aoo_recorded 1 set epc 1 set epc_total epc_total + 1 set totalcases totalcases + 1 ]]
  ;; the next command identifies the remission of the first episode and calculates its duration
  ask turtles [if epc = 1 and fer_recorded = 0 and runningaverage < (threshold * remissionstringency) [set fer days set fer_recorded 1 set fed fer - aoo set remitted 1 ]]
  ;; the following command identifies remissions from subsequent episodes.
  ask turtles [if epc > 0 and fer_recorded = 1 and runningaverage < (threshold * remissionstringency) [set remitted 1]]
  ;; the next command identifies subsequent episodes, and counts them.
  ask turtles [if epc > 0 and remitted = 1 and runningaverage > threshold [set epc epc + 1 set epc_total epc_total + 1 set remitted 0 ]]
  ;; this command calculates the prevalence
  set periodprevalence totalcases / subjectcount
  ;; the next line is necessary to set an episode duration when the first episode is censored due to the end of the simulation.
  ask turtles [if days > simulationdays and aoo_recorded = 1 and fer_recorded = 0 [set fed days - aoo]]
  ;; these commands update the global variables after each turtle's simulation is completed
  ask turtles [if days > simulationdays and totalcases > 0 [set fed_total fed_total + fed set fed_mean fed_total / totalcases set epc_mean epc_total / totalcases]]
  ;; turtles are removed from the simulation after the specified number of days to be simulated, another one will be created when "go" executes again.
  ask turtles [if days > simulationdays [die]]
  if subjectcount > number_to_simulate [stop]
end