Model of Social Identity Theory (slight update)

No preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0-M6 • Viewed 341 times • Downloaded 22 times • Run 0 times
Download the 'Model of Social Identity Theory (slight update)' 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

; Natalie Gallagher
; June 2016

extensions [ls]

globals [
  x                   ; useful for iteration stuff, basically empty variables
  z
  a
  b
  c
  all-ingroup-turtles
  prototypes-dim1
  prototypes-dim2
  prototypes-dim3
  dimension1-colors
  dimension2-colors
  dimension3-colors
  num-ticks
  intersectionality
  ]

turtles-own [
  brain               ; where you open the level-space brain
  dim1-level
  dim2-level
  dim3-level
  dimension-dominant    ; which category identity is dominant at any given time. This will always include the three basic dimensions. In some cases, it will also include intersections (i.e. 1-2, 1-3, 2-3, and 1-2-3) and individual (i.e. no collective identity activated)
  dimension-dominant-next ; which category identity will be dominant/expressed at the next tick
  switched-on-last-tick ; did this turtle change their identity on the last tick
  ingroup-agentset
  ingroup-size
  in-ingroup
  trait-values
  num-times-switched
]


patches-own [
  dim1-salience-from-context
  dim2-salience-from-context
  dim3-salience-from-context
]

to Setup
  clear-all
  ifelse intersectionality? [                     ; is intersectionality part of this model?
    set intersectionality 1][
    set intersectionality 0]
  create-turtles number-of-agents [
    setxy random-xcor random-ycor                    ; set each turtle to a random location
    set shape "circle"
    set size 1.5
    set dim1-level (random levels-social-dimension1) + 1
    set dim2-level (random levels-social-dimension2) + 1
    set dim3-level (random levels-social-dimension3) + 1
    set trait-values n-values number-of-traits [random 101]         ; set each turtle to a random set of traits
    set num-times-switched 0
    set switched-on-last-tick 0
    ifelse intersectionality = 1 [
      set dimension-dominant one-of (list 1 2 3 12 23 13)
    ][
      set dimension-dominant (random 3)
      set dimension-dominant dimension-dominant + 1]
    set ingroup-agentset nobody
    ]

  set all-ingroup-turtles nobody
  set dimension1-colors (list 13 13.5 14 14.5 15 15.5 16 16.5 17 17.5) ;these are useful for coloring-turtles (used lists to deal with intersectional cases efficiently)
  set dimension2-colors (list 43 43.5 44 44.5 45 45.5 46 46.5 47 47.5)
  set dimension3-colors (list 103 103.5 104 104.5 105 105.5 106 106.5 107 107.5)

  setup-brain
  ask turtles [
    define-ingroup]
  set all-ingroup-turtles (turtle-set [ingroup-agentset] of turtles)
  ask turtles [
    determine-if-in-ingroup]
  ask patches [generate-patch-salience]
  setup-prototypes
  recolor-turtles
  reset-ticks
  tick
end 

to Go
  ask turtles [
      move       ; move to another patch within their distance
      (ls:ask brain [gather-salience ?1 ?2 ?3 ?4] dim1-salience-from-context dim2-salience-from-context dim3-salience-from-context intersectionality)   ; tell the child model to pick up all the salience from that place
      (ls:ask brain [define-comparative-fit ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?10 ?11 ?12 ?13]
          sharedlevel-distance-dim1
          sharedlevel-distance-dim2
          sharedlevel-distance-dim3
          notsharedlevel-distance-dim1
          notsharedlevel-distance-dim2
          notsharedlevel-distance-dim3
          sharedlevel-distance-intersection12
          sharedlevel-distance-intersection23
          sharedlevel-distance-intersection13
          notsharedlevel-distance-intersection12
          notsharedlevel-distance-intersection23
          notsharedlevel-distance-intersection13
          intersectionality)
      (ls:ask brain [define-normative-fit ?1 ?2 ?3 ?4 ?5 ?6 ?7]
          normative-fit-dim1
          normative-fit-dim2
          normative-fit-dim3
          normative-fit-intersection12
          normative-fit-intersection23
          normative-fit-intersection13
          intersectionality)
      set num-ticks ticks
      (ls:ask brain [set-social-identification ?1 ?2 ?3] num-ticks dimension-dominant intersectionality)
      (ls:ask brain [determine-next-dimension ?1 ?2 ?3 ?4 ?5 ?6] normative-fit-weight comparative-fit-weight environmental-salience-weight social-identification-weight intersectionality dimension-dominant)
      set dimension-dominant-next (ls:report brain [dimension-dominant-next-child])
      define-ingroup]
  set all-ingroup-turtles (turtle-set [ingroup-agentset] of turtles)
  ask turtles [
      determine-if-in-ingroup
      dominant-identity-switch]
  recolor-turtles
  tick
