New Simple Economy 2.0.1

New Simple Economy 2.0.1 preview image

1 collaborator

Thai_visa_cr Carl Snare (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.4 • Viewed 294 times • Downloaded 21 times • Run 0 times
Download the 'New Simple Economy 2.0.1' modelDownload this modelEmbed this model

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


Info tab cannot be displayed because of an encoding error

Comments and Questions

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

Click to Run Model

globals [
  gini-index-reserve
  lorenz-points
  Pareto-ratio
]

turtles-own [ wealth ]

to setup
 clear-all
  ask patches [ set pcolor white ]
  create-turtles num-agents [
    ;; everyone starts with the same amount of after-tax money
    set wealth initial-wealths
    set shape "circle"
    set color 125
    set size 3
    ;; visualize the turtles from left to right in ascending order of wealth
    setxy wealth random-ycor  ; all agents have same initial wealth
  ]
    update-lorenz-and-gini
  reset-ticks
end 

to recolor-turtles
  ;; Set the class of the turtles -- if a turtle has less than a third
  ;; the wealth of the richest turtle, color it red.  If between one
  ;; and two thirds, color it green.  If over two thirds, color it blue.

  ; ask turtles [set wealth sort wealth]
  let max-wealth max [wealth] of turtles
  ask turtles
    [ ifelse (wealth <= max-wealth / 3)
        [ set color red ] ; one-third of maximum wealth
        [ ifelse (wealth <= (max-wealth * 2 / 3))  ; two-thirds of maximum wealth
            [ set color green ]
        [ set color blue ] ]
  ]
end 

to go
  ;; agents with less than the transaction amount can't give it away
  ask turtles [if wealth >= transaction-amount [ transact-and-update ]]
  ;; prevent wealthy turtles from moving too far to the right
  ask turtles [ ifelse wealth <= max-pxcor [ set xcor wealth ] [ set xcor wealth * 2]] ; xcor can't exceed max-pxcor
  recolor-turtles
  update-lorenz-and-gini
  tick
end 

to transact-and-update
  ;; prevent rich turtles from going too far to the right
  if wealth >= max-pxcor [ set xcor max-pxcor ]
  ;; give transaction-amount to another turtle
  set wealth wealth - transaction-amount
  ask one-of other turtles [ set wealth wealth + transaction-amount ]
end 

to update-lorenz-and-gini

  ;; this procedure recomputes the value of gini-index-reserve
  ;; and the points in lorenz-points for the Lorenz and Gini-Index plots
  ;; initialize variables before computing Lorenz curve and Gini
  let sorted-wealths sort [wealth] of turtles
  let total-wealths sum sorted-wealths
  let wealth-sum-so-far 0
  let index 0
  set gini-index-reserve 0
  set lorenz-points []

  ;; now actually plot the Lorenz curve -- along the way, we also
  ;; calculate the Gini index.
  ;; (see the Info tab for a description of the curve and measure)
  repeat num-agents [
    set wealth-sum-so-far (wealth-sum-so-far + item index sorted-wealths)
    set lorenz-points lput ((wealth-sum-so-far / total-wealths) * 100) lorenz-points
    set index (index + 1)  ; counts the number of agents in this loop
    set gini-index-reserve gini-index-reserve + (index / num-agents) - (wealth-sum-so-far / total-wealth)
  ]
end 

to-report top-10-pct-wealth
  report sum [ wealth ] of max-n-of (count turtles * 0.10) turtles [ wealth ]
end 

to-report top-20-pct-wealth
  report sum [ wealth ] of max-n-of (count turtles * 0.20) turtles [ wealth ]
end 

to-report bottom-50-pct-wealth
  report sum [ wealth ] of min-n-of (count turtles * 0.50) turtles [ wealth ]
end 

to-report bottom-80-pct
  report sum [ wealth ] of min-n-of (count turtles * 0.80) turtles [ wealth ]
end 

to-report total-wealth
  report sum [ wealth ] of turtles
end 

to-report Pareto-80/20-test
  report ((sum [ wealth ] of min-n-of (count turtles * 0.80) turtles [ wealth ]) - (sum [ wealth ] of max-n-of (count turtles * 0.20) turtles [ wealth ]))
end 

to-report wealth-by-class
  report (sum [ wealth ] of turtles with [ color = red ])
  report (sum [ wealth ] of turtles with [ color = green ])
  report (sum [ wealth ] of turtles with [ color = blue ])
end 

to-report top-wealth-%
  report ((sum [ wealth ] of turtles with [ color = blue]) / (sum [ wealth ] of turtles) * 100)
end 

to-report mid-wealth-%
   report ((sum [ wealth ] of turtles with [ color = green ]) / (sum [ wealth ] of turtles) * 100)
end 

to-report low-wealth-%
   report ((sum [ wealth ] of turtles with [ color = red ]) / (sum [ wealth ] of turtles) * 100)
end 

to-report top-wealth-population
  report (count turtles with [ color = blue ])
end 

to-report mid-wealth-population
  report (count turtles with [ color = green ])
end 

to-report low-wealth-population
  report (count turtles with [ color = red ])
end 

to-report top-average-wealth
   report (((sum [ wealth ] of turtles with [ color = blue ]) / (count turtles)))
end 

to-report mid-average-wealth
   report ((sum [ wealth ] of turtles with [ color = green ]) / (count turtles))
end 

to-report low-average-wealth
   report ((sum [ wealth ] of turtles with [ color = red ]) / (count turtles))
end 

to-report upper-third-wealth
  report sum [ wealth ] of turtles with [ color = blue]
end 

to-report middle-third-wealth
   report sum [ wealth ] of turtles with [ color = green]
end 

to-report lower-third-wealth
   report sum [ wealth ] of turtles with [ color = red]
end 

There is only one version of this model, created almost 6 years ago by Carl Snare.

Attached files

File Type Description Last updated
New Simple Economy 2.0.1.png preview Preview for 'New Simple Economy 2.0.1' almost 6 years ago, by Carl Snare Download

This model does not have any ancestors.

This model does not have any descendants.