Modeling Nonspatial Socioeconomic Interactions

An Agent-Based Approach

Richard J. Gaylord

Jon S. Davis

Mathematica in Education and Research, in press.

Many important models of socioeconomic interactions depend upon social distance rather than spatial distance. Over time, social distance (connectivity) has increased in importance for many forms of interaction while spatial distance (proximity) has concomitantly decreased in importance. The growing role of social distance in socioeconomic interactions has followed advances in transportation and communications technologies and quite recently, this trend has accelerated explosively. Here, we will present a set of tools, along with some examples of their use, for the modeling of socioeconomic behavior in which there is a social rather than spatial dimension.

Defining Agents

Each individual is characterized by a list whose elements indicate the individual's attributes. These attributes are represented by numbers and lists of numbers. Attributes may include the individual's name, a list of the names of the members of the individual's social network and usually one or more of the following:

social status,

wealth,

a list of the values of the individual's culturally determined memes (eg., religious or political affiliation),

a list of various other attributes (eg., gender, race, intelligence, risk preferences, etc.).

The first element of each individual's attribute list is a unique integer that represents the individual's name. Initially, we assign these integer "names" sequentially to members of society. This practice makes it easy to sort the list of society members so that a person with name i is in the (i^th) position in the list. As will become apparent below, the ability to sort society in this way simplifies the introduction of social interaction. The second element in each individual's attribute list is a list of the names of every person in the individual's social network. Other values representing characteristics of an individual are located at whatever positions in the list we choose.

Populating Society

Society is simply a list of the attribute lists of people. As an illustration, we will create a society consisting of eight people (n), each with four attributes. In each person's attribute list,

the first element represents the person's name,

the second element is a list of the names of the members of the person's social network, randomly selected from society (with a maximum length, f, of two names),

the third element represents the person's social status (a real number between zero and one, randomly drawn from a uniform distribution), and

the fourth element is a two-element list (s), where each element represents a meme value randomly set at either one or two (m).

When selecting the members of each individual's social network, we delete the individual's own name from the list that is generated.