end 

to setup-prototypes
  ; first, generate the list of lists that I'll populate with prototypes from the actual agents
  set prototypes-dim1 n-values levels-social-dimension1 [n-values number-of-traits [0]]
  set prototypes-dim2 n-values levels-social-dimension2 [n-values number-of-traits [0]]
  set prototypes-dim3 n-values levels-social-dimension3 [n-values number-of-traits [0]]
  set a 1
  set b 1
  set c 1

  while [a <= levels-social-dimension1] [                                           ; this will iterate for each level of Dimension1
    ; collate list of lists of all agents with each level of each category
    if any? turtles with [dim1-level = a] [
      set x (map [[trait-values] of ?] sort turtles with [dim1-level = a])
      set z 1                            ; this will iterate for each TRAIT
      while [z <= number-of-traits] [
        set prototypes-dim1 replace-item (a - 1) prototypes-dim1 (replace-item (z - 1) (item (a - 1) prototypes-dim1) mean (map [item (z - 1) ?] x))
        set z z + 1]]
    set a a + 1]

  while [b <= levels-social-dimension2] [                                           ; this will iterate for each level of Dimension2
    ; collate list of lists of all agents with each level of each category
    if any? turtles with [dim2-level = b] [
      set x (map [[trait-values] of ?] sort turtles with [dim2-level = b])
      set z 1                            ; this will iterate for each TRAIT
      while [z <= number-of-traits] [
        set prototypes-dim2 replace-item (b - 1) prototypes-dim2 (replace-item (z - 1) (item (b - 1) prototypes-dim2) mean (map [item (z - 1) ?] x))
        set z z + 1]]
    set b b + 1]

  while [c <= levels-social-dimension3] [                                           ; this will iterate for each level of Dimension3
    ; collate list of lists of all agents with each level of each category
    if any? turtles with [dim3-level = c] [
      set x (map [[trait-values] of ?] sort turtles with [dim3-level = c])
      set z 1                            ; this will iterate for each TRAIT
      while [z <= number-of-traits] [
        set prototypes-dim3 replace-item (c - 1) prototypes-dim3 (replace-item (z - 1) (item (c - 1) prototypes-dim3) mean (map [item (z - 1) ?] x))
        set z z + 1]]
    set c c + 1]
end 

to setup-brain
  while [length ls:models < count turtles] [
  (ls:load-headless-model "05302016_Brain1.nlogo")]
  let available-brains ls:models
  ask turtles [
    set brain first available-brains
    set available-brains but-first available-brains
    ls:set-name brain (word "Brain of " self)
    (ls:ask brain [setup ?1 ?2 ?3] levels-social-dimension1 levels-social-dimension2 levels-social-dimension3)
    (ls:ask brain [activate-levels ?1 ?2 ?3 ?4] dim1-level dim2-level dim3-level dimension-dominant)]
end 

to move                    ; turtles move some random amount in a random direction, so they're exposed to new "environmental" or "patch" influences
  lt random 360
  rt random 360
  fd random 5
end 

