Contraception Simulation R0

Contraception Simulation R0 preview image

1 collaborator

Rg_400x400 Ricardo Gonzalez (Author)

Tags

average_vs_median 

Tagged by Ricardo Gonzalez over 3 years ago

contraception 

Tagged by Ricardo Gonzalez over 3 years ago

nyt 

Tagged by Ricardo Gonzalez over 3 years ago

population dynamics 

Tagged by Ricardo Gonzalez over 3 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.2.2 • Viewed 490 times • Downloaded 44 times • Run 0 times
Download the 'Contraception Simulation R0' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This model simulates the use of a tool (f.eg. a contraceptive device or method) within a population with two diffentiated subgroups, each with a different ability to use the tool.

An agent has two features:

  1. A mental state (MS), which is the tendency it has to properly use the tool [0, 1].
  2. An observed state (OS), which indicates the consequence of misusing the tool [0, 1].

The subgroups within the population are defined by their MS, assumed to be unvariable (but see LR below).

The relative size of the two subgroups (MS=0 and MS=1) is defined with a slider (variable S1).

Each subgroup has a probability of misusing the tool at each step, which is determined by the variables E0 and E1 (defined with sliders). E0 refers to the subpopulation MS=0, and E1 to MS=1. If an agent misues the tool, his OS changes from 1 (initial condition) to 0. Agents with OS=0 retain that state.

The agents can learn with time, in two ways. The learning rate for agents of the type MS=0 is determined by variable LR0 (defined with a slider), which is the percentage of agents MS=0 which at any tick change to MS=1. For agents of the type MS=1, LR1 (defined with a slider) is the rate (%) by which its average error rate (E1) is reduced at each tick.

From an initial distribution of MS among the agents, the model shows the changes in OS=0 along time (with a counter for the total number of agents with OS=0, and with a chart for each step).

Prepared to falsify the results presented by the NYT in How Likely Is It That Birth Control Could Let You Down?.

HOW IT WORKS

The model differentiates the agents by their MS. The parameters that control their actions are defined for the cases MS=0 and MS=1. The values of these parameters are defined by sliders.

After initialization, the steps followed by the model are simply checking against a random variable adjusted to MS=0 (E0) and MS=1 (E1) whether the agent has misused the tool, in which case his OS changes to OS=0.

HOW TO USE IT

Items in the Interface:

  1. number_agents, slider: number of agents (turtles).
  2. number_ticks, slider: the maximum number of ticks (steps, years).
  3. S1, slider: percentage of agents with MS=1 at start.
  4. E0 (1), slider: the probability (%) that if MS=0 (1) the agent will misuse the tool and then change his 0S to 0.
  5. LR0, slider: the probability (%) that an agent with MS=0 will change to MS=1.
  6. LR1, slider: the rate (%) by which the average error rate E1 is reduced each tick.
  7. Eavg, output: weighted average of E0 and E1.
  8. number_ticks, slider: the number of ticks (steps, years).
  9. OS0%, output: the percentage of agents with OS=0
  10. DELTA OS=0, output chart: change in number of agents with OS=0

Operation:

  • Push the set-up button.
  • Push either the go (tick-by-tick) or the go* buttons.
  • Observe the changes in the number of agents whose OS becomes 0 (red turtles if MS=0, orange if MS=1).

THINGS TO NOTICE

(suggested things for the user to notice while running the model)

THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

CREDITS AND REFERENCES

(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;;
;; Global variables.
;;
globals [count_OS0 delta_OS0 EAVG E1up]

;;
;; turtle/breed.
;;

;;
;; turtle/breed variables.
;;
turtles-own [
  MS  ;; mental state, MS = 1 if the agent tends to use correctly the tool, 0 otherwise
  OS  ;; observed state, OS = 1 if the tool has always been used correctly, 0 otherwise.
]

;;
;; setup.
;;

to setup
  clear-all
  reset-ticks
  setup-world
  setup-turtles
  ;; etc
end 

;;
;; setup-world.
;;

to setup-world
  ask patches [ set pcolor green + 2]
end 

;;
;; setup-turtles.
;;

to setup-turtles
  ;; Initialize global variables.

  ;; Create the turtles and set their initial states.
  create-turtles number_agents
  [ set shape "person"
    setxy random-xcor random-ycor]

  ;; Initial MS and OS.
  ask turtles
  [
    ifelse random 100 < S1
    [ set MS 1
      set color 9.9]
    [ set MS 0
      set color 0  ]
    set OS 1
  ]
  ;; Update counts.
  update-counts

set EAVG (S1 * E1 + (100 - S1) * E0) / 100
set delta_OS0 0
set E1up E1
end 

;;
;; go.
;;

to go
  ;; Criteria to stop.
  if (ticks > number_ticks) [stop]
  if (count_OS0 = number_agents) [stop]

  ;; Otherwise do-things.

  ;; Update status.
  update-turtles

  ;; Update counts.
  update-counts

  ;; tick.
  tick
end 

;;
;; update-turtles.
;;

to update-turtles
  ask turtles
  [ ;; update MS with LR0
    if MS = 0
    [
      if random 100 <= LR0
      [ set MS 1
        if OS = 0 [set color 25]
        if OS = 1 [set color 9.9]
      ]
    ]

    ;; update OS
    set E1up E1up * (100 - LR1) / 100
    if OS = 1
    [
      ifelse MS = 0
      [ if random 100 <= E0
        [set OS 0
        set color 15]
      ]
      [ if random 100 <= E1up
        [set OS 0
        set color 25]
      ]
    ]
  ]
end 

to update-counts
  ;; Update counts.
  set delta_OS0 count turtles with [OS = 0] - count_OS0
  set count_OS0 count turtles with [OS = 0]
end 

There are 4 versions of this model.

Uploaded by When Description Download
Ricardo Gonzalez over 3 years ago Adds learning rates Download this version
Ricardo Gonzalez over 3 years ago Corrects % error... Download this version
Ricardo Gonzalez over 3 years ago How Likely Is It That Birth Control Could Let You Down? Download this version
Ricardo Gonzalez over 3 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Contraception Simulation R0.png preview Preview for 'Contraception Simulation R0' over 3 years ago, by Ricardo Gonzalez Download

This model does not have any ancestors.

This model does not have any descendants.