SeedRandom[9]
n = 8; s = 2; m = 2; f = 2;
society = 
 Map[{#, Union[DeleteCases[Table[Random[Integer,  {1,  n}],   {f}], 
   #] ],Random[], Table[Random[Integer,  {1,  m}],  {s}]}&, Range[n] ]

We can modify society so that anyone who is in another person's social network includes that person in their own social network (i.e., reciprocal social connections).

symSoc = society /. 
 {a_Integer, b_, c___} :> 
    {a, Union[b, Cases[society, {x_, {___, a, ___}, _, _} :> x]], c}

Introducing Social Network Interaction

To introduce social interaction, we create an anonymous function, socNetFunction, that is applied directly to the society list (sorted by agent name). This function applies an interaction rule to each individual and his social network.  (We will show examples of interaction rules shortly.) The argument of the interaction rule is a nested list whose elements are the attribute list of an individual and the attribute lists of the members of his social network.

socNetFunction[rule_] :=Function[y, Map[rule[Join[{#}, y[[#[[2]] ]] ] ]&, y] ]

To illustrate the use of socNetFunction, we take the society of eight agents the in symSoc list created above and apply the general undefined rule foo to its members:

socNetFunction[foo][symSoc]

If a model involves individuals leaving the society over time (perhaps through death), individuals' positions in the society list will not correspond to their name. Consequently, a modified version of the socNetFunction must be used.

socNetFunctionAlt[rule_] :=Function[y, Map
[rule[Join[{#}, Cases[y,{Apply[Alternatives, 
                                  #[[2]]
                                     ], ___} ] ] ]&, y] ]

Note that while the socNetFunctionAlt could in principle, always be used in place of socNetFunction (obviating the need to keep the society list sorted), it executes much more slowly.

To apply an interaction rule to a society repeatedly over t time steps in order to observe dynamic behavior, we can use either the Nest, NestList, FixedPoint, or FixedPointList functions as illustrated below:

NestList[socNetFunction[foo],symSoc, t]

Examples of Social Network Interaction

For purposes of illustration, we introduce two network interaction rules. The first, emulate, models the effect of emulating those with higher status in one's social network. The second interaction rule, friendsOfFriends, provides an individual with a list of individuals who are acquaintances of members of his social network.

emulate

Each individual in this society is represented by a four-tuple attribute list of the form {name, socNetLis, socialStatus, memeLis} where the first attribute is the person's name, the second attribute is the list of the names of the members of her social network, the third attribute is the social status of the person, and the fourth attribute is her meme list.

During a time step, each individual locates the person in her social network who has the highest social status and changes the value of one of her memes,  randomly selected, to equal the value of the corresponding meme of that person. Thus, for an individual who is a member of a social network, the emulate rule is:

emulate[{{a_, b_, c_, d_}, res__}]:=
	{a,b,c,ReplacePart[d,Sort[{res},#1[[3]] > 
                              #2[[3]]&][[1, 4, #]],#]}&[Random[Integer, {1, s}]]

For an individual who is a loner outside of any social network (a person with an empty social network list—e.g., individual 3 in symSoc, above), the emulate rule leaves the person unchanged.

emulate[{{a_, {}, c_, d_}}] := {a, {}, c, d}

Using symSoc as the argument to the anonymous function socNetFunction[emulate], we can see the change in each individual's meme list after a single time step.

NestList[socNetFunction[emulate],symSoc,1]

friendsOfFriends

The following rules take a nested list containing the attribute lists of a person and the members of his social network (friends) and returns a four-tuple consisting of (1) the person's name, (2) an ordered pair whose first element is the list of the names of his friends and the second element is a list of lists of the names of his friends' friends, (3) his social status, and (4) his meme list.

friendsOfFriends[{{a_Integer, b_, c___}, res__}]:={a,{b,Transpose[{res}][[2]]},c}
friendsOfFriends[{{a_Integer, b_, c___}, res__}] := 
      {a, {}, c}

Using symSoc as the argument to the anonymous function socNetFunction[friendsOfFriends]

Nest[socNetFunction[friendsOfFriends], symSoc, 1]

The friendsOfFriends definition above includes the person's own name in the social network lists of the members of his social network. We can remove this duplication by using

friendsOfFriends2[{{a_, b_, c___}, res__}] := 
       {a,{b, Map[DeleteCases[#, a]&, Transpose[{res}][[2]]]}, c}

friendsOfFriends2[{{a_, {}, c___}}] := {a, {}, c}

The friendsOfFriends rules can be used to investigate the "six degrees of separation" phenomenon first identified by Milgram [1967. Milgram]. These rules also provide a foundation for studying information flow through social networks [1999. Davis, Gaylord and Johnson].

Social Network Interaction Program Template

network[dummy variables for input values]:=Module[{k = 0,localized names and initial values},

initNetConfig=Table[{++k,{network member names},numbers,symbols,lists},{n}];

updateRule[{values (or dummy variables) of network members
                      }]:=...;

socNetFunction[func_]:=Function[y,Map[func[Join[{#},y[[#[[2]]]]]]&,y]];

NestList[socNetFunction[updateRule],initNetConfig,t] ]

Bilateral Social Interaction

Sometimes, socioeconomic behavior is best characterized by bilateral interaction between two individuals. To model bilateral interaction, we employ two functions that apply rules to a given number of ordered pairs of randomly selected individuals, updating the values of both individuals simultaneously. The first function, randomPairings, creates a list of ordered pairs of individuals.

randomPairings[soc_]:=Partition[Transpose[Sort[Map[{Random[], #} &, #]]][[2]],2]&[soc]

Note that the randomPairings definition assumes that there are an even number of individuals in society. If this is not the case, or if the the number of individuals is not known, the randomPairingsAlt function below should be used, in which case it will be necessary to write an interaction rule of the form rule[{{x__}, {0}}] :={{x}}.

randomPairingsAlt[soc_]:=Partition[Join[Transpose[Sort[Map[{Random[], #} &, #]]][[2]],{0}],2]& [soc]

The second function, below, is analogous to socNetFunction. It applies an interaction rule to m pairs of agents generated by randomPairings (m can be specified or determined using a probability function). .

biInteractFunction[rule_]:=Function[y,Sort[Flatten[Join[Map[rule, 
                             #[[Range[m]
                                ]]],Drop[#, m]],1]]&[randomPairings[y]]]

An Example of Bilateral Social Interaction

To provide an example of bilateral social interaction, we replicate Alan Kirman's ant recruitment model [1988, 1993. Kirman]. In this model of tandem recruitment, each of 2n individuals has a unique name and a randomly value of  0 or 1 representing an opinion or belief on some subject. The following actions take place consecutively in a given time step.

[1] each individual spontaneously changes his opinion with a probability e (spontaneousChange), and

[2] each individual in society is randomly paired with another individual, resulting in n pairs of individuals

[3] in m ordered pairs of individuals, the first person changes his opinion to the opinion of the second person with a probability, d, unless his opinion was already changed in the previous partial-step (influencedChange).

In the code below, we introduce each of these actions as rules. The final statement uses NestList together with a variant of the biInteractFunction developed above.

antRecruitment[n_,  e_,  d_,  t_,  m_]:=Module[{k  =  0, society, randomPairings, spontaneousChange, influencedChange},

society  =  Table[{++k,  Random[Integer]},  {2 n}];

randomPairings[lis_] := 
                Partition[
                      Transpose[
                          Sort[Map[{Random[],  #} &,  
                              #]]][[2]],  2] &[lis];

spontaneousChange[{w_,  0}]  :=  
                {w, 1, 1}  /;  Random[]  > (1  -  e);
spontaneousChange[{w_,  1}]  :=  
                {w, 0, 1}  /;  Random[]  > (1  -  e);spontaneousChange[{w_,  x_}]  :=  {w,  x,  0};

\(influencedChange[{{v_, \ w_, \ 0}, \ {x_, \ y_, \ _}}]\  
                
                := \ \ \ 
			\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {{v, \ y}, \ 
                    {x, \ y}}\  /; \ Random[]\  > \ \((1\  - \ d)\)\);influencedChange[{{v_,  w_,  0},  {x_,  y_,  _}}]  :=  
                {{v, w},  {x,  y}};influencedChange[{{v_,  w_,  1},  {x_,  y_,  _}}]  :=  
                {{v, w},  {x, y}};

NestList[Function[y,Sort[Flatten[Join[Map[influencedChange, #[[Range[
                                        m]]]],(Drop[#,  m] /.  
                                        {x_,  y_,  z_}  :>  
                                        {x,  y})], 1]]&[randomPairings[Map[spontaneousChange, y]]]],        
			                    society, t] ]

This simple model can serve as a basis for individual behavior in financial markets [1999. Davis and Gaylord].

Bilateral Social Interaction Program Template

randomCoupling[dummy variables for input values]:=Module[{k = 0,localized names and initial values},

initAgentLis=Table[{++k,numbers,symbols,lists},{2 n}];

randomPairings[lis_] := 
                Partition[
                      Transpose[Sort[Map[{Random[], #}&, #]]]
                          [[2]], 2]&[
                  lis];
		
		biInteractFunction[rule_]:=Function[y,Sort[Flatten[Join[Map[rule, 
                                     #[[Range[m]
                                        ]]],Drop[#, m]],1]]&[randomPairings[y]]];
				
		updateRule[{values (or dummy variables) of network 
                        member pairs}]:=... ;

NestList[biInteractFunction[updateRule],initAgentLis,t] ]

References

Milgram, S. 1967. The small world problem. Psychology Today 2: 60-67.

Davis J.S.,  R.J. Gaylord and D. Johnson. 1999. The "small world" social network model: Diffusion of information and opinion. Unpublished Manuscript (University of Illinois at Urbana-Champaign).

Kirman, A. 1988. On ants and markets. European University Institute, 1-18.

Kirman, A. 1993. Ants, rationality and recruitment. Quarterly Journal of Economics (February): 137-156.

The Economist. 1992. Why a queue? (February 8), p. 67.

Davis, J.S., and R. J. Gaylord. 1999. Making money on market fads. In preparation.