to dominant-identity-switch ; agent procedure
  ifelse dimension-dominant != dimension-dominant-next [         ; if the current category doesn't match the "next" category,
    set dimension-dominant dimension-dominant-next
    set switched-on-last-tick 1
    set num-times-switched num-times-switched + 1] [
    set switched-on-last-tick 0]
end 

to generate-patch-salience
      set dim1-salience-from-context n-values levels-social-dimension1 [(random 100) + 1]   ; for each level of each category, each patch has a random % salience
      set dim2-salience-from-context n-values levels-social-dimension2 [(random 100) + 1]
      set dim3-salience-from-context n-values levels-social-dimension3 [(random 100) + 1]
end 

to define-ingroup  ; turtle procedure
     if [dimension-dominant] of self = 1 [
        set ingroup-agentset agentset-enacting-my-dim1-level with [WHO != [WHO] of myself]]
      if [dimension-dominant] of self = 2 [
        set ingroup-agentset agentset-enacting-my-dim2-level with [WHO != [WHO] of myself]]
      if [dimension-dominant] of self = 3 [
        set ingroup-agentset agentset-enacting-my-dim3-level with [WHO != [WHO] of myself]]
      if [dimension-dominant] of self = 12 [
        set ingroup-agentset agentset-enacting-my-dim1-dim2-intersection with [WHO != [WHO] of myself]]
      if [dimension-dominant] of self = 23 [
        set ingroup-agentset agentset-enacting-my-dim2-dim3-intersection with [WHO != [WHO] of myself]]
      if [dimension-dominant] of self = 13 [
        set ingroup-agentset agentset-enacting-my-dim1-dim3-intersection with [WHO != [WHO] of myself]]
      set ingroup-size count ingroup-agentset
end 

to determine-if-in-ingroup        ; this is where each turtle determines whether it is, at all, in an ingroup
     ifelse member? self all-ingroup-turtles [                                ; ask each turtle to determine whether it is a member of the overall ingroup, and set its value accordingly
       set in-ingroup 1][
       set in-ingroup 0]
end 

to recolor-turtles
  if (TurtleColors = "Dominant Dimension") [       ; if the switch is set for turtles to display their dominant category, do this
    ask turtles [                                      ; set overall color based on categorydominant, and then each level within each category is a particular color
      if dimension-dominant = 1 [
        set color item (dim1-level - 1) dimension1-colors]
      if dimension-dominant = 2 [
        set color item (dim2-level - 1) dimension2-colors]
      if dimension-dominant = 3 [
        set color item (dim3-level - 1) dimension3-colors]
      if dimension-dominant = 12 [
        set color (20 + (((item (dim1-level - 1) dimension1-colors) + (item (dim2-level - 1) dimension2-colors) - 50) / 2))]
      if dimension-dominant = 23 [
        set color (50 + (((item (dim3-level - 1) dimension3-colors) + (item (dim2-level - 1) dimension2-colors) - 140) / 2))]
      if dimension-dominant = 13 [
        set color (110 + (((item (dim1-level - 1) dimension1-colors) + (item (dim3-level - 1) dimension3-colors) - 110) / 2))]]]

  if (TurtleColors = "In An Ingroup") [
    ask turtles [
      if in-ingroup = 1 [
        set color green]
      if in-ingroup = 0 [
        set color gray]]]

  if (TurtleColors = "Switched On Last Tick") [
    ask turtles [
      if switched-on-last-tick = 1 [
        set color green]
      if switched-on-last-tick = 0 [
        set color gray]]]
end 




;; Below here is all reporters.

to-report percent-excluded
  ifelse any? all-ingroup-turtles [
    report 100 - ((count all-ingroup-turtles / count turtles) * 100)]
    [report 100]
end 

to-report mean-ingroup-size
  ifelse any? all-ingroup-turtles [
    report mean([ingroup-size] of turtles)]
    [report 0]
end 

to-report percent-switched-on-last-tick
  report ( count turtles with [switched-on-last-tick = 1] / count turtles) * 100
