Download - ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
![Page 1: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/1.jpg)
Introduction to Computing for Complex Systems
(Lab Session 4)
Daniel Martin KatzMichigan State University
College of Law
![Page 2: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/2.jpg)
Take a Look at this Article
from the Economist
(July 22, 2010)
Agent Based Models and
Positive Economic Theory
Refer Back to my slides about equilibrium and its discontents
![Page 3: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/3.jpg)
![Page 4: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/4.jpg)
Schelling Social Segregation Model
![Page 5: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/5.jpg)
the full model
![Page 6: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/6.jpg)
![Page 7: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/7.jpg)
Print This and Draw the Connections for a Full Map
of the Schelling Code
![Page 8: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/8.jpg)
Mapping of the Schelling Code(%-similar-wanted is a slider)
![Page 9: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/9.jpg)
We Need to see What “update-varables” is Actually Doing
![Page 10: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/10.jpg)
![Page 11: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/11.jpg)
![Page 12: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/12.jpg)
Here we are going to “set” some of our “turtles-own” variables
![Page 13: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/13.jpg)
![Page 14: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/14.jpg)
“Set” the Turtles-own Variable “similar-nearby”
to the count of “turtles-on” neighbors (8 of them)
but only those with color = my color
![Page 15: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/15.jpg)
“Set” the Turtles-own Variable “other-nearby”
to the count of “turtles-on” neighbors (8 of them)
but only those with color = not my color
![Page 16: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/16.jpg)
Take a look at what is happening here
The “happy?” condition is going to be important
involves an agent by agent comparison of the spread between “similarity-wanted” & “similar-nearby”
![Page 17: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/17.jpg)
Now Lets Look at “Update-globals”
It involves “lets” and “sets”
uses the globals but also some of the turtles-own variables
![Page 18: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/18.jpg)
I will allow you to review this on your own
However, consider the syntax of “sum”
![Page 19: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/19.jpg)
(1) Right Click (ctrl + Click on Mac) on the “percent-similar” plot
(2) This will appear and will allow for various modifications(color, interval, etc.)
![Page 20: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/20.jpg)
![Page 21: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/21.jpg)
![Page 22: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/22.jpg)
![Page 23: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/23.jpg)
![Page 24: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/24.jpg)
We now consider the “to go” portion of the code
![Page 25: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/25.jpg)
lets reduce the “to go” procedures
the “to go” portion of the code
above are the major new elements
remember conceptually the model relies upon movement if a turtle is unhappy
![Page 26: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/26.jpg)
Again, we have the “if”
the “to go” portion of the code
The “to go” button with stop when all turtles are “happy?”
Here is how “Happy?” gets set:
model continues to tick until every agent is above the “%-similar-wanted” as set on the slider
![Page 27: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/27.jpg)
create an agentset of “not happy?” turtles
the movement portion of the code
For that agentset we run the “find-new-spot” procedures
We know from the “to go” procedures that this is going to continue to run until the “if” condition is satisfied
![Page 28: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/28.jpg)
the movement portion of the code
![Page 29: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/29.jpg)
the movement portion of the code
![Page 30: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/30.jpg)
the movement portion of the code
Notice that it is going to re-run the “find-new-spot”
If the “if” condition is met
In other words, agents are going to move until they find a open patch
then agent will occupy the center of open patch
![Page 31: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/31.jpg)
![Page 32: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/32.jpg)
Thinking about Extensions to the Schelling Model
This is closer to a “representative agent” model
Agents are homogenous in their %similar-wanted
In reality, there is likely variance across agents
In other words, comparing across agents there are differential preferences with respect to the %similar-wanted
![Page 33: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/33.jpg)
Thinking about Extensions to the Schelling Model
spatial considerations
The 8 neighbors might not be how individuals actually make their assessments
agents might make choices based upon a wider assessment of the neighborhood
there might be different “prices” for different patches (i.e. a simulated housing market)
![Page 34: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/34.jpg)
Thinking about Extensions to the Schelling Model
structural considerations
the model could encode certain barriers to entry to particular neighborhoods
barriers could be highly asymmetric(i.e. red turtles face no barriers and green turtles face high barriers)
![Page 35: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/35.jpg)
![Page 36: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/36.jpg)
An Exercise
Start With the Default Implementation of
Social Segregation
Imagine that you are interested in
developing a certain style of integration
![Page 37: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/37.jpg)
Modify the Code as Needed in Order to Produce The Closest Possible Model Run to the Camouflage
Note: this involves 4 Groups not 2 Groups
Your Goal!
An Exercise
![Page 38: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/38.jpg)
Send Me Your Best Effort
I will announce the Winner
![Page 39: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/39.jpg)
![Page 40: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/40.jpg)
Simple Birth Rates
![Page 41: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/41.jpg)
Simple Birth Rates
![Page 42: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/42.jpg)
Simple Birth Rates
![Page 43: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/43.jpg)
Simple Birth Rates
take a few minutes and play around with the model
consider the questions offered above
![Page 44: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/44.jpg)
Thinking Conceptually:Simple Birth Rates
What Does the Turtle Movement Add to the Model?
Are Turtles Added to the Model? and If So How?
Are Turtles Removed from the Model? and If So How?
![Page 45: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/45.jpg)
Simple Birth Rates:Exploring the Code
![Page 46: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/46.jpg)
Step 1: map the dependancies
Step 2: learn the syntax and functionality for all unknown primitives
Step 3: read each line of code and determine what it doing
Simple Birth Rates
Step 4: sketch a procedures map that follows the chronology of your program
At this point it is more Important for you to go though the models line by line on your own using
the above protocol
![Page 47: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/47.jpg)
Simple Birth Rates
![Page 48: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/48.jpg)
Experiment
Basic Setup
Simple Birth Rates
Death
Plots
Reproduction
Movement
![Page 49: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/49.jpg)
Simple Birth Rates
“To Setup” Procedures
![Page 50: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/50.jpg)
Simple Birth Rates
“To Go” Procedures
![Page 51: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/51.jpg)
Simple Birth Rates
Turtle Movement Procedures
![Page 52: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/52.jpg)
Simple Birth Rates
PleaseReview “ifelse”
How does it work?
![Page 53: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/53.jpg)
Simple Birth Rates
Take a Look at the
Reproduction Procedures
![Page 54: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/54.jpg)
Simple Birth Rates
Death Procedures
Plot Procedures
![Page 55: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/55.jpg)
![Page 56: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/56.jpg)
Simple Birth Rates
Right Click (ctrl + Click on Mac) on the “run experiment” Button
![Page 57: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/57.jpg)
Simple Birth Ratesforever button
Notice observer is selected
Calls upon the go-experiment
sub-procedures
Name of our Button
![Page 58: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz](https://reader035.vdocuments.us/reader035/viewer/2022062615/548bb66ab4795996348b4add/html5/thumbnails/58.jpg)
Simple Birth Rates
Take a look at this for later in the week
Automation is really going to help us