end 

to-report percent-expressing-dim1
  report (count turtles with [dimension-dominant = 1]) * 100 / (count turtles)
end 

to-report percent-expressing-dim2
  report (count turtles with [dimension-dominant = 2]) * 100 / (count turtles)
end 

to-report percent-expressing-dim3
  report (count turtles with [dimension-dominant = 3]) * 100 / (count turtles)
end 

to-report percent-expressing-intersection12
  report (count turtles with [dimension-dominant = 12]) * 100 / (count turtles)
end 

to-report percent-expressing-intersection23
  report (count turtles with [dimension-dominant = 23]) * 100 / (count turtles)
end 

to-report percent-expressing-intersection13
  report (count turtles with [dimension-dominant = 13]) * 100 / (count turtles)
end 

to-report percent-intersectional
  report (count turtles with [dimension-dominant = 12 or dimension-dominant = 23 or dimension-dominant = 13])/(count turtles) * 100
end 

to-report mean-percent-switches-per-turtle
  ifelse ticks != 0 [
  report 100 * mean([num-times-switched] of turtles) / ticks][
  report 0]
end 

; Relevant for the calculation of Comparative Fit

to-report query-distance [ person ]
  let othertraitlist [trait-values] of person
  let traitdistance mean ( map [ abs(?1 - ?2)] othertraitlist trait-values)
  report traitdistance
end 

to-report agentset-enacting-my-dim1-level
  report turtles with [dimension-dominant = 1 and dim1-level = [dim1-level] of myself]
end 

to-report agentset-enacting-my-dim2-level
  report turtles with [dimension-dominant = 2 and dim2-level = [dim2-level] of myself]
end 

to-report agentset-enacting-my-dim3-level
  report turtles with [dimension-dominant = 3 and dim3-level = [dim3-level] of myself]
end 

to-report agentset-enacting-my-dim1-dim2-intersection
  report turtles with [dimension-dominant = 12 and dim1-level = [dim1-level] of myself and dim2-level = [dim2-level] of myself]
end 

to-report agentset-enacting-my-dim2-dim3-intersection
  report turtles with [dimension-dominant = 23 and dim2-level = [dim2-level] of myself and dim3-level = [dim3-level] of myself]
end 

to-report agentset-enacting-my-dim1-dim3-intersection
  report turtles with [dimension-dominant = 13 and dim1-level = [dim1-level] of myself and dim3-level = [dim3-level] of myself]
end 

to-report sharedlevel-distance-dim1
  ifelse any? agentset-enacting-my-dim1-level [
      ifelse (round( mean([query-distance myself] of agentset-enacting-my-dim1-level))) = 0 [
        report 1]
      [ report round( mean([query-distance myself] of agentset-enacting-my-dim1-level))]]
  [report 100] ; if there are no turtles enacting my level of category 1, then ingroup homogeneity is as high as possible (it's only me), which is the number of traits on which differing is possible, times the maximum possible difference on any single trait, which is 100
end 

to-report sharedlevel-distance-dim2
  ifelse any? agentset-enacting-my-dim2-level [
    ifelse (round( mean([query-distance myself] of agentset-enacting-my-dim2-level))) = 0 [
        report 1]
      [ report round( mean([query-distance myself] of agentset-enacting-my-dim2-level))]]
  [report 100]
end 

to-report sharedlevel-distance-dim3
  ifelse any? agentset-enacting-my-dim3-level [
      ifelse (round( mean([query-distance myself] of agentset-enacting-my-dim3-level))) = 0 [
        report 1]
      [ report round( mean([query-distance myself] of agentset-enacting-my-dim3-level))]]
  [report 100]
end 

to-report sharedlevel-distance-intersection12
  ifelse any? agentset-enacting-my-dim1-dim2-intersection [
      ifelse (round( mean([query-distance myself] of agentset-enacting-my-dim1-dim2-intersection))) = 0 [
        report 1]
      [ report round( mean([query-distance myself] of agentset-enacting-my-dim1-dim2-intersection))]]
  [report 100]
end 

to-report sharedlevel-distance-intersection23
  ifelse any? agentset-enacting-my-dim2-dim3-intersection [
      ifelse (round( mean([query-distance myself] of agentset-enacting-my-dim2-dim3-intersection))) = 0 [
        report 1]
      [ report round( mean([query-distance myself] of agentset-enacting-my-dim2-dim3-intersection))]]
  [report 100]
end 

to-report sharedlevel-distance-intersection13
  ifelse any? agentset-enacting-my-dim1-dim3-intersection [
      ifelse (round( mean([query-distance myself] of agentset-enacting-my-dim1-dim3-intersection))) = 0 [
        report 1]
      [ report round( mean([query-distance myself] of agentset-enacting-my-dim1-dim3-intersection))]]
  [report 100]
end 

to-report notsharedlevel-distance-dim1
  ifelse any? other turtles with [not member? self agentset-enacting-my-dim1-level] [
      ifelse (round (mean([query-distance myself] of other turtles with [not member? self agentset-enacting-my-dim1-level]))) = 0 [  ; if this rounds down to zero
         report 1][
         report ( round (mean([query-distance myself] of other turtles with [not member? self agentset-enacting-my-dim1-level])))]]
  [report 100]
end 

to-report notsharedlevel-distance-dim2
  ifelse any? other turtles with [not member? self agentset-enacting-my-dim2-level] [
      ifelse ( round (mean([query-distance myself] of other turtles with [not member? self agentset-enacting-my-dim2-level]))) = 0 [  ; if this rounds down to zero
         report 1][
         report ( round (mean([query-distance myself] of other turtles with [not member? self agentset-enacting-my-dim2-level])))]]
  [report 100] ; if there are no turtles outside of the identity I'm considering, intergroup is as high as possible
end 

to-report notsharedlevel-distance-dim3
  ifelse any? other turtles with [not member? self agentset-enacting-my-dim3-level] [
      ifelse ( round (mean([query-distance myself] of other turtles with [not member? self agentset-enacting-my-dim3-level]))) = 0 [  ; if this rounds down to zero
         report 1][
         report ( round (mean([query-distance myself] of other turtles with [not member? self agentset-enacting-my-dim3-level])))]]
  [report 100]
end 

to-report notsharedlevel-distance-intersection12
  ifelse any? other turtles with [not member? self agentset-enacting-my-dim1-dim2-intersection] [
      ifelse ( round (mean([query-distance myself] of other turtles with [not member? self agentset-enacting-my-dim1-dim2-intersection]))) = 0 [  ; if this rounds down to zero
         report 1][
         report ( round (mean([query-distance myself] of other turtles with [not member? self agentset-enacting-my-dim1-dim2-intersection])))]]
  [report 100]
end 

to-report notsharedlevel-distance-intersection23
  ifelse any? other turtles with [not member? self agentset-enacting-my-dim2-dim3-intersection] [
      ifelse ( round (mean([query-distance myself] of other turtles with [not member? self agentset-enacting-my-dim2-dim3-intersection]))) = 0 [  ; if this rounds down to zero
         report 1][
         report ( round (mean([query-distance myself] of other turtles with [not member? self agentset-enacting-my-dim2-dim3-intersection])))]]
  [report 100]
end 

to-report notsharedlevel-distance-intersection13
  ifelse any? other turtles with [not member? self agentset-enacting-my-dim1-dim3-intersection] [
      ifelse ( round (mean([query-distance myself] of other turtles with [not member? self agentset-enacting-my-dim1-dim3-intersection]))) = 0 [  ; if this rounds down to zero
         report 1][
         report ( round (mean([query-distance myself] of other turtles with [not member? self agentset-enacting-my-dim1-dim3-intersection])))]]
  [report 100]
end 


; Relevant for calculation of Normative Fit

to-report distance-from-prototype-dim1
  report mean(map [ abs( ?1 - ?2)] trait-values item (dim1-level - 1) prototypes-dim1)
end 

to-report distance-from-prototype-dim2
  report mean( map [ abs( ?1 - ?2)] trait-values item (dim2-level - 1) prototypes-dim2)
end 

to-report distance-from-prototype-dim3
  report mean( map [ abs( ?1 - ?2)] trait-values item (dim3-level - 1) prototypes-dim3)
end 

to-report distance-from-prototype-intersection12
  report mean( map [abs (?1 - ?2)] trait-values (map[(?1 + ?2) / 2] item (dim1-level - 1) prototypes-dim1 item (dim2-level - 1) prototypes-dim2))
end 

to-report distance-from-prototype-intersection23
    report mean( map [abs (?1 - ?2)] trait-values (map[(?1 + ?2) / 2] item (dim2-level - 1) prototypes-dim2 item (dim3-level - 1) prototypes-dim3))
end 

to-report distance-from-prototype-intersection13
    report mean( map [abs (?1 - ?2)] trait-values (map[(?1 + ?2) / 2] item (dim1-level - 1) prototypes-dim1 item (dim3-level - 1) prototypes-dim3))
end 

to-report normative-fit-dim1
  ifelse any? agentset-enacting-my-dim1-level [                  ; are there any turtles that have my level of category 1 and are expressing it, including myself?
    ifelse round( mean([distance-from-prototype-dim1] of agentset-enacting-my-dim1-level)) = 0 [    ; if so, how distant are those turtles expressing my level of category 1 from the prototype of my level of category 1
      report 1][
      report round( mean([distance-from-prototype-dim1] of agentset-enacting-my-dim1-level))]]
  [report 100]
end 

to-report normative-fit-dim2
  ifelse any? agentset-enacting-my-dim2-level [
    ifelse round( mean([distance-from-prototype-dim2] of agentset-enacting-my-dim2-level)) = 0 [    ; if so, how distant are those turtles expressing my level of category 1 from the prototype of my level of category 1
      report 1][
      report round( mean([distance-from-prototype-dim2] of agentset-enacting-my-dim2-level))]]
  [report 100]
end 

to-report normative-fit-dim3
  ifelse any? agentset-enacting-my-dim3-level [
    ifelse round( mean([distance-from-prototype-dim3] of agentset-enacting-my-dim3-level)) = 0 [    ; if so, how distant are those turtles expressing my level of category 1 from the prototype of my level of category 1
      report 1][
      report round( mean([distance-from-prototype-dim3] of agentset-enacting-my-dim3-level))]]
  [report 100]
end 

to-report normative-fit-intersection12
    ifelse any? agentset-enacting-my-dim1-dim3-intersection [
    ifelse round(mean([distance-from-prototype-intersection13] of agentset-enacting-my-dim1-dim3-intersection)) = 0 [
      report 1][
      report round(mean([distance-from-prototype-intersection13] of agentset-enacting-my-dim1-dim3-intersection))]]
  [report 100]
end 

to-report normative-fit-intersection23
    ifelse any? agentset-enacting-my-dim2-dim3-intersection [
    ifelse round(mean([distance-from-prototype-intersection23] of agentset-enacting-my-dim2-dim3-intersection)) = 0 [
      report 1][
      report round(mean([distance-from-prototype-intersection23] of agentset-enacting-my-dim2-dim3-intersection))]]
  [report 100]
end 

to-report normative-fit-intersection13
  ifelse any? agentset-enacting-my-dim1-dim3-intersection [
    ifelse round(mean([distance-from-prototype-intersection13] of agentset-enacting-my-dim1-dim3-intersection)) = 0 [
      report 1][
      report round(mean([distance-from-prototype-intersection13] of agentset-enacting-my-dim1-dim3-intersection))]]
  [report 100]
end 

There is only one version of this model, created almost 8 years ago by Natalie Gallagher.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.