Citation
Statistical analysis of some problems in evolutionary population dynamics

Material Information

Title:
Statistical analysis of some problems in evolutionary population dynamics
Creator:
Nielsen, Aaron D.
Place of Publication:
Denver, CO
Publisher:
University of Colorado Denver
Publication Date:
Language:
English

Thesis/Dissertation Information

Degree:
Doctorate ( Doctor of philosophy)
Degree Grantor:
University of Colorado Denver
Degree Divisions:
Department of Mathematical and Statistical Sciences, CU Denver
Degree Disciplines:
Applied mathematics
Committee Chair:
Santorico, Stephanie
Committee Members:
Simon, Burton
Hendricks, Audrey
Cobb, Loren
Doebeli, Michael

Record Information

Source Institution:
University of Colorado Denver
Holding Location:
Auraria Library
Rights Management:
Copyright AAron D. Nielsen. Permission granted to University of Colorado Denver to digitize and display this item for non-profit research and educational purposes. Any reuse of this item in excess of fair use or other copyright exemptions requires permission of the copyright holder.

Downloads

This item has the following downloads:


Full Text
STATISTICAL ANALYSIS OF SOME PROBLEMS IN EVOLUTIONARY
POPULATION DYNAMICS by
AARON D. NIELSEN B.S. Colorado State University, 2007 B.S. Colorado State University, 2007 M.S. University of Colorado Boulder, 2008 M.S. University of Colorado Denver, 2012 M.S. Colorado State University, 2014
A thesis submitted to the Faculty of the Graduate School of the University of Colorado in partial fulfillment of the requirements for the degree of Doctor of Philosophy Applied Mathematics
2018


This thesis for the Doctor of Philosophy degree by Aaron D. Nielsen has been approved for the Applied Mathematics Program by
Stephanie Santorico, Chair Burton Simon, Advisor Audrey Hendricks Loren Cobb Michael Doebeli
Date: July 28, 2018
n


Nielsen, Aaron D. (Ph.D., Applied Mathematics)
Statistical Analysis of Some Problems in Evolutionary Population Dynamics Thesis directed by Associate Professor Burton Simon
ABSTRACT
Since Charles Darwin first published On the Origin of Species in 1859, scientists, philosophers, and mathematicians have been discussing the mechanisms of how evolution works in nature. Natural selection, the process by which individuals that are better adapted to their environment tend to leave more offspring than their cohort, is hotly debated on the particular mediums on which it functions. Unfortunately, many of these models fail to explain the evolution of cooperation. How is it possible for an individual that provides a benefit to its peers at its own expense able to thrive in a world of “survival of the fittest” ?
Over the past couple of decades, there has been a renewed interest into two-level population dynamics models which are one way to model evolutionary population dynamics. In these models, events occurring on the individual level (births and deaths of individuals) and events occurring on the group level (fissions and extinctions of groups of individuals) affect the overall population dynamics of the environment. This dissertation will examine the behavior and properties of evolutionary population dynamics using three related models: a stochastic model, a deterministic model, and a hybrid model. Two important problems from the held of evolutionary population dynamics will be discussed. First, the stochastic model will be used to study fixation times, the time until a population only has one type of individual. These results are contrasted with analogous results using the deterministic model which seem to suggest no fixing of populations. Second, the hybrid model is extended to simulate multiple levels of cooperation. The results from simulations with two types of individuals will be contrasted with simulations of three or more types of individuals and asymptotic results will be discussed. Of particular interest is how multiple levels of cooperation


can affect the overall population dynamics of the environment.
The form and content of this abstract are approved. I recommend its publication.
Approved: Burton Simon
IV


DEDICATION
This dissertation is dedicated to my family, the Nielsens and the Meyers.
v


ACKNOWLEDGMENTS
A special thanks to my dissertation committee members, Burt Simon, Stephanie Santorico, Audrey Hendricks, Loren Cobb, and Michael Doebeli, for their feedback and support.
vi


TABLE OF CONTENTS
CHAPTER
I. BACKGROUND.......................................................... 1
The Development of Evolutionary Theory...................... 1
Modes of Selection and the Evolution of Cooperation ........ 3
II. TWO-LEVEL POPULATION DYNAMICS MODEL................................. 6
Population Models.............................................. 6
One-Level Population Dynamics Model............................ 8
Two-Level Population Dynamics Model........................... 10
Model Assumptions ...................................... 11
Model 1: Stochastic Simulation Model.................... 12
Model 2: Deterministic PDE Model ....................... 15
Model 3: Hybrid Model................................... 17
Motivation for Research Problems.............................. 19
Introduction to Fixation Times Research................. 19
Introduction to Multiple Levels of Cooperation Research ... 20
III. FIXATION TIMES IN GROUP-STRUCTURED POPULATIONS .... 21
Fixation Times for the Continuous-Time Moran Process........ 21
A Simple and Useful Heuristic Calculation............. 24
Neutral-Drift Moran Process ............................ 25
Moran Process with Selection............................ 28
Fixation Times for Two-Level Population Dynamics Models..... 30
Example 1: Neutral Selection............................ 32
Example 2: Weak Selection............................... 36
Example 3: Public Good’s Game #1...................... 39
Example 4: Public Good’s Game #2........................ 44
Other Standard Games ................................... 47
vii


Conclusions
50
IV. MULTIPLE LEVELS OF COOPERATION ......................... 52
Generalizing to More Than Two Types of Individuals... 52
Computing Birth Rates when k > 2 52
Computing the Mutation Matrix when k > 2 ...... 53
Example 1: Public Goods Game......................... 59
Example 2: Snowdrift................................. 68
Conclusions ......................................... 76
V. FUTURE WORK.............................................. 77
REFERENCES................................................... 78
APPENDIX
A. MATLAB CODE ......................................... 80
B. R CODE.............................................. 190
viii


LIST OF TABLES
TABLE
1. Notation for various event rates...................................... 10
2. Example events in a simulation........................................ 13
3. Steady-state statistics (public goods game)........................... 65
4. Steady-state statistics (snowdrift)................................... 74
IX


LIST OF FIGURES
FIGURE
2.1 State of the environment at time t using the stochastic/simulation model 14
2.2 State of the environment at time t using the deterministic/PDE model . 16
2.3 Path of a single group using the hybrid model......................... 18
3.1 Expected time from state i to N for s = 0.01 using the simple heuristic . 24
3.2 Mean fixation times for K neutral-drift continuous-time Moran processes
of size N.............................................................. 25
3.3 Mean fixation times for K neutral-drift continuous-time Moran processes
of size N................................................................ 27
3.4 Mean fixation time for one asymmetric continuous-time Moran process of
size N................................................................... 28
3.5 Fixation time variance for one asymmetric continuous-time Moran process
of size N................................................................ 29
3.6 Simulated fixation times as a function of the group level events parameter,
s, and no migrations, fi = 0............................................. 33
3.7 Simulated fixation times as a function of the migration rate parameter, fi,
and no group level events, s = 0....................................... 34
3.8 Simulated fixation times as a function of the migration rate parameter, fi,
and group level events parameter, s (neutral selection)................ 35
3.9 Simulated fixation times as a function of the group level events parameter,
s, and no migrations, n = 0 (weak selection) .......................... 37
3.10 Simulated fixation times as a function of the migration rate parameter, fi,
and no group level events, s = 0 (weak selection) ..................... 38
3.11 Simulated fixation times as a function of the group level events parameter,
s, and migration rate parameter, n (weak selection).................... 39
x


3.12 Simulated fixation times as a function of the group level events parameter,
s, and no migrations, fi = 0............................................ 41
3.13 Simulated fixation times as a function of the migration rate parameter, fi,
and no group level events, s = 0........................................ 42
3.14 Simulated fixation times as a function of the group level events parameter,
s, and migration rate parameter, n...................................... 43
3.15 Simulated fixation times as a function of the group level events parameter,
s, and no migrations, n = 0............................................. 44
3.16 Simulated fixation times as a function of the migration rate parameter, fi,
and no group level events, s = 0........................................ 45
3.17 Simulated fixation times as a function of the group level events parameter,
s, and migration rate parameter, n...................................... 46
3.18 State of the environment for snowdrift example with migration .......... 49
4.1 Mutation Probabilities for i = 0,1,..., 5 (Mutation Method #1)........... 55
4.2 Mutation Probabilities for i = 0,1,..., 5 (Mutation Method #2)........... 56
4.3 Mutation Probabilities for i = 0,1,..., 5 (Mutation Method #3)........... 57
4.4 State of the environment at time t using the deterministic/PDE model . 60
4.5 Hybrid model results for public goods game example at t = 1000 (k = 2) 62
4.6 Hybrid model results for public goods game example at t = 1000 (k = 3) 63
4.7 Hybrid model results for public goods game example at t = 1000 (k = 5) 64
4.8 Hybrid model results for public goods game example at t = 1000 (k = 10) 65
4.9 Hybrid model results for public goods game example at t = 1000 (k = 100) 66
4.10 Comparison of steady-state distributions for different values of k...... 67
4.11 Hybrid model results for snowdrift example at t = 1000 (k = 2)........... 70
4.12 Hybrid model results for snowdrift example at t = 1000 (k = 3)........... 71
4.13 Hybrid model results for snowdrift example at t = 1000 (k = 5)........... 72
4.14 Hybrid model results for snowdrift example at t = 5000 (k = 10).......... 73
xi


4.15 Hybrid model results for snowdrift example at t = 5000 (k = 100) .... 74
4.16 Comparison of steady-state distributions for different values of k.......... 75
xii


I. BACKGROUND
The Development of Evolutionary Theory
When Charles Darwin published On the Origin of Species in 1859, he began a revolution in how we think about biology and specifically in the mutability of species. Darwin wrote, “Owing to this struggle for life, any variation, however slight and from whatever cause proceeding, if it be in any degree profitable to an individual of any species, in its infinitely complex relations to other organic beings and to external nature, will tend to the preservation of that individual, and will generally be inherited by its offspring.” [1]
Philosophers and scientists of the past two millennia vigorously debated whether species can change over time and the means by which such a change could occur [25] [28]. The concept that species of organisms change over time had been suggested as far back as the Ancient Greek and Chinese[25][17], but it wasn’t until Charles Darwin in the 19th century that a consistent, coherent theory by which species evolve was introduced. Darwin states in the introduction to On the Origin of Species, “As many more individuals of each species are born than can possibly survive; and as, consequently, there is a frequently recurring struggle for existence, it follows that any being, if it vary however slightly in any manner profitable to itself, under the complex and sometimes varying conditions of life, will have a better chance of surviving, and thus be naturally selected. From the strong principle of inheritance, any selected variety will tend to propagate its new and modified form.”
Darwin posited in Origin that species evolve by means of natural selection. One definition of natural selection is “a natural process that results in the survival and reproductive success of individuals or groups best adjusted to their environment and that leads to the perpetuation of genetic qualities best suited to that particular environment.” [29] In other words, individual organisms that have better success
1


at surviving and reproducing are more likely to pass on their genetic information to the next generation.
A classic example of evolution by means of natural selection is the prevalence of dark-winged peppered moths during the Industrial Revolution in England during the 19th century. [7] Prior to the start of the Industrial Revolution, peppered moths had white wings with “peppered” black spots. No black-winged peppered moths were present in England prior to 1811. As air pollution, particularly coal soot, increased around the industrial centers of England, black-winged peppered moths were discovered. By the end of the 19th century, black-winged peppered moths dominated peppered-moth populations around cities such as Manchester. Scientists used Darwin’s theory of evolution by means of natural selection to argue that the black-winged peppered moths were more likely to survive than white-winged pepper moths since black-winged peppered moths were more camouflaged in the black, sooty environment. As air pollution subsided in the 20th century, white-winged peppered moths again dominated.
Herbert Spencer was the first to use the term “survival of the fittest” in his book, Principles of Biology in 1864 after reading Darwin’s Origin. Spencer stated, “This survival of the fittest, which I have here sought to express in mechanical terms, is that which Mr. Darwin has called ‘natural selection’, or the preservation of favored races in the struggle for life.” Many people understand the general idea of “survival of the fittest”, that is, organisms that are “fitter” or adapted to its environment are more likely to pass on their genes to the next generation compared to a “less fit” individual[20] [21], Unfortunately, the term “fitness” is vague and often open to debate. Many interpreted “survival of the fittest” to mean the organisms which individually had the characteristics best adapted to survival and reproduction. If an individual is a member of a group and groups of individuals make up an environment, could an individual’s group affect their “fitness”?
2


Modes of Selection and the Evolution of Cooperation
The means by which natural selection functions is debated still today. Natural selection can potentially take place on an individual level and/or on a group level. Individual selection is natural selection acting on an individual, that is, characteristics that benefit an organism on an individual level tend to evolve. Group selection is less easily defined. Okasha (2006) [13] defines group selection using the Price equation,
wAz = Cov(Wk, Zk) + E[Cov(wjk,zjk)\, (LI)
where w is the average fitness in the population, Az is the change in the fraction of cooperators in the population, Wk is the average fitness of the individuals in group k, Zk is the fraction of cooperators in group k, Wjk is the fitness of individual j in group k, and Zjk is zero or one depending on whether individual j in group k is a defector or cooperator. This definition of group selection has been criticized for a number of problems, one of which is that it only captures short-term changes[20][21][3][26][27]. On the other hand, Simon et al (2012) [20] defines group selection as follows: “If a trait establishes itself in a model of two-level population dynamics when group-level events are present, and does not establish itself in the same model when they are absent, then the trait evolves by group selection.” [20] While many initially interpreted Darwin’s theory of evolution by means of natural selection to apply specifically on the individual level (e.g., faster cheetahs are more likely to catch prey), Darwin suggested in 1871 in The Descent of Man that an individual’s group could impact an individual’s “fitness”. He stated, “There can be no doubt that a tribe including many members who, from possessing in high degree the spirit of patriotism, fidelity, obedience, courage, and sympathy, were always ready to aid one another, and to sacrifice themselves for the common good, would be victorious over most other tribes; and this would be natural selection.”
3


Of particular interest in the debate between individual and group selection is the evolution of cooperation. Individual selection helps explain why faster cheetahs are more likely to pass on their genes than slower cheetahs, but it is hard to explain the evolution of cooperation using individual selection alone. For example, social insects such as ants demonstrate cooperative behavior and many species of ants have only one female queen that reproduces for a colony of hundreds or even thousands of ants[30] [6]. If natural selection acts only on an individual level, why do so few female ants reproduce? Of all qualities that an organism could evolve, lack of reproductive ability does not seem likely but we see this in nature for a number of social organisms. Another example of cooperation in nature are honeybees that have evolved the behavior to sting hive invaders at the expense of its own life. How can we explain this kamikaze behavior of bees with respect to “survival of the fittest”? Why are there instances in nature where an individual potentially sacrifices its own fitness in favor of the individual’s group?
The conundrum of the evolution of cooperation and social behavior has perplexed biologists since Darwin wrote Origin. While some scientists suggested that natural selection took place on the individual and the group level, others rejected such an explanation. By the mid 20th century, prominent biologists such as George C. Williams and John Maynard Smith argued that natural selection only takes place on the level of the individual.[22] Others such W.D. Hamilton argued for kin selection, that is, individuals with “fit” relatives are more likely to pass on their genetic data than individuals without “fit” relatives. [5] While kin selection seems to potentially help explain the evolution of cooperation, not all biologists subscribe to this theory. One of the most vocal critics of kin selection and advocates of group selection today is renowned biologist E.O. Wilson. Wilson released the controversial book Sociobiology in 1975 which he discussed different modes of selection such as individual selection, kin selection, and group selection[30] and at the time argued that kin selection leads
4


to the evolution of altruism. In the early 1990’s, Eliot Sober and David Sloan Wilson argued for a multilevel selection model of natural selection, and in fact, there is currently a resurgence in thought that natural selection acts on an individual and group level.[22] By 2010, E.O. Wilson (along with Martin Nowak and Corina Tar-nita) penned the controversial article, “The evolution of eusociality”, which rejected kin selection in favor of group selection[ll] and multilevel selection models. Today, however, biologists remain split on the exact mechanisms of natural selection.
This dissertation will explore mathematical models for multilevel selection models where individual and group level events impact the population dynamics of organisms. These models illustrate how cooperative behavior could potentially evolve. The details of this multilevel selection model are outlined in the next chapter.
5


II. TWO-LEVEL POPULATION DYNAMICS MODEL
Population Models
When modeling populations of organisms with more than one type, standard models such as the Moran process make numerous assumptions that may not accurately model nature. Before introducing the two-level population dynamics model that will be utilized in the rest of this study, some of the drawbacks of standard population models will be briefly discussed.
The discrete-time Moran process was first introduced by Patrick Moran in 1958 to model finite populations. [9] A Moran process is a stochastic process with a fixed population size of N individuals of two types which will be called cooperators and defectors for convenience. The states of this Markov process are {0,1,..., N}, where state i indicates a population of i cooperators and N — i defectors.
A neutral Moran process has the following discrete-time transition probabilities from state i to state j [18].
>' = « + ! (IL1)
1 Pi,i— 1 Pi,i+1 3 *
These probabilities can be explained as follows. An individual is chosen at random to give birth and an individual is chosen at random to die. For a population of N individuals of which i are of type 1 and N — i are of type 2, the probability that a type 1 individual is chosen to give birth is P(type 1) = and the probability that a type 2 individual is chosen to die is P(type 2) = In other words, the probability of a transition from state i (i.e., i individual of type 1) to state j (i.e., j individuals of type 1) is given by Pitj = Similar reasoning can be used to calculate the
probability that a type 1 individual dies and a type 2 individual is born or the same
6


type of individual could be selected to be born and to die in which case the Markov chain stays in the same state.
For the neutral Moran process, at each time step an individual is chosen at random to give birth to an individual of the same type and an individual is chosen at random to die. The neutral Moran process is an appropriate model for the population dynamics of a fixed size population with two types of individuals with equal birth and death rates. We can first generalize this model to allow for individuals with different levels of “fitness”, where “fitter” individuals are more likely to give birth. Suppose i cooperators have fitness /* and i defectors have fitness g*. An asymmetric Moran process has the following transition probabilities from state i to state j, where i is the number of cooperators.
9i-(N—i) j
j = i ~ 1
P
11- j
fi-i
N-i
fi-i+9i-(N-i) N
j = i + 1
1 Pi,i— 1 Pi,i+1 j *
(II.2)
An asymmetric Moran process allows for a population of individuals of differing birth rates to be modeled, but it assumes a birth and death occur at each succeeding time instance. This asymmetric Moran process can be further generalized to allow for a variable amount of time in between birth/death occurrences. A continuous-time Moran process allows for variable time between events by modeling these times as exponential random variables. This will be discussed in depth in the next chapter. Unfortunately, the continuous-time Moran process, along with the other types of Moran processes aforementioned, assumes a fixed population size, so a death occurs every time a birth occurs. While the Moran process can be used to model populations, the assumption of a fixed population doesn’t seem reasonable for the population dynamics in nature. In particular, birth and death rates of individuals could depend on the size of an individual’s group which cannot be incorporated into the Moran
7


model. The Moran process will be explored more in the next chapter, but since it assumes a fixed population size, a more robust model is preferred. Note that all population models for the rest of this study will be in continuous-time and not discrete-time.
One-Level Population Dynamics Model
Since the Moran process makes assumptions that seem unlikely to hold in nature, a more general population dynamics model is introduced. In this model, individuals can give birth and can die (and births and deaths aren’t required to coincide like the Moran process). In addition, births can have mutations (i.e., cooperators sometimes give birth to defectors and vice versa). For simplicity, all models used in this paper will assume cooperators and defectors have equal death rates, but potentially differing birth rates.
Birth rates can be modeled in a variety of manners such as fixed and equal birth rates for cooperators and defectors, fixed and unequal birth rates for cooperators and defectors, or even time-varying birth rates depending on the state of the environment. One possibility for modeling birth rates is to apply Game Theory and consider cooperators and defectors “playing a game” that determines their respective birth rates)?]. Consider the general two-player, two-strategy game with payoff matrix,
P
c d
( R
V p)
(II.3)
where we call the strategies cooperate and defect. Birth rates for individuals in the group can be modeled as proportional to the expected payoff for a game against a random opponent from the group,
bc(x,y)
\ % + y
y
x + y
bd(x,y)
<• (T ■ —------h P ■
\ x + y
y
x + y
(11.4)
(11.5)
8


where ( is a scaling parameter, x is the number of cooperators, and y is the number of defectors in the group.
Different choices of R, S, T, and P will result in different types of games. For example, when S < P < R < T (e.g., R = 3, S = 0,T = 5, P = 1), the game is Prisoner’s Dilemma where defectors always have higher birth rate than cooperators. In a one-level population dynamics model with birth rates based on the payoff of a game of Prisoner’s Dilemma, cooperation is very unlikely to evolve since the birth rates of defectors is always greater than or equal to the birth rates of cooperators under the condition S < P < R < T.
Birth rates could also be modeled as the expected payoff in a public goods game. In a public goods game, cooperators offer a benefit to the group that results in all individuals having a higher expected payoff (i.e., birth rate) at a certain cost to the cooperator. Defectors don’t offer the benefit to the group while still benefiting from the cooperators’ contributions. For example, the per capita birth rates of cooperators and defectors in a group with x cooperators and y defectors can be calculated in the following manner, where &o,&i,&2 are model parameters.
bc = bo + h^-h (II.6)
x + y
bd = bQ + h^— (II.7)
x + y
In this scenario, defectors again always have a higher birth rate than cooperators, however, groups with lots of cooperators grow faster than groups with lots of defectors due to the benefits that cooperators provide. Even so, defectors are highly likely to thrive at the expense of cooperators for one-level population dynamics model and hence, cooperation is unlikely to evolve in such a scenario. If this one-level population model is extended to a two-level population model where individuals are organized into groups, the evolution of cooperation seems much more likely since group-level events can favor groups with a higher proportion of cooperators.
9


Two-Level Population Dynamics Model
Simon (2010) introduced a two-level population dynamics model, where individuals of k types are organized into groups[19]. In this model, individuals can give birth (possibly with mutations), can die, or can migrate to a different group. On a group level, groups of individuals can fission into two groups or can go extinct.
The state of a group is a vector, x, that specifies the number of individuals of each type, i.e., x = [x\ X2 ... Xk\ where ay is the number of individuals of type i. The state of the environment at time t is {0t{x) \ x G Z^}, the number of groups in the environment with group population x for each x G Z^.
The following notation will be used to label event rates throughout the rest of this study, where group i has x cooperators and y defectors.
Table 1.: Notation for various event rates
Symbol Event Event Type
bc{x,y) Birth rate of cooperators in group i1 Individual
Mx,y) Birth rate of defectors in group i1 Individual
dc(x,y) Death rate of cooperators in group i Individual
dd(x,y) Death rate of defectors in group i Individual
m(x, y) Migration rate from group i Individual
f(x,y) Fission rate for group i Group
e(x,y) Extinction rate for group i Group
1Birth mutations can also be introduced in the model.
10


Model Assumptions
As laid out in Simon (2010) [19], this model also makes the following assumptions:
1. The environment contains distinct groups of distinct individuals.
2. The migration of individuals from group to group (if any) is random (i.e. individuals act independently).
3. The population dynamics of the individuals within a group depends on its present state and (possibly) the present states of the other groups in the environment.
4. Groups occasionally fission into two or more pieces that become new groups on their own.
5. All groups eventually die (of extinction) if they do not fission first.
6. Group-level variables, such as fissioning rates, extinction rates, etc., are functions of the present states of the groups in the environment including the group in question.
Unlike the Moran process, this group-structured population dynamics model allows for group populations to vary through time. This population model can be studied by large-population asymptotics (i.e., a deterministic model), by simulation (i.e., a stochastic model), or by a hybrid model that includes deterministic and stochastic elements.
11


Model 1: Stochastic Simulation Model
The stochastic model is a Monte Carlo-based simulation using a complicated continuous-time Markov chain. This simulation can be completed using the Gillespie algorithm, where individual and group level events are modeled as exponential random variables. Exponential random variables have the memoryless property (i.e., P \t > T + t \ t > t\ = P [t > T) ) that makes simulation easy to implement in practice.
The Gillespie algorithm has four steps: (1) initializing, (2) random number generation, (3) updating, and (4) iterating. The simulation begins at time t = 0 and exponential random variables are generated based on event rates (births, deaths, migrations, group extinctions, group fissions) which are calculated based on the state of the environment (step 1). The minimum realized value of the exponential random variables determines the next event to occur (step 2), the time at which the next event occurs, and how the state of the environment changes. . Once the population of the environment and the time of the simulation are updated (step 3), the process is repeated beginning again with generating exponential random variables with the updated event rates (step 4).
To illustrate this simulation model, consider an environment that consists of one group with 15 cooperators and 15 defectors beginning at time t = 0 where the following events occur in succession.
12


Table 2.: Example events in a simulation
Time Event Event Type Environment
t = 0 Start of simulation One group: (15 coop., 15 def.)
t = 0.132 Cooperator birth Individual One group: (16,15)
t = 0.168 Defector death Individual One group: (16,14)
t = 0.203 Cooperator death Individual One group: (15,14)
t = 0.311 Group fission Group Two groups: (8,3), (7,11)
t = 0.314 Defector birth Individual Two groups: (8,4), (7,11)
t = 0.389 Group extinction Group One group: (7,11)
The stochastic model can be useful for analyzing quantities for which closed formulas don’t exist. Repeating simulations for the same starting conditions allows for unknown quantities to be studied statistically. For example, in chapter 3, the stochastic model will be used to study how long until an environment of cooperators and defectors eventually is homogeneous. Since these simulations are independent, we can easily calculate approximate confidence intervals for various parameters of interest such as what is the probability that defectors eventually rule the entire environment and on average, how long does it take to reach homogeneity. Visually viewing the population dynamics of a simulation can be more challenging to note overall shifts in the population, as the random nature of individual and group level events can obscure the overall drift.
Two limit models derived from the simulation model will also be explored. First, a deterministic PDE model will be developed by letting the size of groups and the number of groups approach infinity. This model will be useful for studying the overall evolution of group compositions as a function of time. Second, a hybrid model will be developed by letting group sizes approach infinity. In this hybrid model, group-level events are still random, so this model is useful for inspecting the overall evolution of
13


Group popJations at l-.l 32 (cooperator birth)
Group populations at 1-.168 (defector death)
2 46 8 10 12 14 16 18 0 0 2 4 6 8 10 12 14 16 18 2
Cooperators Cooperators
(a) t = 0.132 (b) t = 0.168
Group populations at t=.2Q3 (cooperator death) Group populations at t=.311 (fission)
&-&-© O-6-J 18 16 14 .... .0-d-4
1 10 0"
s 8 6 4 2 o
0 2 4 6 8 10 12 14 16 18 2 Cooperators °c 2 46 8 10 12 14 16 18 20 Co operators
(c) t = 0.203 (d) t = 0.311
Group populations at t- 314 (defector birth) Groip populations at 1= 389 (group extinction)
0&-* ... ©*i-t 18 16 14 12 .. 0-4-4
O' S 10 S A / /
8 /
6
V 4 ' / V
2
/
0 2 4 6 8 10 12 14 16 18 2 Cooperators °c 2 46 8 10 12 14 16 18 20 Cooperators
(e) t = 0.314 (f) t = 0.389
Figure 2.1: State of the environment at time t using the stochastic/simulation model
14


the environment as well as the effect of group-level events on the population dynamics of the environment.
Model 2: Deterministic PDE Model
A partial differential equation (PDE) limit model can be built from the stochastic model that enables one to derive group population trajectories [19] by letting group sizes approach infinity and the number of groups in the environment approach infinity. This is a large-population limit model that is justified by a limit theorem in Puhalskii and Simon (2018) [16], has real-valued populations of individuals and groups, and stochastic rate functions are analyzed to be deterministic rate functions. This deterministic process is governed by:
k
('T ) -\-
dt
d\i) + J2^^=g,(x)
i= 1
dxj
(II.8)
where
gt(x) = / QfXxjgvJxjdx - (eof(;r) - df.(x)
(IIV)
and
oti,t = bitt(x) - ditt{x) (II.10)
i.e., the difference in birth and death rates for individuals of type i at time t and rjet(x) is the fissioning probability density function for an T-group. The PDE given in (2.6) can be solved numerically by first truncating the entire state space into a fc-dimensional (hyper) rectangle [0,x1>max] x [0,x2>max\ x â– â– â–  [0,xk>max], where xitmax are selected so that there is small probability a group will attain more than xi>max individuals of type i. Time can also be discretized into steps of length At. As such, the state of the environment can be updated from time t, 9t, to time t + At, 6t+a*.
To illustrate this model, consider the following example with two types of individuals, cooperators and defectors. For this example, birth rates are based on the expected payoff from a public goods game, so within any given group, defectors have
15


(d) t = 9
(e) t = 12
(f) t = 20
Figure 2.2: State of the environment at time t using the deterministic/PDE model
a slightly higher birth rate and groups with lots of cooperators overall have higher birth rates than compared to group with lots of defectors. Birth mutations as well as group-level events such as fissions and extinctions are also present in this model. At t = 0, the environment consists of only groups of approximately 10 cooperators and 40 defectors. As t increases, the overall composition of the environment goes from defector-heavy groups to cooperator-heavy groups despite all groups eventually becoming defector-heavy in the absence of group-level events. By t = 20, groups are mostly cooperators with a small number of defectors. This example illustrates how an environment of majority defector groups can evolve to an environment of majority cooperator groups and hence illustrates one way cooperation could potentially evolve. This example will be studied more in depth in chapter 4.
This deterministic/PDE model is useful to understanding the general evolution of the compositions of the groups in the entire environment. In particular, the solution of the PDE can be viewed visually to see the gradual changing of the environment.
16


This is much harder to discern with the simulation model due to the random nature of births, deaths, and other events. Unfortunately, there are some artifacts of using the large population approximation that don’t seem to accurately model reality. In chapter 3, fixation time, the time until all groups in population of two or more types of individuals become homogeneous, will be studied in depth. The PDE model suggests a steady-state population of cooperators and defectors, however, since these simulations have absorbing states along the axes, i.e., groups with all defectors or all cooperators will stay all defectors or all cooperators in the absence of mutations, the environment will eventually hx with only one type of individual in each group. This inconsistency will be studied in chapter 3.
Model 3: Hybrid Model
The hybrid model was developed by Simon and Nielsen (2012) and is a compromise of the purely stochastic simulation model and of the purely deterministic PDE model[21] by letting the size of groups approach infinity. In this model, individual level events such as births, deaths, mutations, and migrations are all modeled as deterministic and group level events such as group fissions ans extinctions are modeled as stochastic. This compromise allows one to visually inspect the general drift of the population while allowing for the randomness of group-level events to impact the population in interesting ways.
The hybrid model works by dividing time into sufficiently small time steps, At, so that it is very unlikely for more than one group-level event to occur in any given time step. At the beginning of each time step, random variables are generated based on the group-level event rates. If one of these random variables is smaller than the time step At, then the environment is updated to reflect either the group fission or the group extinction. After updating the group populations as needed for any group-level events in the time step At, all populations are updated based on their respective birth and death rates. This updating is done based on numerically solving
17


an ordinary differential equation based on the current birth and death rates of the different populations. Suppose the current time is to, the time step of the model is At, and group i has ncd{t) and ndd{t,) cooperators and defectors, respectively. Populations are updated using Newton’s method as follows.
nc4(t,0 + At,) = nc4(t,0) + At, • (bc(t) - dc(t)) (H.ll)
nd,i(to + At,) = nd4(t,0) + At, • (bd(t) - dd(t)) (11.12)
As an example, the path of a single group using the hybrid model is displayed in figure 2.3. The group initially has a population of 35 cooperators and 10 defectors. Initially, there is an increase in cooperator and defector populations until there are approximately 50 cooperators and 25 defectors. At this point, the size of the group is sufficiently large that the death rate exceeds the birth rate of cooperators while the opposite is true for defectors. As a result, the number of defectors continues to increase while the number of cooperators decreases.
Group populations at t=50
Figure 2.3: Path of a single group using the hybrid model
The hybrid model is the preferred method for visualizing the evolution of a pop-
18


ulation for the two-level population dynamics model. It is not only more computationally efficient than the simulation model and the PDE model, it also allows for one to study the drift of the population while still seeing the effects of group level events. For this reason, the hybrid model will be used in chapter 4 to explore the population dynamics when more than two types of individuals make up the environment. As the number of types of individuals increases, simulation becomes difficult computationally with current technology. The computational efficiency of the hybrid model compared to the simulation model allows for modeling increasingly complicated population structures.
Motivation for Research Problems
Two topics involving evolutionary population dynamics were studied for this dissertation. In chapter 3, fixation times will be explored using the simulation model. In chapter 4, the hybrid model will be generalized to allow intermediate levels of cooperation rather than just pure cooperators and pure defectors.
Introduction to Fixation Times Research
Fixation time is defined here as the time until all groups in the environment are
homogeneous, that is, each group only has one type of individual. In section 2.2.3,
a solution for the PDE model is displayed in figure 2.2. Of particular interest is
that as time approaches infinity, there is a steady-state population of groups with
both cooperators and defectors when using the PDE model. If the simulation model
is used with the same parameters, the fixing of population is expected in a finite
amount of time. This is because all groups will eventually have all cooperators or all
defectors just by the random movements from the stochastic processes. If migrations
or mutations are sufficiently frequent, it is possible for some of these homogeneous
groups to become heterogeneous but typically these groups quickly fix again with
all cooperators or all defectors. Why does this matter? The PDE model suggests a
steady-state population of groups that are heterogeneous, that is, some of the groups
19


in steady-state will have a mixed population and the simulation model suggests the environment will fix with all homogeneous groups. Resolving this potential conflict is of interest in an attempt to understand these models more clearly. Prior to research, it was hypothesized that either the fixing of populations takes a “long time”, so in practice, the groups don’t fix for an extremely long time or that the difference between the PDE model and the simulation model results were merely an artifact of how the PDE limit model was formulated. It will be shown in chapter 3 that the later is true; groups fix with one type of individual within a simulation time of approximately 105 < t < 106, so the difference in the models is in fact an artifact of how the limit model was formulated.
Introduction to Multiple Levels of Cooperation Research
The evolutionary population dynamics models discussed in this chapter assume that there are only two types of individuals, cooperators and defectors. In chapter 4, this condition will be relaxed to allow for the population dynamics of N > 2 types of individuals to be modeled. In particular, a cooperation coefficient will be introduced where a pure defector has a cooperation coefficient of c\ = 0, a pure cooperator has a cooperation coefficient of cn = 1, and intermediate levels of cooperation (0 < q < 1) are also modeled. Of particular interest in this research topic is whether the overall population dynamics are similar when N > 2 or if completely different population dynamics result from more than two types of individuals. It is also of interest how the steady-state populations differ for different values of N and if increasing N speeds up or slows down the evolution of cooperation. Interestingly, two examples in chapter 4 will show that increasing the number of intermediate levels of cooperation may or may not lead to completely different steady-state populations. In fact, the introduction of multiple levels of cooperation can have interesting and unexpected results. The hybrid model was utilized for this research topic for computational speed and because the general drift of the population is easier to visualize with the hybrid model.
20


III. FIXATION TIMES IN GROUP-STRUCTURED POPULATIONS
Fixation Times for the Continuous-Time Moran Process
Consider a population of individuals, where each individual is either type A or
type B. A continuous-time Moran process has states {0,1,, N} where state i corresponds to i type A individuals and N — i type B individuals, i.e., there are always a total of N individuals. Type A and B individuals have fixed (possibly different) birth rates. Whenever an individual gives birth, its offspring is the same type, and at the same instant an individual chosen randomly from the original N dies, keeping the total population at N. Here we will assume (without loss of generality) that the per capita birth rate for type Aisl + s, s > — 1, and for type B is 1. To go from state i to i + 1 means there was a type A birth (rate z(l + s)) and the individual chosen to die was type B (probability ^k)- To go from state i to i — 1 means there was a type B birth (rate N — i) and the individual chosen to die was type A (probability j^).
The infinitesimal generator [14], Q, for the continuous-time Moran process therefore has
_ (l + s)*(A-«) (III.l)
_(N- i)i Wi,i-1 (III.2)
_ -i(N - i)(2 + s) N (III-3)
Qi,j o, j ^ {i — 1, i, * + 1} (III-4)
When i = 0 or i = N, we have Qitj = 0, 0 < j < N since they
are absorbing states. The rows and columns of the infinitesimal generator Q can be rearranged to be in the block form:
Q
Q P
0 0
(III.5)
In this form, the matrix Q is an N— 1 by N— 1 matrix representing the transitions
between transient states (i.e., i = 1,2,... N — 1), P represents the transitions between
21


transient and absorbing states. Let F be the time until fixation starting in state n/2, i.e., the time until absorption in either state ) or N. Let tq be a row vector with N — 1 zeros except for the ith entry which is equal to 1, and let 1 be a N — 1 column vector of At — 1 ones.
From theory [14], the following are obtained from the infinitesimal generator.
E[F\ = -utQ~l 1 (III.6)
E[F2] = 2uiQ~2l (III-T)
Var(F) = E[F2} - (.E[F])2 (ms)
The mean and variance of the fixation time of a continuous-time Moran process of size N can be calculated in this manner. In this Moran model, the time until a group is homogeneous is equal to the time until the population reaches one of the two absorbing states, namely i = 0 or i = N, and this will be defined as the fixation time. The probability the process reaches state N before state 0 (i.e., type A fixes) is limt^00[e'5t]i)jv, which can be found analytically[14],
Now, consider an environment that has K independent groups, each modeled as a Moran processes of N individuals and the intra-group dynamics are governed by continuous-time Moran processes starting from state i. The time until all K groups have reached one of the absorbing states, defined as F^K\ is the time until all groups are homogeneous.
F(k) = max{FuF2,...,FK} (III.9)
where Fj is the fixation time for the jth group. The expected value and variance of F^) can be calculated from (3.9) as follows.
22


P(FW < t) = P{max{F1,F2, ...,FK} (III.10) (III. 11) (III. 12)
Note that in principle, one can allow each group to start in a different state, but for our purposes here that added complexity is unnecessary. Prom (3.12), we have
= P(F1 t) = (1 - me&l K
E[F{k)} = / P{F{k) > t)dt
Jo
roc
= (1 - P(F^ < t)) dt
1 - (1 - UieQt 1
K
dt
(111.13)
(111.14)
(111.15)
and
Var[F^K)] = / 2tP(F^K) > t)dt - E[F^]2
Jo
K "I
21
> 0
1 - ( 1 - meQt 1
dt - E[F^f
(111.16)
(111.17)
Numerical integration using Simpson’s Rule will be used to evaluate these integrals for a variety of cases.
23


A Simple and Useful Heuristic Calculation
When the Moran process is in state i it can move to the states i — 1 or i + 1, but
if s > 0 then there is a “drift” in the positive direction. The drift rate is
j (N — j)
di = Qi,i+1 - Qi,i-1 = s 'y N (HI-18)
so the time it takes to get from state i to i + 1 should have a mean of about d~l. The expected time to get from state i to N (conditioned on the fact that A fixes) is
N-1 (III.19)
iVy,1 1 s ^ i(N — i) j=% (III.20)
1vV 1 s + N-i/ j=i (III.21)
1 fN~\l 1 w s Ji Kx N — x (III.22)
-(ln(A — 1) — ln(i) + ln(A — ?')) (III.23)
Note that = 21n(iV— l)/s and Tn/2^n = ln(A— l)/s, so given that a rare type
A mutant fixes, it will spend about half the fixation time getting half way to fixation.
(a) N = 10 (b) N = 100 (c) N = 1000
Figure 3.1: Expected time from state i to N for s = 0.01 using the simple heuristic
Note that this simple heuristic is not valid if s ~ 0 unless N is very big.
24


Neutral-Drift Moran Process
The neutral-drift continuous-time Moran process can be analyzed by setting s = 0. The expected value and variance of fixation times, starting in state were calculated analytically (via numerical integration) for 1 < N < 1000 individuals per group and 1 < K < 100 groups of individuals. The results are plotted below and were verified using simulation. As can be seen in Fig. 3.2, the mean fixation time of K groups grows linearly as a function of group size (N).
0
250
500
Group Size (N)
750
1000
K groups
5
10
50
♦ 100
Figure 3.2: Mean fixation times for K neutral-drift continuous-time Moran processes of size N
25


As can be seen in figure 3.3, the mean fixation time of groups of size N grows logarithmically as a function of the number of groups K. Let Xi be the fixation time for group i which is exponentially distributed. The logarithmic growth of mean fixation times as a function of the number of groups K can be justified as follows.
Xi ~ exp(X) (III.24)
Y = max{Xi,X2, • • • ,Xk} (III.25)
P{Y roc E[Y] = / (1 - e~xt)Kdt Jo (III.27)
Jo 1 - u (III.28)
,\K-l = A-1 / uldu Jo ~o (III.29)
K-l = A->y,1, t^ + 1 (III.30)
« A~lln(K) (III.31)
where u = 1 — e~xt, du = Ae~xtdt.
In summary, for a collection of K neutral-drift continuous-time Moran processes, each of size N, the fixation time starting in state y grows linearly as a function of N and logarithmically as a function of K.
26


2000-
0 12 3 4
log(K groups)
Group Size (N) 10
50
100
500
• 1000
Figure 3.3: Mean fixation times for K neutral-drift continuous-time Moran processes of size N
27


Moran Process with Selection
Now, we will consider the case s > 0, that is, the first type of individual has a competitive advantage over the second type of individual. Below are the mean and the variance of the fixation time for one group for a range of values for the asymmetry parameter, s.
0
250
500
Group Size (N)
750
1000
s
-• 0.001
-*â–  0.01 0 .1
Figure 3.4: Mean fixation time for one asymmetric continuous-time Moran process of size N
28


As seen in the neutral-drift examples (s = 0), the mean fixation grows linearly as a function of group size. In the asymmetric cases (s / 0), mean fixation times have a limit that that is logarithmic, as can be seen from equation (3.23).
0
250
500
Group Size (N)
750
1000
s
0
-• 0.001 -*■ 0.01 0 .1
Figure 3.5: Fixation time variance for one asymmetric continuous-time Moran process of size N
29


Fixation Times for Two-Level Population Dynamics Models
The Moran process allows one to study an idealized model of fixation. The strength of the Moran process lies in its simplicity which allows analytical results. But the simplicity is also a weakness. For example, the constant population size means that the Markov chain has a relatively small state space, but in order to keep the population constant we are forced to imagine that every birth is simultaneously accompanied by a death. This setup is insensitive to size dependent effects. In multigroup models, we would have to imagine that migration events would have to occur in such a way that there was never a net gain or loss in each group’s population. Differences in birth, death and migration rates due to varying group sizes cannot be studied in Moran-based models, and group-level events like fission cannot be studied since it changes the size of the affected groups. For these reasons we look for a more general model of group-structured populations.In Simon (2010), a dynamical population model was proposed that featured (uncoupled) births and deaths of individuals, group fissions, group extinctions, and migrations of individuals [?]. In this model, there are no artificial constraints on the number of groups in the population, nor on the number of individuals in each group. The individual-level and group-level event rates are state-dependent. For example, an individual’s birth rate is often determined by its expected payoff in a game (like Snowdrift) played with its group mates and/or the individual’s type. Since event rates are state dependent, it will be convenient to define an (x, y)-group to be a group with x type A (cooperators) and y type B (defectors).
Define bc(x,y) and bd(x,y) to be the per capita birth rates of cooperators and defectors in an (x, y)-group. Several examples will be studied for different choices of the birth rate functions. These examples include a baseline case where cooperators
30


and defectors have equal and fixed birth rates, a “weak selection” case where cooperators and defectors have fixed and non-equal but similar birth rates, two cases where the birth rates are a function of the individual’s payoff in a Public Good’s Game, and finally, a case where birth rates are a function of the individual’s payoff in a game of Snowdrift.
In addition to birth events in the model, there are also deaths, migrations, extinctions (group deaths), and fissions (group births). These rate functions will be fixed across the five examples in order to keep the scope of this study from growing uncontrollably.
We will assume that per capita death rates for cooperators and defectors depend only on the size of the group they reside in, i.e.,
dc(x,y) = dd(x,y) = 8 â–  (x+ y) (III.32)
We assume individuals migrate from their groups to another group at a per capita rate is constant, i.e.,
m(x,y) = y (III.33)
where y is the migration rate parameter.
Individual births, deaths, and migrations will be called individual-level events as defined in [20]. There are also group-level events which include group fissions (group births) and group extinctions (group deaths). To control the number of group level events, there will also be a scaling parameter, s. When s = 0, no group-level events occur. When s > 0, group fissions and group extinctions occur at rates proportional to s.
Define f(x, y) to be the fission rate of an (x, y)-group. 7 is a fission rate parameter and is set to 7 = 0.0001 in all our examples. We assume the fission rate is proportional to the group’s size,
f(x,y) = s-7- (x + y) (III.34)
31


Define e(x, y, n) to be the extinction rate for an (x, y)-group in a population with n groups. The extinction rate function is parameterized by ei, £2, £3 which are set to t\ = 0.1, £2 = 0.25, £3 = 0.15 in all our examples, n is the number of groups (not counting empty groups). The extinction rate has the form,
e(x, y,n) = s â–  â–  n â–  e-^-(x+y)+^-n (III.35)
This choice of extinction rate function will result in an increased likelihood of extinctions when the environment is crowded (n is large). Smaller groups are also more likely to go extinct. Additionally, these parameters typically result in approximately 40 groups with approximately 40 total individuals per group.
In the following examples, we will be examining the fixation times for different choices of birth rate functions, as well as different choices of the migration rate parameter, y, and the group-level event rate scaling parameter, s. In each case, the initial environment will be set to include 40 groups of 20 cooperators and 20 defectors and the fixation time will be the time until each group has only cooperators or only defectors.
Example 1: Neutral Selection
In this first case, the birth rate of cooperators and defectors are equal and state independent: bc(x,y) = bd(x,y) = 0.06. When group-level events and migrations are not present, the infinitesimal generator of this Markov process can be used to calculate the probability a single group fixes with all cooperators (or alternatively, all defectors) and the mean fixation time, E[F], for the initial state of 40 groups with 20 cooperators and 20 defectors. In this neutral selection setting, groups are equally likely to fix with all cooperators or all defectors and the expected fixation time for the environment of 40 groups, calculated using the infinitesimal generator, is E[F) « 1503.4. To confirm this value, 10,000 simulations were completed and a 95% confidence interval for mean fixation time was found to be 1501.3 < E[F] < 1517.5. Simulation was next
32


used to analyzed the effects of migrations and group level events on the fixation times.
In Fig. 3.6, simulated fixation times are plotted as a function of the group level event parameter, s, where no migrations take place (p. = 0). There is a downward trend in fixation time as the group level events parameter is increased and this occurs as extinctions become more common. As s is increased, fissions and extinctions are increased, and in this selection of parameters, the steady state environment is approximately 20 - 30 groups. As a result, more group level events typically results in fewer groups which in turn results in a smaller fixation time since fewer groups need to fix.
Figure 3.6: Simulated fixation times as a function of the group level events parameter, s, and no migrations, fi = 0
33


In Fig. 3.7, simulated fixation times are plotted as a function of the log migration rate parameter, log(p.), where no group level events occur. Since no group level events occur, the environment always includes the initial condition of 40 groups. An interesting relationship is seen between migration rates and fixation times. When migrations rates are low, there is little interaction between the groups.

Figure 3.7: Simulated fixation times as a function of the migration rate parameter, fj,, and no group level events, s = 0
In this example, about half of the groups fix with all cooperators and about
half of the groups fix will all defectors. As the migration rate increases, there is a
34


homogenizing effect on the groups, where groups tend to have similar compositions of cooperators and defectors. With an increase in migration, some groups initially fix with one type of individual, but then get a migrant of the opposite type and are no longer fixed. This causes fixation times to increase. When the migration rate is high enough, groups are all nearly identical and the environment consists of 40 groups slowly moving toward either all cooperators or all defectors. Since the composition of the groups is so similar, there appears to be a slight decrease in fixation time in comparison to a smaller migration rate.
Figure 3.8: Simulated fixation times as a function of the migration rate parameter, fj,, and group level events parameter, s (neutral selection)
35


Finally, in figure 3.8, simulated fixation times were analyzed as a function of the log migration rate parameter, log(yu), and the group level events parameter, s. This data was smoothed using third-order polynomial regression on the covariates. A somewhat more complicated relationship between the covariates and fixation time is noted. Estimated fixation times are lowest for a low rate of migration and a high rate of group level events. On the other hand, when group level events are low and migrations are relatively frequent, fixation times are at the highest. In addition, fixation times are highest under the choice of parameters that tend to favor all defector groups and are lowest under the choice of parameters that favor all cooperator groups.
Example 2: Weak Selection
In this second case, the birth rates of cooperators and defectors are state independent, but non-equal with a small difference in magnitude: bc(x,y) = 0.059, bd(x,y) = 0.06. With no migrations or group-level events, it was found that 42.2% of groups would fix with all cooperators and the mean fixation time for all groups would be E[F) ph 1488.8. In 10,000 simulations, 42.1% of groups fixed with all cooperators and a 95% confidence interval for the mean fixation time was 1481.7 < E[F] < 1497.9. Simulation was next used to determine the effects of migrations and group-level events on mean fixation times for this weak selection example.
Similar to the neutral selection example, mean fixation times tend to decrease with an increase in the number of group-level events. Since the steady state environment has fewer groups than the initial condition of 40 groups, group level events (specifically, extinctions) result in fewer groups and thus a quicker fixation time (3.9). A similar pattern in fixation times, compared to the neutral selection case, can be seen when group-level events are not present but migrations do occur (3.10). Overall, fixation times are smaller (3.11) for the weak selection example compared to neutral selection which is expected due to the asymmetry of the individual birth rates.
36


log fixation time
• (
• I
• I
1 2 group events parameter
Figure 3.9: Simulated fixation times as a function of the group level events parameter, s, and no migrations, fi = 0 (weak selection)
37


•
« • • « * • • • • • • * •
1 • / * • / t • • i • » • / « 1 * . * * * • • ► \ « * * \ • • \ • • •
: • . . i « » ^ i ‘ » 4 • * 1 1 . » • i • t ! • • •
• • •
-6 -5 -4 -3 -2
log migration rate
Figure 3.10: Simulated fixation times as a function of the migration rate parameter, fj,, and no group level events, s = 0 (weak selection)
38


Estimated Fixation Time
group events parameter
Figure 3.11: Simulated fixation times as a function of the group level events parameter, s, and migration rate parameter, p, (weak selection)
Example 3: Public Good’s Game #1
In the previous examples, per birth rates for cooperators and defectors were
constant (state independent). It is also possible to model state dependent birth
rates, e.g., as a function of payoff in a game played with other individuals in the
same group. For the following example, birth rates are based on the average payoff
for individuals in a Public Goods Game. Birth rates for cooperators and defectors
39


in a group are a function of the individual’s type (cooperator or defector) and the composition of the individual’s group. For group with x cooperators and y defectors, the per capita birth rate of a cooperator is as follows.
bc(x,y) = f3i+ f32^~-------/% (III.36)
x + y
and the per capita birth rate of a defector is
bd(x,y) = f3i+ f32^— (III.37)
x + y
In other words, there is a baseline birth rate of /% which is increased by /?2 times the fraction of the group that is cooperators. The difference between cooperators and defectors is that cooperators have to pay a cost, /?3, for cooperating, while defectors do not. For the following example, /% = 0.04, /% = 0.05, and /?3 = 0.005. Using the same set of initial conditions, as the previous examples, with 40 groups of 20 cooperators and 20 defectors, the initial birth rates of cooperators and defectors are 0.06 and 0.065 respectively. When group-level events and migrations are not present, the infinitesimal generator can be used to calculate the expected fixation time (E[F] ~ 1228.6) and the probability a group fixes with all cooperators (17.1%). These numbers were verified with 10,000 simulations that found a 95% confidence interval for mean fixation time to be 1218.8 < E[F] < 1231.4 and 17.1% of groups fixed with all cooperators.
When group level events are present (but not migrations) (3.12), higher rates of group-level events are associated with a decreased fixation time. When migrations are present (but not group-level events), fixation times increase with higher migration rates for log(y) < —3. When log(y) > —3, migrations become commonplace enough that groups being to all look similar. In the limit, all groups have equal composition of cooperators and defectors and there is a slight decrease in fixation time.
40


log fixation time
3.50-
3.25-
3.00-
2.75-
2.50-

• • • •
• • • • *.. *
• • • * • ^ . . * • ' * • . * • • • • • 1 • • L * m • • \ S • « 1 • # • < • • . • • • • ► t • • • • . • . • •. •
i ’ . • • • . ► t • ' • : .Vl • • Tm • * i «

0 12 3
group events parameter
Figure 3.12: Simulated fixation times as a function of the group level events parameter, s, and no migrations, fi = 0
41


-6
-5
-4
log migration rate
-3
-2
Figure 3.13: Simulated fixation times as a function of the migration rate parameter, fj,, and no group level events, s = 0
42


When migrations and group-level events are present (3.14), fixation times are highest when the migration rate is high and groups tend to fix with all defectors. When the migration rate is moderate and the group-level events parameter is high, fixation times are lowest and groups tend to fix with all cooperators.
Estimated Fixation Time
group events parameter
Figure 3.14: Simulated fixation times as a function of the group level events parameter, s, and migration rate parameter, p,
43


Example 4: Public Good’s Game ^2
Example ^4 uses the same parameters as example #3 except that (3% = 0.01 with all other parameters remaining the same. The increase in j3-z decreases the birth rates of cooperators but has no impact on the birth rates of defectors. The result of this change is that cooperators tend to be less likely to fix and for some choices of parameters this results in lower fixation times.
3.25- •
2.50-
0 12 3
group events parameter
Figure 3.15: Simulated fixation times as a function of the group level events parameter, s, and no migrations, fi = 0
44


-6
-5
-4
log migration rate
-3
-2
Figure 3.16: Simulated fixation times as a function of the migration rate parameter, fj,, and no group level events, s = 0
45


log migration rate
Estimated Fixation Time
group events parameter
Figure 3.17: Simulated fixation times as a function of the group level events parameter, s, and migration rate parameter, p,
46


Other Standard Games
There are choices of birth rate functions that result in fixation occurring much more quickly or much more slowly than for the examples considered above. Consider the general 2-player, 2-strategy game with payoff matrix,
P
c d
( R s^
V p)
(III.38)
where (for convenience) we call the strategies cooperate and defect. Birth rates for individuals in the group can be modeled as proportional to the expected payoff for a game against a random opponent from the group,
bd(x,y)
(â–  [R-
x
x + y
+ S-
y
x + y
bc(x,y)
<â–  T-
x
x + y
+ P-
y
x + y
(III.39)
(III.40)
where ( is a scaling parameter.
When R = 3,S = 1, T = 5,P = 0, the game is Prisoner’s Dilemma where defectors have a higher birth rate in every group. However, as is well known, if cooperative groups have an advantage over less-cooperative groups (e.g., a smaller extinction rate) then cooperation can thrive in the population.
If C = io an(I the same initial conditions are used as in the previous examples, then initially, bc(x,y) = 0.0375 and bd(x,y) = 0.075. The average per capita birth rate hence is 0.05625 which is approximately equal to the previous examples. 10,000
47


simulations were completed for this choice of game and parameters and a 95% confidence interval for the mean fixation time was calculated to be 274.4 < E[F] < 276.6 and 100% of the groups fixed with all cooperators. In this example, defectors have a significant birth rate advantage over cooperators and additionally, unlike the Public Goods Game examples, migrations and group-level events do not lead to a greater likelihood of groups fixing with all cooperators.
Now, suppose that R = 0, S = 2, T = 4, P = 3 and C = which is a game of Snowdrift. Initially, bc(x,y) = 0.0556 and bd(x,y) = 0.0694 with an average per capita birth rate of 0.0625. 10,000 simulations were completed for this example and it was found that a 95% confidence interval for mean fixation time was 5171.9 < E[F) < 5230.5 and 99.73% of groups fixed with all cooperators. When there is a 2:1 cooperator:defector ratio within a group, birth rates of cooperators and defectors are equal, so most groups have a mixed population in steady-state. Since these groups tend to have more cooperators, they are most likely to fix with all cooperators when they eventually hx.
If migration (y = 10-2) is introduced into the simulations, fixation takes a relatively very long time. In Fig. 3.18, the state of the environment is plotted at four different times. Each group is represented in the plot as a point at (x,y), denoting x cooperators and y defectors. Note that at t = 10000, it doesn’t appear fixation is any more imminent than when t = 100.
48


Time=10, Groups=40 • Number of Defectors Time=100, Groups-40 •!: •„ •. • • 1 . .1 v •• • V
0 10 20 30 40 50 60 70 80 90 100 "o Number of Cooperators 10 20 30 40 50 60 70 80 90 10 Number of Cooperators
(a) t = 10 (b) t = 100
Time=1000, Groups=40 100 90 Time=10000, Groups=40
80 70 § 60
D g 50
| 40 z
30 20 *••• *
â– o
.•* • . ••
10 20 30
50 60 70
90 100
90 100
Number of Cooperators
(c) t = 1000
(d) t = 10000
Figure 3.18: State of the environment for snowdrift example with migration


Conclusions
Studying fixation times of constrained population models such as the Moran process can give some insights into fixation times for unconstrained, more complex population models. In the case where an environment is modeled by N independent continuous-time Moran processes (each with total population K), fixation times grow linearly as a function of group size (K) and the number of groups (N). In addition, when birth rates are asymmetric, fixation times have a logarithmic limit in which fixation times decrease for higher levels of birth rate asymmetry.
Studying fixation times dynamic population models such as the one given in section 3 differs from the constrained models like the Moran process in that dynamic models have time-varying population sizes and time-varying number of groups. However, like the Moran process, fixation times in the dynamic population model are affected by the asymmetry of individual birth rates. When birth rates are fixed and equal (symmetric), mean fixation times are higher than when birth rates are fixed and non-equal.
Birth rates can also be modeled as the expected payout from a game such as Prisoner’s Dilemma or Snowdrift. In the case of Prisoner’s Dilemma, there is an asymmetry in birth rates, as defectors will always have a higher birth rate than cooperators in the same group. While this seems to make defectors favored over cooperators, groups with a higher proportion of cooperators have, overall, higher birth rates. As a result of this balance between defectors having the upper hand within any group and groups with a higher proportion of cooperators have a distinct advantage in higher birth, migrations and group-level events have a significant impact on fixation times. In the examples using Prisoner’s Dilemma that were presented, higher group-level event rates were associated in an increased likelihood that any given group fixed
50


with all cooperators. Migration tends to do the opposite in these models as higher migration rates tend to make groups more likely to fix with all defectors. Fixation times have a more complicated relationship with these variables.
Beyond Prisoner’s Dilemma, fixation is not even easily obtainable for cases where birth rates are based on a game such as Snowdrift where neither cooperator nor defectors are an evolutionary stable state.
51


IV. MULTIPLE LEVELS OF COOPERATION
Generalizing to More Than Two Types of Individuals
Up until this point of the study, results from the three models have been analyzed and discussed when there are two types of individuals. In this section, we will explore the effect of having more than two types of individuals and in particular, individuals will have a fixed cooperation level from 0% cooperation (pure defector) to 100% cooperation (pure cooperator). Several questions can be explored with this more generalized model. Do environments with two types of individuals (cooperators and defectors) have similar population dynamics compared to environments with many types of individuals (cooperators, defectors, and partial cooperator/defectors). Does adding additional level of intermediate cooperation change the steady-state group population distribution? Does multiple levels of cooperation lead to cooperation evolving more quickly or does it, in fact, hinder the evolution of cooperation?
The hybrid model will be used to explore these questions of multiple levels of cooperation for two reasons. First, increasing the number of types of individuals increases computations linearly and since the hybrid model is more computationally efficient than the simulation model, the hybrid model makes sense to complete these more computationally intensive calculations. Second, our main goal here is to study the overall effects of multiple levels of cooperation on the population dynamics, so since the hybrid solution better illustrates the overall drift of the population, it is again preferred to the simulation model for this application.
Computing Birth Rates when k > 2
While there are an infinite number of methods to model event rates when more than two types of individuals are present, we will use the concept of effective cooperators and effective defectors. Suppose our model has k types of individuals distributed evenly from 0% cooperation (pure defector) to 100% cooperation (pure cooperator).
Define the cooperation coefficient for type i to be q = ffj (i E {1,..., k}, c E [0,1]),
52


where a “type-1” individual is a pure defector (ci = 0), and a “type-fc” individual is a pure cooperator (Ck = 1). We define the number of effective cooperators, nec, and the number of effective defectors, ned, for a group with N individuals of k types with rii individuals of type i as follows.
k
nec = S^cini (IV. 1)
i= 1 k
ned = ^(1 - Ci)rii = N — nec (IV.2)
i= 1
k
Tied + nec = N = ^2rii (IV. 3)
i= 1
For example, suppose a group of 60 individuals consists of rq = 10 pure defectors (ci = 0), 77-1 = 20 half-defector/half-cooperators (c2 = 1/2), and n3 = 30 pure cooperators (c3 = 1). A quick calculation shows that this group has 20 effective defectors and 40 effective cooperators.
Using this setup, event rates can be calculated very similarly as before where nec and ned are substituted for nc and rid in the corresponding formulas for death rates, group extinction rates, and group fission rates. Linear interpolation can be used to find birth rates of individuals with cooperation coefficient q, i.e.,
bi = bd + Ci(bc - bd) (IV.4)
where bd is the birth rate of a defector and bc is the birth rate of a cooperator.
Computing the Mutation Matrix when k > 2
The only additional detail that needs to be addressed is how to model mutations. When modeling the population dynamics of an environment with two types of individuals, a mutation probability of n = 0.05 means that 5% births by cooperators are defectors and 5% of births by defectors are cooperators. The mutation matrix for two
53


types of individuals and a fixed mutation probability of /* = 0.05 is given as follows.
M
d c
^ 0.95 0.05 ^
^ 0.05 0.95 ^
(IV.5)
When there are more than two types of individuals (k > 2), we can still model 5% mutations but we must decide how to split that 5% between the other k — 1 individuals. Let M = [m^] be the mutation matrix, where
uiij = P(type j born | type i birth parent) (IV.6)
With a fixed mutation rate /i, mu = 1 — /i (i E {1,..., k — 1}) and YliZo mv = 1-The ehects of choosing diherent mutation probability mass functions will be explored later in this chapter, but first, some possible mutation probability mass functions will be introduced.
Mutation Matrix Method #1 (Gaussian):
The first method for computing the mutation matrix when k > 2 with a fixed mutation rate uses a Gaussian (normal) random variable probability density function. This method requires two parameters, the fixed mutation rate n and a mutation variance parameter a2. Let function of a normal random variable with mean q and variance a2 evaluated at x. The mutation matrix for this method can be computed as follows.
1 — n
i = 3
m.
v
. (IV.7)
For example, if k = 6, n = 0.5, and a2 = 0.1, then the entries corresponding to a type-* birth are plotted in figure 4.2 for i = 1,2,... ,6 and the corresponding mutation
54


1.00-
1.00-
0.75-£ 0.50-0.25-
0.00- I I # .
o!o o!2 o!4 o!6 o!s io
Ci
(a) i = 1
1.00-1 0.75-£ 0.50-0.25-0.00-
(d) i = 4
1.00-
0.75-£ 0.50-0.25-
o!o o!2 04 0.6 o!8 i!o
Ci
(b) i = 2

. . 1 1 l
o!o o!2 o!4 0.6 o!8 lo Ci (e) i = 5
0.75-
£ 0.50-
0.25-
o!o 0.2 o!4 o!6 o!8 i!o
C|
(c) i = 2
1.00-0.75-£ 0.50-0.25-
0.00- • • ^
o!o 0.2 o!4 o'.6 o'a i!o
Ci
(f) i = 6
Figure 4.1: Mutation Probabilities for i = 0,1,..., 5 (Mutation Method #1)
matrix M is presented in equation IV.8. Note p. = 0.5 was chosen for visualization purposes; typically, models were simulated with p, = 0.05.
0.500 0.276 0.152 0.056 0.014 0.002
0.179 0.500 0.179 0.098 0.036 0.009
0.083 0.152 0.500 0.152 0.083 0.031
0.031 0.083 0.152 0.500 0.152 0.083
0.009 0.036 0.098 0.179 0.500 0.179
0.002 0.014 0.056 0.152 0.276 0.500
(IV.8)
Mutation Matrix Method ^2 (Geometric):
The second method for generating a mutation matrix with a fixed mutation probability fi is similar to the first method except that a geometric random variable is used instead of a normal random variable with parameter p. Let
where x = 1, 2,..., k and p G (0,1). The mutation matrix using the second method
55


is computed as follows.
|1- - h * = 3
ma = i
1 lp(Cj,Ci,p) 6, n = 0.5, and p = 0.5, then
(IV.9)
to a type-?' birth are plotted in figure 4.2 for i = 1,2,..., 6 and the corresponding mutation matrix M is presented in equation IV. 12.
1.00- 1.00 1.00


0.00- lit. 0.00 I lit. 0.00 l I I T T
).o o 2 04 (16 (18 l!o Ci (a) i = 1 o!o 0.2 04 o!6 ol8 l!o Ci (b) i = 2 o!o 0.2 0 (c) 4 0.6 o!8 l!0 C| = 3



t r I l l 0.00- , T l I I 0.00- . t 1 1
o!o 0.2 04 o!6 ol8 l!o Ci (d) i = 4 )!o 0.2 04 o!6 ois i!o Ci (e) i = 5 10 0.2 04 0.6 o!8 C| (f) i = 6
Figure 4.2: Mutation Probabilities for ? = 0,1,..., 5 (Mutation Method #2)
0.500 0.258 0.129 0.065 0.032 0.016
0.258 0.500 0.258 0.129 0.065 0.032
0.129 0.258 0.500 0.258 0.129 0.065
0.065 0.129 0.258 0.500 0.258 0.129
0.032 0.065 0.129 0.258 0.500 0.258
0.016 0.032 0.065 0.129 0.258 0.500
(IV.10)
56


Mutation Matrix Method #3 (Uniform):
The third method for generating a mutation matrix with a fixed mutation probability fi is to make all mutations equally likely. Using this setup, the mutation matrix is calculated as follows.
m.ij
{f - n i = j
(IV.ll)
(a) i = f
(b) i = 2
(c) i = 3
(d) i = 4
(e) i = 5
(f) i = 6
Figure 4.3: Mutation Probabilities for i = 0,1,..., 5 (Mutation Method #3)
M =
0.5
O.f
O.f
O.f
O.f
O.f
O.f
0.5
O.f
O.f
O.f
O.f
O.f
O.f
0.5
O.f
O.f
O.f
O.f
O.f
O.f
0.5
O.f
O.f
O.f
O.f
O.f
O.f
0.5
O.f
O.f
O.f
O.f
O.f
O.f
0.5
(IV.12)
57


The choice of mutation method is up to the modeler and depending on the application, one method may be more appropriate than the others. In particular, the variance of mutation probability mass functions differ, so it must be determined how quickly the probability of mutations approach zero as \i — j\ increases.
Two examples will now be presented showing the effects of increasing the number of levels of cooperation. Note: hyperlinks to video solutions are available at end of each example section.
58


Example 1: Public Goods Game
We begin exploration of the effects of multiple levels of cooperation by exploring a model that uses the expected payout in a public goods game to determine per capita birth rates with birth mutation probability of n = 0.05.
bc = 0.04 + 0.05 • — 0.015 (IV.13)
77
bd = 0.04 + 0.05 • (IV.14)
Per capita death rates are modeled as proportional to the group size.
dc = dd = 0.0008 • N (IV. 15)
Note that total death rate for individuals of type i is an group is the per capita death rate multiplied by the number of individuals of type i. As a result, the total death rate in a group grows quadratically with group size.
In the example, group fission rates are proportional to the number of effective cooperators and the number of effective defectors, where an increase in the number of effective defectors results in a higher group fission rate than an equal increase in the number of effective cooperators.
fi = 0.0008 • nec + 0.0014 • ned (IV.16)
Group extinction rates are a function of the number of groups in the environment and group size.
e* = 0.02 • ng ■ e~0-2'N (IV. 17)
Using this setup, cooperators have a lower birth rate than defectors within the
same group, but groups with a larger proportion of cooperators have higher individual
birth rates overall compared to groups with a larger proportion of defectors. Groups
59


with a higher population of defectors are more likely to fission. Also, as the number of groups in the environment increases, there is an increase in group extinction rates and smaller groups are more likely to fission.
This model will first be analyzed when there are k = 2 types of individuals using the initial conditions of 50 groups consisting of 10 cooperators and 40 defectors with fi = 0.05 probability of mutation. These results will be compared to the results for when k > 2.
The PDE solution of this model, referenced in chapter 2, was first presented in Simon and Nielsen (2012) [21] and is shown in figure 4.4. It shows how an initial environment of predominantly defectors can slowly morph into an environment of predominantly cooperators.
(a) t = 0
(d) t = 9
(b) t = 5
(e) t = 12
(c) t = 7
t = 20
(f) t = 20
Figure 4.4: State of the environment at time t using the deterministic/PDE model
Before examining the results of the hybrid model, some statistics will be defined for the hybrid model that will be of interest to compare for different values of k.
Let c-i be the average group cooperation rate for group i with iii individuals of
60


type i, i.e.
N
Ci = ^2cini (IV. 18)
i= 1
Let C be the global average group cooperation rate, that is, the average percent cooperation level across all alive groups in the environment.
% = ]>> (IV.19)
i= 1
C can be estimated from a single hybrid simulation by running the simulation for long enough to assure the environment reaches “steady-state” and then taking the average of the global cooperation rate for the last 10% of the simulation.
Similarly, the average number of groups, ng in “steady-state” can be calculate by taking the average of the number of groups for the last 10% of the simulation. If the environment has ng(t) groups at time t and the simulation is over t E {0, At, 2At,..., tend}, then ng can be calculated as follows.
- _ te(o.9-tend,tend]
na sp 1
Z-^t£(0.9-tend,tend] 1
The global cooperation standard deviation can be estimated from the steady-state distribution at the end of the simulation, where 1% is the number of individuals of type i in the entire environment.
(IV.20)
CiNf- (
i=1 \i=l
The hybrid model was run for k = 2 types and mutation probability n = 0.05 with the initial conditions of 50 groups with 40 defectors and 10 cooperators which has an initial global group cooperation rate C = 20%. By t = 1000, the hybrid method has an approximate global group cooperation rate of 58.4%, a significant increase from the starting condition. Additionally, it was calculated that sc = 49.3% and ng = 604.6 groups. In figure 4.5, the state of the environment at t = 1000 is displayed as a scatter plot in (a) and as a heat map in (c). A histogram of the distribution of the
(IV.21)
61


two types of individual are plotted in (b) and the number of groups as a function of time is plotted in (d).
0 10 20 30 40 50 60 70 80 90 100
Number of Effective Cooperators
(a) State of the environment
0 50 100
Number of Effective Cooperators
(c) Heat map of state of the environment
Histogram of Individual Strateaies
% cooperation
(b) Histogram of individual types
Global Average Group Cooperation (Currently: 58%)
-o
Op i i I III I -
0 100 200 300 400 500 600 700 800 900 1000
Time
(d) Number of groups as a function of time
Figure 4.5: Hybrid model results for public goods game example at t = 1000 (k = 2)
Of particular note is that the hybrid simulation produces a steady-state population that is consistent with the PDE model. Both models show an environment that is initially dominated by defectors that slowly evolves to have a mixed population with a significantly higher proportion of cooperators.
The hybrid model was next run for k = 3, so the environment has pure defectors (ci = 0), half-cooperator/half-defectors (c2 = 1/2), and pure cooperators (03 = 1). Additionally, there was a fixed 5% mutation probability, where the mutation matrix was computed using the Gaussian method (a2 = 0.01). The results are plotted in
62


Time=1000
100
90
80
i= 70
:
§ 60 S
Number of Effective Cooperators
(a) State of the environment
0 50 100
Number of Effective Cooperators
(c) Heat, map of state of the environment
% cooperation
(b) Histogram of individual types
Global Average Group Cooperation (Currently: 49%)
90 -80
£
o ?n -
•o -
Oil i i i i i
0 100 200 300 400 500 600 700 800 900 1000
(d) Number of groups as a function of time
Figure 4.6: Hybrid model results for public goods game example at t = 1000 (k = 3)
??. With three types of individuals, the estimated global cooperation average rate C = 48.5% which is lower than C = 58.4% for k = 2. In steady-state, groups tend to have fewer effective cooperators when k = 3 compared to when k = 2. As will be seen, increasing k results in a lower average global group cooperation rate for this scenario.
The estimated global cooperation standard deviation for k = 3 is 38.5%, a decrease from 49.5% when k = 2, and the average number of groups at steady-state for k = 3 was estimated to be 603.1 for k = 3, a small decrease from an estimated 604.6 groups at steady-state when k = 2.
The hybrid model was also run for k = 5 (figure 4.7), k = 10 (figure 4.8), k = 100
63


(figure 4.7) and the results are summarized in table 3. In fact, as k increases, the global cooperation average decreases, the global cooperation standard deviation, and the average number of groups at steady-state decreases.
(a) State of the environment
0 50 100
(c) Heat map of state of the environment
Histogram of Individual Strategies
90
80
70
c 60
(b) Histogram of individual types
Global Average Group Cooperation (Currently: 32%)
90
80
E
S 70
7
a 50
a '10
-
-0
Of_______l______l_____________________l______l______l______l_______l_____=
0 100 200 300 400 500 600 700 800 900 1000
Time
(d) Number of groups as a function of time
Figure 4.7: Hybrid model results for public goods game example at t = 1000 (k = 5)
This phenomenon that cooperation is, in fact, hindered by increasing the number of levels of cooperation seems somewhat counterintuitive and requires explanation. When k = 2, global cooperation slowly increases as some majority defector groups fission into small majority cooperator groups by chance and these groups rapidly increase population until they approach peak capacity. Since the death rate increases quadratically with group size, there is a natural limit on how large groups can get. The speed at which the cooperators are able to reproduce in these groups exceeds
64


(a) State of the environment
0 50 100
Number of Effective Cooperators
(b) Histogram of individual types
Global Average Group Cooperation (Currently: 15%)
90
80
E
§ 70
Oil i i i i i
0 100 200 300 400 500 600 700 800 900 1000
(c) Heat map of state of the environment (d) Number of groups as a function of time
Figure 4.8: Hybrid model results for public goods game example at t = 1000 (k = 10)
Table 3.: Steady-state statistics (public goods game)
Number of Types (k) Global Coop. Average (C) Global Coop. Std. Dev. (sc) Average Number of Groups (ng)
2 58.4 49.3 604.6
3 48.5 38.5 603.1
5 31.7 27.5 335.1
10 15.1 13.3 181.1
100 7.2 7.4 156.7
65


(a) State of the environment
0 50 100
(c) Heat map of state of the environment
(b) Histogram of individual types
Global Average Group Cooperation (Currently: 7%)
90 -80
£
o 70 -
R
o 60-= 50 -
<5
| 40 -
75 30 0
20 t
•0 - ____________
Oil i i i i i
0 100 200 300 400 500 600 700 800 900 1000
(d) Number of groups as a function of time
Figure 4.9: Hybrid model results for public goods game example at t = 1000 (k = 100)
the rate at which defectors are able to. As these heavy cooperator groups approach peak capacity, the likelihood of a fission increases and when these majority cooperator groups fission, the newly formed groups also tend to be majority cooperator. When a group size reaches this peak capacity, defectors slowly thrive at the expense of cooperators. Barring a fission, the group will eventually again obtain a majority of defectors and the cycle will begin again.
The mutation matrix plays a critical role when k > 2. When k = 2, even though defectors have a higher birth rate than cooperators, since fi = 0.05, 5% of births by pure-defectors are pure-cooperators (and vice versa). When k is increased, the mutation method tends to result in mutations that are closer to the cooperation level
66


% cooperation % cooperation
(a) k = 2
(b) k = 3
Histogram of Individual Strategies
% cooperation
% cooperation
(c) k = 10
(d) k = 100
Figure 4.10: Comparison of steady-state distributions for different values of k
of the parent (i.e., mutants of pure-defectors still tend to have a lower cooperation coefficient), whereas when k = 2 a mutant birth of pure-defector is a pure-cooperator. As a result, when k increases, mutant births from defectors are typically still have a low cooperation coefficient resulting in less cooperation. This, in turn, means that few cooperator majority groups result from fissions and instead, group fissions that do result in some groups with intermediate levels of cooperation more quickly return to majority defector groups than if those groups had pure-cooperators.
In addition to the role that the mutation matrix plays in this interesting phenomenon, adding the intermediate levels of cooperation results in a lower global cooperation variance, so there is much less variability in group compositions than when
67


k = 2. In other words, increasing k has a homogenizing effect on group compositions, i.e., groups tend to have a similar number of each type of individual.
Links to supporting videos for example 1:
PDE solution: https://youtu.be/JwJY4RHjeHk Hybrid solution, k=2: https://youtu.be/BPBDZqilGCk Hybrid solution, k=3: https://youtu.be/5U6f_uvis9g Hybrid solution, k=5: https://youtu.be/HvlUVdo73v8 Hybrid solution, k=10: https://youtu.be/n5qmSU0hFUo Hybrid solution, k=100: https://youtu.be/LDHnRLDw5A0
Example 2: Snowdrift
As discussed in chapter 2, birth rates can also be modeled as proportional to the expected payout in a game. Consider a two-player, two-strategy game with the payout matrix, P.
P
c d
( R
V p)
(IV.22)
Birth rates for cooperators and defectors can be calculated from this payout matrix.
bc(x,y)
Mx,y)
C -(t-
X + S â–  y
x + y x + y
X + P- y
x + y x + y
(IV.23) (IV.24)
where ( is a scaling parameter, x is the number of cooperators, and y is the number of defectors.
When R = b — |, S = b — c, T = b, and P = 0, then the game is called snowdrift. The snowdrift game has an evolutionary stable state with cooperators and defectors, so we would expect a mixture distribution of cooperators and defectors at steady-state.
68


Let 6=2 and c = 1, so i? = 3/2, S' = 1 ,T = 2, P = 0 are the entries are of a payoff matrix corresponding to a game of snowdrift. These values will be used for the
following example along with scaling parameter C = Ts- Using these values, we get
the following birth rates for cooperators and defectors in a group with nec effective cooperators, ned effective defectors, and N = nec + ned total individuals.
7 _ 1 'IT'ec 1 'IT'ed,
c ~ 12 ' IV + 18 ' IV
, 1 nec
d ~ 9 ' N
(IV.25) (IV.26)
The probability of mutation is fixed to ^ = 0.05 and the per capita death rates are again modeled as proportional to group size albeit with a different death rate parameter, 5 = 0.0015.
dc = dd = 0.0015 • N (IV.27)
In the example, group fission rates are proportional to the number of effective cooperators and the number of effective defectors, but unlike example 1, cooperators and defectors equally contribute to the fission rate.
fi = 0.0001 • nec + 0.0001 • ned = 0.0001 • N (IV.28)
Group extinction rates are modeled exactly like the first example in this chapter as a function of the number of groups in the environment and group size.
e* = 0.02 • ng ■ e~0-2'N (IV.29)
Recall that the simulation method was run for this exact scenario in section 3.2.5 and had approximately a ratio of two cooperators for every one defector which equates to C = 67%.
The hybrid model was run for k = 2 with an initial condition of 50 groups with
20 pure defectors and 20 pure cooperators (figure 4.11). A couple of interesting
observations can be made. First, the environment quickly reaches steady-state by
69


Time=1000
45
40
g 35
§ 30
.1
0 i i i i i
0 5 10 15 20 25 30 35 40 45 50
Number of Effective Cooperators
(a) State of the environment
Number of Effective Cooperators
(c) Heat, map of state of the environment
Histogram of Individual Strategies
% cooperation
(b) Histogram of individual types
Global Average Group Cooperation (Currently: 63%)
90 -80
£
o ?n -
75 30
•o -
Oil i i i i i
0 100 200 300 400 500 600 700 800 900 1000
(d) Number of groups as a function of time
Figure 4.11: Hybrid model results for snowdrift example at t = 1000 (k = 2)
approximately t = 200 with a global group cooperation level of C = 63% which closely matches the simulation results found in chapter 3. Second, the steady-state distribution of group populations has very little variation, that is, most groups are concentrated around (nec,ned) = (30,18) which equates to a group cooperation rate of 63%.
After analyzing k = 2, the hybrid model was run for k = 3 (figure 4.16), k = 5 (figure 4.13), k = 10 (figure 4.14), and k = 100 (figure 4.15). For all these values of k and for large values of t, most groups again have a population of approximately (nec, neci) = (30,18). Once they fission, the two newly created groups quickly reach steady-state. Also, when k increases, C slightly increases toward 67% which was
70


approximately the average group cooperation in the simulation model analyzed in chapter 3.
Tjme=1000
45
â– 10
10
0I---------------------------------------1-------1-------1-------1-------1------1
0 5 10 15 20 25 30 35 40 45 50
Number of Effective Cooperators
(a) State of the environment
Number of Effective Cooperators
(c) Heat, map of state of the environment
Histogram of Individual Strategies
% cooperation
(b) Histogram of individual types
_________Global Average Group Cooperation (Currently: 63%)__
90
80
§ 70
I
-n
0 _______i_______i______________________i_______i______i_______i_______i______:
0 100 200 300 400 500 600 700 800 900 1000
Time
(d) Number of groups as a function of time
Figure 4.12: Hybrid model results for snowdrift example at t = 1000 (k = 3)
So why does this example have a very concentrated steady-state group population while the previous example with the public goods game had a varied steady-state population distribution with small values of k? It turns out that there is stronger “selection” in this second example in that the differential birth rate of defectors and cooperators is stronger for the second example as compared to the first example.
As a numerical example, suppose there is a group with 10 effective cooperators and 30 effective defectors. For the first example involving the public goods game, the
71


Time=1000
45
40
g 35
§ 30
.1
'0
0 I I I I I
0 5 10 15 20 25 30 35 40 45 50
Number of Effective Cooperators
Histogram of Individual Strategies
% cooperation
(a) State of the environment
(b) Histogram of individual types
(c) Heat map of state of the environment (d) Number of groups as a function of time
Figure 4.13: Hybrid model results for snowdrift example at t = 1000 (k = 5)
per capita birth rates for pure cooperators and pure defectors are given.
71 10
bc = b0 + h • - b2 = 0.04 + 0.05 • — - 0.015 = 0.0375 (IV.30)
77 20
bd = b0 + h • - &2 = 0.04 + 0.05 • ^ = 0.0525 (IV.31)
For the public goods game example, defectors always have a slightly higher birth rate than defectors (bd — bc = 0.015) and for a group of 20 pure cooperators and 20 pure defectors, bc = 0.05 and bd = 0.065. On the other hand, for the snowdrift example, the per capita birth rates for pure cooperators and pure defectors differ more significantly.
1 ^ec J_ ned _ J_ 10 1 30
c - 12 ' N + 18 ' N ~ 12 ' 40 + 18 ' 40
0.0625
(IV.32) 72


Time=5000
45
40
g 35
§ 30
.1
'0
0 I I I I I
0 5 10 15 20 25 30 35 40 45 50
Number of Effective Cooperators
Histogram of Individual Strategies
(a) State of the environment
(b) Histogram of individual types
(c) Heat map of state of the environment (d) Number of groups as a function of time
Figure 4.14: Hybrid model results for snowdrift example at t = 5000 (k = 10)
bd=l~ = 0.0278 (IV.33)
6 40
For the snowdrift example, groups that don’t have a composition close to the steady-state mean of (nec,ned) = (30,18) will have larger differential birth rate between cooperators and defectors that will cause these groups to quickly reach stead-state. In the public goods game example, the differential birth rate is much lower for most choices of (nec,ned), so groups don’t converge towards steady-state as quickly.
Using the expected payouts from a game of snowdrift is interesting because it has an internal evolutionary stable state, that is, at steady-state there will be pure cooperators and pure defectors for k = 2. What this study shows is that when k is increased, there is very similar steady-state population distribution in terms of effective
73


45
40
g 35
§ 30
.1
'0
0 I I I I I
0 5 10 15 20 25 30 35 40 45 50
Number of Effective Cooperators
(a) State of the environment
Number of Effective Cooperators
(c) Heat, map of state of the environment
Histogram of Individual Strategies
(b) Histogram of individual types
0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000
(d) Number of groups as a function of time
Figure 4.15: Hybrid model results for snowdrift example at t = 5000 (k = 100)
Table 4.: Steady-state statistics (snowdrift)
Number of Types (k) Global Coop. Average (C) Global Coop. Std. Dev. (sc) Average Number of Groups (ng)
2 62.8 48.3 183.0
3 63.4 39.1 136.3
5 64.9 33.2 114.3
10 66.0 28.6 173.9
100 66.0 25.8 63.7
74


cooperators and effective defectors but the majority of individuals at steady-state are neither pure-cooperators nor pure-defectors.
% cooperation % cooperation
(a) k = 2 (b) k = 3
(c) k = 10
(d) k = 100
Figure 4.16: Comparison of steady-state distributions for different values of k
Links to supporting videos for example 2:
Hybrid solution, k=2: https://youtu.be/VnrPjcJwStI Hybrid solution, k=3: https://youtu.be/q_3zYArUjOU Hybrid solution, k=5: https://youtu.be/noc5RxaiwlMx Hybrid solution, k=10: https://youtu.be/meF07qrk74w Hybrid solution, k=100: https://youtu.be/mC-lU0tq8V8
75


Conclusions
Multiple levels of cooperation can affect the overall dynamics in many interesting ways. As was seen in the first example using the public good’s game, while cooperators were in the majority as time approached infinity when k = 2 types of individuals, defectors tended to be in the majority when intermediate levels of cooperation (k > 2) were introduced. For this example, multiple levels of cooperation seems to inhibit the evolution of cooperation though cooperators do still exist as time approaches infinity. On the other hand, the example involving the snowdrift game had an approximately 2:1 cooperator:defector ratio when k = 2 and when k is increased, the global average group cooperation percentage does not change much. Taken together, these examples show that the average rate of cooperation for groups can potentially differ significantly if k is increased as in the first example or the average rate of cooperation for groups could stay approximately equal if k is increased as in the second example.
76


V. FUTURE WORK
This dissertation explored two specific topics in two-level evolutionary population dynamics, fixation times and multiple levels of cooperation. There are numbers of topics that can be researched to both extend the results presented here, as well as topics related to evolutionary population dynamics not discussed in this study.
The most obvious extension of the research outlined in this paper is to extend the PDE model and stochastic model to allow for more than k = 2 types of individuals. First, the PDE model with k > 2 could be studied to see if there are any unique qualities that don’t show up in the hybrid or simulation model. For instance, does the PDE model predict a similar steady-state distribution as the hybrid model? Does this extended PDE model again to fail to predict eventual fixing of the population like the k = 2 case? This certainly seems likely. Second, a generalized simulation model for k > 2 could be used to estimate fixation times (like chapter 3) and maybe more interestingly, the types of individuals that groups eventually fix with could be studied. In the snowdrift example in chapter 4 with k = 100, pure-cooperators are the most common type of individual with near pure-cooperators (q ~ 1) being the next most common. When groups eventually hx with only one type of individual, do these groups tend to hx with all pure cooperators? This seems like the most likely outcome, but further research needs to be completed to verify this. It could also be studied how the steady-state distribution differs for when the intermediate levels of cooperation are not evenly distributed between pure defector ( Outside of fixation times and multiple levels of cooperation, there are many tangentially related topics that could be investigated. How do choices of R, S, T, P for a payoff matrix affect the overall population dynamics when birth rates are modeled as proportional to a game’s expected payout. Under what choices of these variables is cooperation most likely and least likely to evolve? Finally, the ultimate goal of these models could be to estimate actual population dynamics in nature. This would require estimating all of the various event parameters and determining what game would be most appropriate to model birth rates observed in nature.
77


REFERENCES
[1] C. Darwin, 1859. On The Origin of the Species, Harvard University Press, Cambridge.
[2] Darwin, C., 1871. The Descent of Man. Murray, London.
[3] Frank, S., 1995. “George Price’s Contributions to Evolutionary Genetics”, Journal of Theoretical Biology, 175: 373-388.
[4] Gillespie, D., 1977. “Exact Stochastic Simulation of Coupled Chemical Reactions”, The Journal of Physical Chemistry, 25:2340-2361.8.
[5] Hamilton, W.D., 1964. “The genetical evolution of social behaviour”, Journal of Theoretical Biology. 7.
[6] Keller, L., Gordon, E., 2010. The Lives of Ants, Oxford University Press, Oxford, England.
[7] Majerus, M., 2008. “Industrial Melanism in the Peppered Moth, Biston be-tularia: An Excellent Teaching Example of Darwinian Evolution in Action”, Evolution: Education and Outreach. 2:107.
[8] McCLEAN, M., 2014. “Data density plot,” https://www.mathworks.com/ matlabcentral/fileexchange/31726-data-density-plot.
[9] Moran, P., 1958. “Random processes in genetics”, Mathematical Proceedings of the Cambridge Philosophical Society. 54.
[10] Moreland, K., 2018. “Diverging Color Maps for Scientific Visualization,” http://www.kennethmoreland.com/color-maps/.
[11] Nowak, M., Tarnita, Wilson, E., 2010. “The evolution of eusociality”, Nature, 466:1057-1062.
[12] Nowak, M., 2006. Evolutionary Dynamics. Harvard Press, Boston.
[13] Okasha, S., 2009. “Evolutions and the Levels of Selection”. Oxford University Press, London.
[14] Oksendal, B., 2003. Stochastic Differential Equations: An Introduction vnth Applications. Springer, Berlin.
[15] Puhalskii, A., Simon, B., 2011. “Discrete evolutionary birth-death processes and their large population limits”, Stochastic Models, 28.
78


[16] Puhalskii, A., Simon, B., 2018. “A large-population limit for a Markovian model of group-structured populations”. (Unpublished manuscript currently in submission).
[17] Ronan, C., 1995. The Shorter Science and Civilisation in China: An Abridgement. Cambridge University Press, New York.
[18] ROSS, S., 2010. Introduction to Probability Models. Elsevier, San Diego, CA.
[19] Simon, B., 2010. “A Dynamical Model of Two-Level Selection”, Evolutionary Ecology Research. 12:555-588.
[20] Simon, B., Fletcher, J., Doebeli, M., 2012. “Towards a General Theory of Group Selection”, Evolution. 67:1561-1572.
[21] Simon, B., Nielsen A., 2012. “Numerical solutions and animations of group selection dynamics”, Evolutionary Ecology Research. 14:757-768.
[22] Sober, E., Wilson, D.S., 1998. Unto Others. Harvard University Press, Cambridge, MA.
[23] Spencer, H., 1864. Principles of Biology. William and Norgate, London.
[24] TAYLOR, C., IWASA, Y., NOWAK, M., 2006. “A symmetry of fixation times in evolutionary dynamics”, Journal of Theoretical Biology. 243(2): 245-251.
[25] Torrey, H., Felin, F., 1937. “Was Aristotle an Evolutionist?”, The Quarterly Review of Biology, 12:1-18.
[26] VAN Veelen, M., 2005. “On the use of the Price Equation”, Journal of Theoretical Biology, 237: 412-426.
[27] van Veelen, M., Garca, J., Sabelis, M., Egas, M.. “Group selection and inclusive htness are not equivalent; the Price equation vs. models and statistics”, Journal of Theoretical Biology, 299: 64-80.
[28] Waggoner, B., 2000. “Carl Linnaeus (1707-1778)”, Evolution (online exhibit). University of California Museum of Paleontology, Berkeley, CA.
[29] Webster, D., 2004. The Merriarn-Webster dictionary, Pocket Books, United States.
[30] Wilson, E., 1975. Sociobiology: The New Synthesis. Harvard University Press, Cambridge, MA.
[31] Wu, B., Altrock, P., Wang, L., Traulsen, A., 2010. “Universality of Weak Selection’, Phys. Rev. E. 82.
[32] Wynne-Edwards, V., 1962. “Animal Dispersion in Relation to Social Behaviour”. Oliver & Boyd, London.
79


APPENDIX A
MATLAB CODE
Author’s note: MATLAB was primarily used in this study for generating data, running simulations, computing analytical results, and creating movies for examples.
File name Page File name Page
calc_approx_fix.m 81 moran_partial.m 131
calc_multiple_moran_fix_time.m 88 moran_selection.m 134
calc_single_moran_fix_time.m 92 MoranFixDist.m 136
dataDensity.m 94 plot_determ_path.m 139
DataDensityPlot.m 96 plot_dynamics_ipd.m 142
gen_brates_payoff_matrix.m 99 plot_dynamics_pgg.m 145
gen_hybr i d_ s ims.m 101 plot_hybrid.m 151
gen_trans_matrix_simon.m 102 sim_moran.m 160
gen_moran_inf.m 106 sim_pgg_calc_approx_f ix.m 162
gen_payoff_matrix.m 107 sim_simon_small_payoff.m 178
hybrid_dist.m 111 sim_simon_small.m 182
hybr i d_updat ed.m 113 simondist.m 186
moran neutral.m 130
80


% File: calc_approx_fix.m
% function to run multiple simulations to calc fixation times.
out_file = strcat(datestr(datetime('todaycsv'); fid = fopen(out_file,’w’);
n_sims = 5;
fix_times = zeros(n_sims,1);
% param,birth_option = 1; % PGG
param.birth_option = 2; % game based on payoff matrix
param.payoff = [02; 1 3/2]/18; % snowdrift
%param.payoff = [1 5; 0 3]/40; % prisoner's dilemma
param.max_groups = 200;
param.initial_groups = 40; param.initial_size = 40; param.initial_sd = 0; param.n_types = 2; param.mutant = 0;
param.bl = 0.04;


param.b2 = 0.05;
% originally b3 = 0.004 — adjusting this to 0.008
% third run is with 0.001 , now 0.005
param.b3 = 0.005;
param.dl = 0.0015;
param.fl = 0.0001;
param.ml = 0.00001;
%param.el = 0.2; param.el = 0.1; param.e2 = 0.25; param.e3 = 0.015; param.s = 1;
param.c = 0.05;
repeat_flag = 1;
%ml = 0:0.0001:0.001;
%ml = -6:0.25:-2; ml = -2;
n_ml = length(ml);
%s = 0:0.1:3;
param.group_events = 1;
n_s = length(s);
fix_times = zeros(n_ml,n_s);
output = zeros(n_ml*n_s*n_sims,6);


fprintf(fid,'s,ml,fixtype,fixtime,ngroups,ndefectgroups\n’); count = 1;
fprintf('Simulation:\n',count); for k = 1 : n_sims
for i = 1 : length(ml)
if ml(i) = = 0
param.ml = 0; else
param.ml = 10~(ml(i));
end
for j = 1 : length(s)
param.s = s(j);
%param.s = s (j);
% pa ram bl = 0.2 * rand;
% pa ram b2 = 0.2 * rand;
% pa ram b3 = 0.02 * rand;
% pa ram dl = 0.01 * rand;
% pa ram fl = 0.001 * rand;
% pa ram el = 0.5 * rand;
% pa ram e2 = rand;
% pa ram e3 = 0.5 * rand;
% pa ram mutant = 0.05 * rand;


85
90
95
100
105
% param.ml = 10* (—6) ;
% param.s = i * 0.1;
% if i < 43
% param.s = 0.5 * mod (1 — 1, 7) ;
% param.ml = 10* (—0.5 * mod (i — 1, 6)—3.5) ;
% else
% param.s = 3 * rand;
% param.ml = 10* (—6*rand) ;
% end
% switch 1 % case 1
% param.ml = 10* (—rand—4);
% param.s = 2*rand+l;
% case 2
% param.ml = 10* (—rand—4);
% param.s = 2*rand+l;
% case 3
% param.ml = 10* (—rand—4);
% param.s = 2*rand+l;
% case 4
% param.ml = 10* (—rand*2—3) ;
% param.s = 2*rand+l;
% otherwise
% param.ml = round(10*(—2*rand—2)*100000) /100000; % param.s = round (100000* (rand*2+l)) /100000;
84


end
no
115
120
125
130
Q,
O
%fprintf
^ r-----------------------------------------------------
â– -> n') ; fprintf(...
’°/0d (logm = s = t = count,ml(i),s(j));
[ out ] = sim_pgg_calc_approx_fix( param ); fix_times(count) = out.fixation_time;
fprintf (,0/01 • If, °/ol • If°/o°/o defectors) \n' , out. f ixation_time, . . . 100*out.n_defect_groups/out,n_alive_groups);
if isempty(out.fixation_type) out.fixation_type = -1; end
output(count,:) = [ param.s, param.ml, ... out.fixation_time, out.fixation_type, ... out.n_alive_groups, out,n_defect_groups];
% fprintf (fid, ' %1.5f, ', param. hi) ;
% fprintf (fid, ' %1.5f, ', param. b2) ;
% fprintf (fid, ' %1.5f, ', param. b3) ;
% fprintf (fid, ' %1.5f, ', param. dl) ;
% fprintf (fid, ' %1.5f, ', param. fl) ;
% fprintf (fid, ' %1.5f, ', param. el) ;
85


135
140
145
150
155
% fprintf (fid, ' %1.5f, ', param. e2) ;
% fprintf (fid, ' %1.5f, ', param. e3) ; fprintf (fid, ,0/01. 5f, ’ , param. s) ;
% fprintf (fid, ' %1.5f, ', param .mutant) ; fprintf (fid, ,0/01. lOf , ' , param. ml) ; fprintf (fid, ,0/od, ' ,out .f ixation_type) ; fprintf(fid,'%1.5f,',out.fixation_time); fprintf (fid, ,0/01.5f , ' , out ,n_alive_groups) ; fprintf (fid, ,0/01.5f \n' , out. n_def ect_groups) ;
% fprintf ('— — — — — — — — — — — — — — — — — — \n‘ % fprintf('Fixation time: %5.1f\n', out.fixation_time) % fprintf('Fixation type: %d\n', out.fixation_type);
% fprintf ('--------------------------------------------
count = count + 1; end end
end
fix_times
mean(fix_times)
%var(fix_times) hist(fix_times)
);
\n \n \n
86


160
%end
87


% File: calc_multiple_moran_fix_times.m
% function to estimate fixation times for multiple cont. time % moran processes
function [ out ] = calc_multiple_moran_fix_time(sizes,num_groups)
n = length(sizes);
ET = zeros(n,1);
VarT = zeros(n,l);
ETk = zeros(n,1);
VarTk = zeros(n,l); s=0;
n_int = 100;
fid = fopen('analytical_out.csv','w'); tic
fprintfC’s = %1.3f, calculating for n=\n',s); out = [ ];
for j = 1 : length(sizes) N = sizes(j);


Full Text

PAGE 1

STATISTICALANALYSISOFSOMEPROBLEMSINEVOLUTIONARY POPULATIONDYNAMICS by AAROND.NIELSEN B.S.ColoradoStateUniversity,2007 B.S.ColoradoStateUniversity,2007 M.S.UniversityofColoradoBoulder,2008 M.S.UniversityofColoradoDenver,2012 M.S.ColoradoStateUniversity,2014 Athesissubmittedtothe FacultyoftheGraduateSchoolofthe UniversityofColoradoinpartialfulllment oftherequirementsforthedegreeof DoctorofPhilosophy AppliedMathematics 2018

PAGE 2

ThisthesisfortheDoctorofPhilosophydegreeby AaronD.Nielsen hasbeenapprovedforthe AppliedMathematicsProgram by StephanieSantorico,Chair BurtonSimon,Advisor AudreyHendricks LorenCobb MichaelDoebeli Date:July28,2018 ii

PAGE 3

Nielsen,AaronD.Ph.D.,AppliedMathematics StatisticalAnalysisofSomeProblemsinEvolutionaryPopulationDynamics ThesisdirectedbyAssociateProfessorBurtonSimon ABSTRACT SinceCharlesDarwinrstpublished OntheOriginofSpecies in1859,scientists, philosophers,andmathematicianshavebeendiscussingthemechanismsofhowevolutionworksinnature.Naturalselection,theprocessbywhichindividualsthatare betteradaptedtotheirenvironmenttendtoleavemoreospringthantheircohort,is hotlydebatedontheparticularmediumsonwhichitfunctions.Unfortunately,many ofthesemodelsfailtoexplaintheevolutionofcooperation.Howisitpossibleforan individualthatprovidesabenettoitspeersatitsownexpenseabletothriveina worldofsurvivalofthettest"? Overthepastcoupleofdecades,therehasbeenarenewedinterestintotwo-level populationdynamicsmodelswhichareonewaytomodelevolutionarypopulation dynamics.Inthesemodels,eventsoccurringontheindividuallevelbirthsand deathsofindividualsandeventsoccurringonthegrouplevelssionsandextinctions ofgroupsofindividualsaecttheoverallpopulationdynamicsoftheenvironment. Thisdissertationwillexaminethebehaviorandpropertiesofevolutionarypopulation dynamicsusingthreerelatedmodels:astochasticmodel,adeterministicmodel,and ahybridmodel.Twoimportantproblemsfromtheeldofevolutionarypopulation dynamicswillbediscussed.First,thestochasticmodelwillbeusedtostudyxation times,thetimeuntilapopulationonlyhasonetypeofindividual.Theseresultsare contrastedwithanalogousresultsusingthedeterministicmodelwhichseemtosuggest noxingofpopulations.Second,thehybridmodelisextendedtosimulatemultiple levelsofcooperation.Theresultsfromsimulationswithtwotypesofindividualswill becontrastedwithsimulationsofthreeormoretypesofindividualsandasymptotic resultswillbediscussed.Ofparticularinterestishowmultiplelevelsofcooperation iii

PAGE 4

canaecttheoverallpopulationdynamicsoftheenvironment. Theformandcontentofthisabstractareapproved.Irecommenditspublication. Approved:BurtonSimon iv

PAGE 5

DEDICATION Thisdissertationisdedicatedtomyfamily,theNielsensandtheMeyers. v

PAGE 6

ACKNOWLEDGMENTS Aspecialthankstomydissertationcommitteemembers,BurtSimon,Stephanie Santorico,AudreyHendricks,LorenCobb,andMichaelDoebeli,fortheirfeedback andsupport. vi

PAGE 7

TABLEOFCONTENTS CHAPTER I.BACKGROUND................................1 TheDevelopmentofEvolutionaryTheory...............1 ModesofSelectionandtheEvolutionofCooperation........3 II.TWO-LEVELPOPULATIONDYNAMICSMODEL............6 PopulationModels............................6 One-LevelPopulationDynamicsModel................8 Two-LevelPopulationDynamicsModel................10 ModelAssumptions.......................11 Model1:StochasticSimulationModel.............12 Model2:DeterministicPDEModel..............15 Model3:HybridModel.....................17 MotivationforResearchProblems...................19 IntroductiontoFixationTimesResearch............19 IntroductiontoMultipleLevelsofCooperationResearch...20 III.FIXATIONTIMESINGROUP-STRUCTUREDPOPULATIONS....21 FixationTimesfortheContinuous-TimeMoranProcess.......21 ASimpleandUsefulHeuristicCalculation...........24 Neutral-DriftMoranProcess..................25 MoranProcesswithSelection..................28 FixationTimesforTwo-LevelPopulationDynamicsModels.....30 Example1:NeutralSelection..................32 Example2:WeakSelection...................36 Example3:PublicGood'sGame#1..............39 Example4:PublicGood'sGame#2..............44 OtherStandardGames.....................47 vii

PAGE 8

Conclusions...............................50 IV.MULTIPLELEVELSOFCOOPERATION................52 GeneralizingtoMoreThanTwoTypesofIndividuals........52 ComputingBirthRateswhen k> 2..............52 ComputingtheMutationMatrixwhen k> 2.........53 Example1:PublicGoodsGame....................59 Example2:Snowdrift..........................68 Conclusions...............................76 V.FUTUREWORK...............................77 REFERENCES...................................78 APPENDIX A.MATLABCODE............................80 B.RCODE.................................190 viii

PAGE 9

LISTOFTABLES TABLE 1.Notationforvariouseventrates.......................10 2.Exampleeventsinasimulation.......................13 3.Steady-statestatisticspublicgoodsgame.................65 4.Steady-statestatisticssnowdrift......................74 ix

PAGE 10

LISTOFFIGURES FIGURE 2.1Stateoftheenvironmentattime t usingthestochastic/simulationmodel14 2.2Stateoftheenvironmentattime t usingthedeterministic/PDEmodel.16 2.3Pathofasinglegroupusingthehybridmodel...............18 3.1Expectedtimefromstate i to N for s =0 : 01usingthesimpleheuristic.24 3.2MeanxationtimesforKneutral-driftcontinuous-timeMoranprocesses ofsizeN....................................25 3.3MeanxationtimesforKneutral-driftcontinuous-timeMoranprocesses ofsizeN....................................27 3.4Meanxationtimeforoneasymmetriccontinuous-timeMoranprocessof sizeN.....................................28 3.5Fixationtimevarianceforoneasymmetriccontinuous-timeMoranprocess ofsizeN....................................29 3.6Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andnomigrations, =0.........................33 3.7Simulatedxationtimesasafunctionofthemigrationrateparameter, , andnogrouplevelevents, s =0.......................34 3.8Simulatedxationtimesasafunctionofthemigrationrateparameter, , andgroupleveleventsparameter, s neutralselection..........35 3.9Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andnomigrations, =0weakselection...............37 3.10Simulatedxationtimesasafunctionofthemigrationrateparameter, , andnogrouplevelevents, s =0weakselection.............38 3.11Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andmigrationrateparameter, weakselection............39 x

PAGE 11

3.12Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andnomigrations, =0.........................41 3.13Simulatedxationtimesasafunctionofthemigrationrateparameter, , andnogrouplevelevents, s =0.......................42 3.14Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andmigrationrateparameter, .....................43 3.15Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andnomigrations, =0.........................44 3.16Simulatedxationtimesasafunctionofthemigrationrateparameter, , andnogrouplevelevents, s =0.......................45 3.17Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andmigrationrateparameter, .....................46 3.18Stateoftheenvironmentforsnowdriftexamplewithmigration.....49 4.1MutationProbabilitiesfor i =0 ; 1 ;:::; 5MutationMethod#1.....55 4.2MutationProbabilitiesfor i =0 ; 1 ;:::; 5MutationMethod#2.....56 4.3MutationProbabilitiesfor i =0 ; 1 ;:::; 5MutationMethod#3.....57 4.4Stateoftheenvironmentattime t usingthedeterministic/PDEmodel.60 4.5Hybridmodelresultsforpublicgoodsgameexampleat t =1000 k =262 4.6Hybridmodelresultsforpublicgoodsgameexampleat t =1000 k =363 4.7Hybridmodelresultsforpublicgoodsgameexampleat t =1000 k =564 4.8Hybridmodelresultsforpublicgoodsgameexampleat t =1000 k =1065 4.9Hybridmodelresultsforpublicgoodsgameexampleat t =1000 k =10066 4.10Comparisonofsteady-statedistributionsfordierentvaluesof k .....67 4.11Hybridmodelresultsforsnowdriftexampleat t =1000 k =2.....70 4.12Hybridmodelresultsforsnowdriftexampleat t =1000 k =3.....71 4.13Hybridmodelresultsforsnowdriftexampleat t =1000 k =5.....72 4.14Hybridmodelresultsforsnowdriftexampleat t =5000 k =10.....73 xi

PAGE 12

4.15Hybridmodelresultsforsnowdriftexampleat t =5000 k =100....74 4.16Comparisonofsteady-statedistributionsfordierentvaluesof k .....75 xii

PAGE 13

I.BACKGROUND TheDevelopmentofEvolutionaryTheory WhenCharlesDarwinpublished OntheOriginofSpecies in1859,hebegana revolutioninhowwethinkaboutbiologyandspecicallyinthemutabilityofspecies. Darwinwrote,Owingtothisstruggleforlife,anyvariation,howeverslightand fromwhatevercauseproceeding,ifitbeinanydegreeprotabletoanindividualof anyspecies,initsinnitelycomplexrelationstootherorganicbeingsandtoexternal nature,willtendtothepreservationofthatindividual,andwillgenerallybeinherited byitsospring."[1] Philosophersandscientistsofthepasttwomillenniavigorouslydebatedwhether speciescanchangeovertimeandthemeansbywhichsuchachangecouldoccur[25][28]. Theconceptthatspeciesoforganismschangeovertimehadbeensuggestedasfar backastheAncientGreekandChinese[25][17],butitwasn'tuntilCharlesDarwin inthe19thcenturythataconsistent,coherenttheorybywhichspeciesevolvewas introduced.Darwinstatesintheintroductionto OntheOriginofSpecies ,Asmany moreindividualsofeachspeciesarebornthancanpossiblysurvive;andas,consequently,thereisafrequentlyrecurringstruggleforexistence,itfollowsthatanybeing, ifitvaryhoweverslightlyinanymannerprotabletoitself,underthecomplexand sometimesvaryingconditionsoflife,willhaveabetterchanceofsurviving,andthus benaturallyselected.Fromthestrongprincipleofinheritance,anyselectedvariety willtendtopropagateitsnewandmodiedform." Darwinpositedin Origin thatspeciesevolvebymeansofnaturalselection.One denitionofnaturalselectionisanaturalprocessthatresultsinthesurvivaland reproductivesuccessofindividualsorgroupsbestadjustedtotheirenvironment andthatleadstotheperpetuationofgeneticqualitiesbestsuitedtothatparticularenvironment."[29]Inotherwords,individualorganismsthathavebettersuccess 1

PAGE 14

atsurvivingandreproducingaremorelikelytopassontheirgeneticinformationto thenextgeneration. Aclassicexampleofevolutionbymeansofnaturalselectionistheprevalenceof dark-wingedpepperedmothsduringtheIndustrialRevolutioninEnglandduringthe 19thcentury.[7]PriortothestartoftheIndustrialRevolution,pepperedmothshad whitewingswithpeppered"blackspots.Noblack-wingedpepperedmothswere presentinEnglandpriorto1811.Asairpollution,particularlycoalsoot,increased aroundtheindustrialcentersofEngland,black-wingedpepperedmothswerediscovered.Bytheendofthe19thcentury,black-wingedpepperedmothsdominated peppered-mothpopulationsaroundcitiessuchasManchester.ScientistsusedDarwin'stheoryofevolutionbymeansofnaturalselectiontoarguethattheblack-winged pepperedmothsweremorelikelytosurvivethanwhite-wingedpeppermothssince black-wingedpepperedmothsweremorecamouagedintheblack,sootyenvironment.Asairpollutionsubsidedinthe20thcentury,white-wingedpepperedmoths againdominated. HerbertSpencerwasthersttousethetermsurvivalofthettest"inhisbook, PrinciplesofBiology in1864afterreadingDarwin's Origin .Spencerstated,This survivalofthettest,whichIhaveheresoughttoexpressinmechanicalterms,is thatwhichMr.Darwinhascalled`naturalselection',orthepreservationoffavored racesinthestruggleforlife."Manypeopleunderstandthegeneralideaofsurvival ofthettest",thatis,organismsthataretter"oradaptedtoitsenvironment aremorelikelytopassontheirgenestothenextgenerationcomparedtoaless t"individual[20][21].Unfortunately,thetermtness"isvagueandoftenopento debate.Manyinterpretedsurvivalofthettest"tomeantheorganismswhichindividuallyhadthecharacteristicsbestadaptedtosurvivalandreproduction.Ifan individualisamemberofagroupandgroupsofindividualsmakeupanenvironment, couldanindividual'sgroupaecttheirtness"? 2

PAGE 15

ModesofSelectionandtheEvolutionofCooperation Themeansbywhichnaturalselectionfunctionsisdebatedstilltoday.Natural selectioncanpotentiallytakeplaceonanindividualleveland/oronagrouplevel. Individualselectionisnaturalselectionactingonanindividual,thatis,characteristics thatbenetanorganismonanindividualleveltendtoevolve.Groupselectionisless easilydened.Okasha[13]denesgroupselectionusingthePriceequation, w z = Cov W k ;Z k + E [ Cov w jk ;z jk ] ; I.1 where w istheaveragetnessinthepopulation, z isthechangeinthefractionof cooperatorsinthepopulation, W k istheaveragetnessoftheindividualsingroup k , Z k isthefractionofcooperatorsingroup k , w jk isthetnessofindividual j ingroup k ,and z jk iszerooronedependingonwhetherindividual j ingroup k isadefector orcooperator.Thisdenitionofgroupselectionhasbeencriticizedforanumberof problems,oneofwhichisthatitonlycapturesshort-termchanges[20][21][3][26][27]. Ontheotherhand,Simonetal[20]denesgroupselectionasfollows:Ifatrait establishesitselfinamodeloftwo-levelpopulationdynamicswhengroup-levelevents arepresent,anddoesnotestablishitselfinthesamemodelwhentheyareabsent,then thetraitevolvesbygroupselection."[20]WhilemanyinitiallyinterpretedDarwin's theoryofevolutionbymeansofnaturalselectiontoapplyspecicallyontheindividual levele.g.,fastercheetahsaremorelikelytocatchprey,Darwinsuggestedin1871in TheDescentofMan thatanindividual'sgroupcouldimpactanindividual'stness". Hestated,Therecanbenodoubtthatatribeincludingmanymemberswho,from possessinginhighdegreethespiritofpatriotism,delity,obedience,courage,and sympathy,werealwaysreadytoaidoneanother,andtosacricethemselvesforthe commongood,wouldbevictoriousovermostothertribes;andthiswouldbenatural selection." 3

PAGE 16

Ofparticularinterestinthedebatebetweenindividualandgroupselectionisthe evolutionofcooperation.Individualselectionhelpsexplainwhyfastercheetahsare morelikelytopassontheirgenesthanslowercheetahs,butitishardtoexplain theevolutionofcooperationusingindividualselectionalone.Forexample,social insectssuchasantsdemonstratecooperativebehaviorandmanyspeciesofantshave onlyonefemalequeenthatreproducesforacolonyofhundredsoreventhousandsof ants[30][6].Ifnaturalselectionactsonlyonanindividuallevel,whydosofewfemale antsreproduce?Ofallqualitiesthatanorganismcouldevolve,lackofreproductive abilitydoesnotseemlikelybutweseethisinnatureforanumberofsocialorganisms.Anotherexampleofcooperationinnaturearehoneybeesthathaveevolvedthe behaviortostinghiveinvadersattheexpenseofitsownlife.Howcanweexplainthis kamikazebehaviorofbeeswithrespecttosurvivalofthettest"?Whyarethere instancesinnaturewhereanindividualpotentiallysacricesitsowntnessinfavor oftheindividual'sgroup? Theconundrumoftheevolutionofcooperationandsocialbehaviorhasperplexed biologistssinceDarwinwrote Origin .Whilesomescientistssuggestedthatnatural selectiontookplaceontheindividualandthegrouplevel,othersrejectedsuchanexplanation.Bythemid20thcentury,prominentbiologistssuchasGeorgeC.Williams andJohnMaynardSmitharguedthatnaturalselectiononlytakesplaceonthelevel oftheindividual.[22]OtherssuchW.D.Hamiltonarguedforkinselection,thatis, individualswitht"relativesaremorelikelytopassontheirgeneticdatathan individualswithoutt"relatives.[5]Whilekinselectionseemstopotentiallyhelp explaintheevolutionofcooperation,notallbiologistssubscribetothistheory.One ofthemostvocalcriticsofkinselectionandadvocatesofgroupselectiontodayis renownedbiologistE.O.Wilson.Wilsonreleasedthecontroversialbook Sociobiology in1975whichhediscusseddierentmodesofselectionsuchasindividualselection, kinselection,andgroupselection[30]andatthetimearguedthatkinselectionleads 4

PAGE 17

totheevolutionofaltruism.Intheearly1990's,EliotSoberandDavidSloanWilsonarguedforamultilevelselectionmodelofnaturalselection,andinfact,thereis currentlyaresurgenceinthoughtthatnaturalselectionactsonanindividualand grouplevel.[22]By2010,E.O.WilsonalongwithMartinNowakandCorinaTarnitapennedthecontroversialarticle,Theevolutionofeusociality",whichrejected kinselectioninfavorofgroupselection[11]andmultilevelselectionmodels.Today, however,biologistsremainsplitontheexactmechanismsofnaturalselection. Thisdissertationwillexploremathematicalmodelsformultilevelselectionmodels whereindividualandgroupleveleventsimpactthepopulationdynamicsoforganisms.Thesemodelsillustratehowcooperativebehaviorcouldpotentiallyevolve.The detailsofthismultilevelselectionmodelareoutlinedinthenextchapter. 5

PAGE 18

II.TWO-LEVELPOPULATIONDYNAMICSMODEL PopulationModels Whenmodelingpopulationsoforganismswithmorethanonetype,standard modelssuchastheMoranprocessmakenumerousassumptionsthatmaynotaccuratelymodelnature.Beforeintroducingthetwo-levelpopulationdynamicsmodel thatwillbeutilizedintherestofthisstudy,someofthedrawbacksofstandard populationmodelswillbebrieydiscussed. Thediscrete-timeMoranprocesswasrstintroducedbyPatrickMoranin1958 tomodelnitepopulations.[9]AMoranprocessisastochasticprocesswithaxed populationsizeof N individualsoftwotypeswhichwillbecalledcooperatorsand defectorsforconvenience.ThestatesofthisMarkovprocessare f 0 ; 1 ;:::;N g ,where state i indicatesapopulationof i cooperatorsand N )]TJ/F20 11.9552 Tf 11.956 0 Td [(i defectors. AneutralMoranprocesshasthefollowingdiscrete-timetransitionprobabilities fromstate i tostate j [18]. P i;j = 8 > > > > > > < > > > > > > : N )]TJ/F21 7.9701 Tf 6.587 0 Td [(i N i N j = i )]TJ/F15 11.9552 Tf 11.955 0 Td [(1 i N N )]TJ/F21 7.9701 Tf 6.587 0 Td [(i N j = i +1 1 )]TJ/F20 11.9552 Tf 11.955 0 Td [(P i;i )]TJ/F18 7.9701 Tf 6.586 0 Td [(1 )]TJ/F20 11.9552 Tf 11.956 0 Td [(P i;i +1 j = i II.1 Theseprobabilitiescanbeexplainedasfollows.Anindividualischosenatrandom togivebirthandanindividualischosenatrandomtodie.Forapopulationof N individualsofwhich i areoftype1and N )]TJ/F20 11.9552 Tf 12.302 0 Td [(i areoftype2,theprobabilitythata type1individualischosentogivebirthis P type 1= i N andtheprobabilitythata type2individualischosentodieis P type 2= N )]TJ/F21 7.9701 Tf 6.586 0 Td [(i N .Inotherwords,theprobability ofatransitionfromstate i i.e., i individualoftype1tostate j i.e., j individuals oftype1isgivenby P i;j = i N N )]TJ/F21 7.9701 Tf 6.587 0 Td [(i N .Similarreasoningcanbeusedtocalculatethe probabilitythatatype1individualdiesandatype2individualisbornorthesame 6

PAGE 19

typeofindividualcouldbeselectedtobebornandtodieinwhichcasetheMarkov chainstaysinthesamestate. FortheneutralMoranprocess,ateachtimestepanindividualischosenat randomtogivebirthtoanindividualofthesametypeandanindividualischosenat randomtodie.TheneutralMoranprocessisanappropriatemodelforthepopulation dynamicsofaxedsizepopulationwithtwotypesofindividualswithequalbirthand deathrates.Wecanrstgeneralizethismodeltoallowforindividualswithdierent levelsoftness",wheretter"individualsaremorelikelytogivebirth.Suppose i cooperatorshavetness f i and i defectorshavetness g i .AnasymmetricMoran processhasthefollowingtransitionprobabilitiesfromstate i tostate j ,where i is thenumberofcooperators. P i;j = 8 > > > > > > < > > > > > > : g i N )]TJ/F21 7.9701 Tf 6.587 0 Td [(i f i i + g i N )]TJ/F21 7.9701 Tf 6.587 0 Td [(i i N j = i )]TJ/F15 11.9552 Tf 11.955 0 Td [(1 f i i f i i + g i N )]TJ/F21 7.9701 Tf 6.587 0 Td [(i N )]TJ/F21 7.9701 Tf 6.587 0 Td [(i N j = i +1 1 )]TJ/F20 11.9552 Tf 11.955 0 Td [(P i;i )]TJ/F18 7.9701 Tf 6.586 0 Td [(1 )]TJ/F20 11.9552 Tf 11.956 0 Td [(P i;i +1 j = i II.2 AnasymmetricMoranprocessallowsforapopulationofindividualsofdiering birthratestobemodeled,butitassumesabirthanddeathoccurateachsucceeding timeinstance.ThisasymmetricMoranprocesscanbefurthergeneralizedtoallow foravariableamountoftimeinbetweenbirth/deathoccurrences.Acontinuous-time Moranprocessallowsforvariabletimebetweeneventsbymodelingthesetimesas exponentialrandomvariables.Thiswillbediscussedindepthinthenextchapter. Unfortunately,thecontinuous-timeMoranprocess,alongwiththeothertypesof Moranprocessesaforementioned,assumesaxedpopulationsize,soadeathoccurs everytimeabirthoccurs.WhiletheMoranprocesscanbeusedtomodelpopulations, theassumptionofaxedpopulationdoesn'tseemreasonableforthepopulation dynamicsinnature.Inparticular,birthanddeathratesofindividualscoulddepend onthesizeofanindividual'sgroupwhichcannotbeincorporatedintotheMoran 7

PAGE 20

model.TheMoranprocesswillbeexploredmoreinthenextchapter,butsince itassumesaxedpopulationsize,amorerobustmodelispreferred.Notethat allpopulationmodelsfortherestofthisstudywillbeincontinuous-timeandnot discrete-time. One-LevelPopulationDynamicsModel SincetheMoranprocessmakesassumptionsthatseemunlikelytoholdinnature, amoregeneralpopulationdynamicsmodelisintroduced.Inthismodel,individuals cangivebirthandcandieandbirthsanddeathsaren'trequiredtocoincidelikethe Moranprocess.Inaddition,birthscanhavemutationsi.e.,cooperatorssometimes givebirthtodefectorsandviceversa.Forsimplicity,allmodelsusedinthispaper willassumecooperatorsanddefectorshaveequaldeathrates,butpotentiallydiering birthrates. Birthratescanbemodeledinavarietyofmannerssuchasxedandequalbirth ratesforcooperatorsanddefectors,xedandunequalbirthratesforcooperatorsand defectors,oreventime-varyingbirthratesdependingonthestateoftheenvironment. OnepossibilityformodelingbirthratesistoapplyGameTheoryandconsidercooperatorsanddefectorsplayingagame"thatdeterminestheirrespectivebirthrates[ ? ]. Considerthegeneraltwo-player,two-strategygamewithpayomatrix, P = 0 B @ cd cRS dTP 1 C A II.3 wherewecallthestrategiescooperateanddefect.Birthratesforindividualsinthe groupcanbemodeledasproportionaltotheexpectedpayoforagameagainsta randomopponentfromthegroup, b c x;y = R x x + y + S y x + y II.4 b d x;y = T x x + y + P y x + y II.5 8

PAGE 21

where isascalingparameter, x isthenumberofcooperators,and y isthenumber ofdefectorsinthegroup. Dierentchoicesof R;S;T; and P willresultindierenttypesofgames.For example,when S
PAGE 22

Two-LevelPopulationDynamicsModel Simonintroducedatwo-levelpopulationdynamicsmodel,whereindividualsof k typesareorganizedintogroups[19].Inthismodel,individualscangivebirth possiblywithmutations,candie,orcanmigratetoadierentgroup.Onagroup level,groupsofindividualscanssionintotwogroupsorcangoextinct. Thestateofagroupisavector, ~x ,thatspeciesthenumberofindividualsof eachtype,i.e., ~x =[ x 1 x 2 :::x k ]where x i isthenumberofindividualsoftype i .The stateoftheenvironmentattime t is t ~x ~x 2 Z + k ,thenumberofgroupsinthe environmentwithgrouppopulation ~x foreach ~x 2 Z + k . Thefollowingnotationwillbeusedtolabeleventratesthroughouttherestof thisstudy,wheregroup i has x cooperatorsand y defectors. Table1.:Notationforvariouseventrates Symbol Event EventType b c x;y Birthrateofcooperatorsingroup i 1 Individual b d x;y Birthrateofdefectorsingroup i 1 Individual d c x;y Deathrateofcooperatorsingroup i Individual d d x;y Deathrateofdefectorsingroup i Individual m x;y Migrationratefromgroup i Individual f x;y Fissionrateforgroup i Group e x;y Extinctionrateforgroup i Group 1 Birthmutationscanalsobeintroducedinthemodel. 10

PAGE 23

ModelAssumptions AslaidoutinSimon[19],thismodelalsomakesthefollowingassumptions: 1.Theenvironmentcontainsdistinctgroupsofdistinctindividuals. 2.Themigrationofindividualsfromgrouptogroupifanyisrandomi.e.individualsactindependently. 3.Thepopulationdynamicsoftheindividualswithinagroupdependsonits presentstateandpossiblythepresentstatesoftheothergroupsintheenvironment. 4.Groupsoccasionallyssionintotwoormorepiecesthatbecomenewgroupson theirown. 5.Allgroupseventuallydieofextinctioniftheydonotssionrst. 6.Group-levelvariables,suchasssioningrates,extinctionrates,etc.,arefunctionsofthepresentstatesofthegroupsintheenvironmentincludingthegroup inquestion. UnliketheMoranprocess,thisgroup-structuredpopulationdynamicsmodelallowsforgrouppopulationstovarythroughtime.Thispopulationmodelcanbestudiedbylarge-populationasymptoticsi.e.,adeterministicmodel,bysimulationi.e., astochasticmodel,orbyahybridmodelthatincludesdeterministicandstochastic elements. 11

PAGE 24

Model1:StochasticSimulationModel ThestochasticmodelisaMonteCarlo-basedsimulationusingacomplicated continuous-timeMarkovchain.ThissimulationcanbecompletedusingtheGillespiealgorithm,whereindividualandgroupleveleventsaremodeledasexponential randomvariables.Exponentialrandomvariableshavethememorylesspropertyi.e., P [ t>T + j t> ]= P [ t>T ]thatmakessimulationeasytoimplementinpractice. TheGillespiealgorithmhasfoursteps:initializing,randomnumbergeneration,updating,anditerating.Thesimulationbeginsattime t =0and exponentialrandomvariablesaregeneratedbasedoneventratesbirths,deaths,migrations,groupextinctions,groupssionswhicharecalculatedbasedonthestate oftheenvironmentstep1.Theminimumrealizedvalueoftheexponentialrandom variablesdeterminesthenexteventtooccurstep2,thetimeatwhichthenext eventoccurs,andhowthestateoftheenvironmentchanges..Oncethepopulation oftheenvironmentandthetimeofthesimulationareupdatedstep3,theprocess isrepeatedbeginningagainwithgeneratingexponentialrandomvariableswiththe updatedeventratesstep4. Toillustratethissimulationmodel,consideranenvironmentthatconsistsof onegroupwith15cooperatorsand15defectorsbeginningattime t =0wherethe followingeventsoccurinsuccession. 12

PAGE 25

Table2.:Exampleeventsinasimulation Time Event EventType Environment t =0 Startofsimulation Onegroup:coop.,15def. t =0 : 132 Cooperatorbirth Individual Onegroup:,15 t =0 : 168 Defectordeath Individual Onegroup:,14 t =0 : 203 Cooperatordeath Individual Onegroup:,14 t =0 : 311 Groupssion Group Twogroups:,3,,11 t =0 : 314 Defectorbirth Individual Twogroups:,4,,11 t =0 : 389 Groupextinction Group Onegroup:,11 Thestochasticmodelcanbeusefulforanalyzingquantitiesforwhichclosed formulasdon'texist.Repeatingsimulationsforthesamestartingconditionsallows forunknownquantitiestobestudiedstatistically.Forexample,inchapter3,the stochasticmodelwillbeusedtostudyhowlonguntilanenvironmentofcooperators anddefectorseventuallyishomogeneous.Sincethesesimulationsareindependent,we caneasilycalculateapproximatecondenceintervalsforvariousparametersofinterest suchaswhatistheprobabilitythatdefectorseventuallyruletheentireenvironment andonaverage,howlongdoesittaketoreachhomogeneity.Visuallyviewingthe populationdynamicsofasimulationcanbemorechallengingtonoteoverallshiftsin thepopulation,astherandomnatureofindividualandgroupleveleventscanobscure theoveralldrift. Twolimitmodelsderivedfromthesimulationmodelwillalsobeexplored.First, adeterministicPDEmodelwillbedevelopedbylettingthesizeofgroupsandthe numberofgroupsapproachinnity.Thismodelwillbeusefulforstudyingtheoverall evolutionofgroupcompositionsasafunctionoftime.Second,ahybridmodelwillbe developedbylettinggroupsizesapproachinnity.Inthishybridmodel,group-level eventsarestillrandom,sothismodelisusefulforinspectingtheoverallevolutionof 13

PAGE 26

a t =0 : 132 b t =0 : 168 c t =0 : 203 d t =0 : 311 e t =0 : 314 f t =0 : 389 Figure2.1:Stateoftheenvironmentattime t usingthestochastic/simulationmodel 14

PAGE 27

theenvironmentaswellastheeectofgroup-leveleventsonthepopulationdynamics oftheenvironment. Model2:DeterministicPDEModel ApartialdierentialequationPDElimitmodelcanbebuiltfromthestochastic modelthatenablesonetoderivegrouppopulationtrajectories[19]bylettinggroup sizesapproachinnityandthenumberofgroupsintheenvironmentapproachinnity.Thisisalarge-populationlimitmodelthatisjustiedbyalimittheorem inPuhalskiiandSimon[16],hasreal-valuedpopulationsofindividualsand groups,andstochasticratefunctionsareanalyzedtobedeterministicratefunctions. Thisdeterministicprocessisgovernedby: @ t @t ~x + k X i =1 @ t t;i @x i = g t ~x II.8 where g t ~x = Z t ~x t ~x d~x )]TJ/F15 11.9552 Tf 11.955 0 Td [( e t ~x )]TJ/F20 11.9552 Tf 11.956 0 Td [(f t ~x t ~x II.9 and i;t = b i;t ~x )]TJ/F20 11.9552 Tf 11.955 0 Td [(d i;t ~x II.10 i.e.,thedierenceinbirthanddeathratesforindividualsoftype i attime t and t ~x isthessioningprobabilitydensityfunctionforan ~x -group.ThePDEgiven in.6canbesolvednumericallybyrsttruncatingtheentirestatespace R k + into a k -dimensionalhyperrectangle[0 ;x 1 ;max ] [0 ;x 2 ;max ] ::: [0 ;x k;max ],where x i;max areselectedsothatthereissmallprobabilityagroupwillattainmorethan x i;max individualsoftype i .Timecanalsobediscretizedintostepsoflength t .Assuch, thestateoftheenvironmentcanbeupdatedfromtime t , t ,totime t + t , t + t . Toillustratethismodel,considerthefollowingexamplewithtwotypesofindividuals,cooperatorsanddefectors.Forthisexample,birthratesarebasedonthe expectedpayofromapublicgoodsgame,sowithinanygivengroup,defectorshave 15

PAGE 28

a t =0 b t =5 c t =7 d t =9 e t =12 f t =20 Figure2.2:Stateoftheenvironmentattime t usingthedeterministic/PDEmodel aslightlyhigherbirthrateandgroupswithlotsofcooperatorsoverallhavehigher birthratesthancomparedtogroupwithlotsofdefectors.Birthmutationsaswell asgroup-leveleventssuchasssionsandextinctionsarealsopresentinthismodel. At t =0,theenvironmentconsistsofonlygroupsofapproximately10cooperators and40defectors.As t increases,theoverallcompositionoftheenvironmentgoes fromdefector-heavygroupstocooperator-heavygroupsdespiteallgroupseventually becomingdefector-heavyintheabsenceofgroup-levelevents.By t =20,groupsare mostlycooperatorswithasmallnumberofdefectors.Thisexampleillustrateshow anenvironmentofmajoritydefectorgroupscanevolvetoanenvironmentofmajority cooperatorgroupsandhenceillustratesonewaycooperationcouldpotentiallyevolve. Thisexamplewillbestudiedmoreindepthinchapter4. Thisdeterministic/PDEmodelisusefultounderstandingthegeneralevolutionof thecompositionsofthegroupsintheentireenvironment.Inparticular,thesolution ofthePDEcanbeviewedvisuallytoseethegradualchangingoftheenvironment. 16

PAGE 29

Thisismuchhardertodiscernwiththesimulationmodelduetotherandomnature ofbirths,deaths,andotherevents.Unfortunately,therearesomeartifactsofusing thelargepopulationapproximationthatdon'tseemtoaccuratelymodelreality.In chapter3,xationtime,thetimeuntilallgroupsinpopulationoftwoormoretypesof individualsbecomehomogeneous,willbestudiedindepth.ThePDEmodelsuggestsa steady-statepopulationofcooperatorsanddefectors,however,sincethesesimulations haveabsorbingstatesalongtheaxes,i.e.,groupswithalldefectorsorallcooperators willstayalldefectorsorallcooperatorsintheabsenceofmutations,theenvironment willeventuallyxwithonlyonetypeofindividualineachgroup.Thisinconsistency willbestudiedinchapter3. Model3:HybridModel ThehybridmodelwasdevelopedbySimonandNielsenandisacompromiseofthepurelystochasticsimulationmodelandofthepurelydeterministicPDE model[21]bylettingthesizeofgroupsapproachinnity.Inthismodel,individual leveleventssuchasbirths,deaths,mutations,andmigrationsareallmodeledasdeterministicandgroupleveleventssuchasgroupssionsansextinctionsaremodeled asstochastic.Thiscompromiseallowsonetovisuallyinspectthegeneraldriftof thepopulationwhileallowingfortherandomnessofgroup-leveleventstoimpactthe populationininterestingways. Thehybridmodelworksbydividingtimeintosucientlysmalltimesteps, t , sothatitisveryunlikelyformorethanonegroup-leveleventtooccurinanygiven timestep.Atthebeginningofeachtimestep,randomvariablesaregeneratedbased onthegroup-leveleventrates.Ifoneoftheserandomvariablesissmallerthanthe timestep t ,thentheenvironmentisupdatedtoreecteitherthegroupssion orthegroupextinction.Afterupdatingthegrouppopulationsasneededforany group-leveleventsinthetimestep t ,allpopulationsareupdatedbasedontheir respectivebirthanddeathrates.Thisupdatingisdonebasedonnumericallysolving 17

PAGE 30

anordinarydierentialequationbasedonthecurrentbirthanddeathratesofthe dierentpopulations.Supposethecurrenttimeis t 0 ,thetimestepofthemodelis t , andgroup i has n c;i t and n d;i t cooperatorsanddefectors,respectively.Populations areupdatedusingNewton'smethodasfollows. n c;i t 0 + t = n c;i t 0 + t b c t )]TJ/F20 11.9552 Tf 11.956 0 Td [(d c t II.11 n d;i t 0 + t = n d;i t 0 + t b d t )]TJ/F20 11.9552 Tf 11.955 0 Td [(d d t II.12 Asanexample,thepathofasinglegroupusingthehybridmodelisdisplayedin gure2.3.Thegroupinitiallyhasapopulationof35cooperatorsand10defectors. Initially,thereisanincreaseincooperatoranddefectorpopulationsuntilthereare approximately50cooperatorsand25defectors.Atthispoint,thesizeofthegroup issucientlylargethatthedeathrateexceedsthebirthrateofcooperatorswhile theoppositeistruefordefectors.Asaresult,thenumberofdefectorscontinuesto increasewhilethenumberofcooperatorsdecreases. Figure2.3:Pathofasinglegroupusingthehybridmodel Thehybridmodelisthepreferredmethodforvisualizingtheevolutionofapop18

PAGE 31

ulationforthetwo-levelpopulationdynamicsmodel.ItisnotonlymorecomputationallyecientthanthesimulationmodelandthePDEmodel,italsoallowsfor onetostudythedriftofthepopulationwhilestillseeingtheeectsofgrouplevel events.Forthisreason,thehybridmodelwillbeusedinchapter4toexplorethe populationdynamicswhenmorethantwotypesofindividualsmakeuptheenvironment.Asthenumberoftypesofindividualsincreases,simulationbecomesdicult computationallywithcurrenttechnology.Thecomputationaleciencyofthehybrid modelcomparedtothesimulationmodelallowsformodelingincreasinglycomplicated populationstructures. MotivationforResearchProblems Twotopicsinvolvingevolutionarypopulationdynamicswerestudiedforthisdissertation.Inchapter3,xationtimeswillbeexploredusingthesimulationmodel. Inchapter4,thehybridmodelwillbegeneralizedtoallowintermediatelevelsof cooperationratherthanjustpurecooperatorsandpuredefectors. IntroductiontoFixationTimesResearch Fixationtimeisdenedhereasthetimeuntilallgroupsintheenvironmentare homogeneous,thatis,eachgrouponlyhasonetypeofindividual.Insection2.2.3, asolutionforthePDEmodelisdisplayedingure2.2.Ofparticularinterestis thatastimeapproachesinnity,thereisasteady-statepopulationofgroupswith bothcooperatorsanddefectorswhenusingthePDEmodel.Ifthesimulationmodel isusedwiththesameparameters,thexingofpopulationisexpectedinanite amountoftime.Thisisbecauseallgroupswilleventuallyhaveallcooperatorsorall defectorsjustbytherandommovementsfromthestochasticprocesses.Ifmigrations ormutationsaresucientlyfrequent,itispossibleforsomeofthesehomogeneous groupstobecomeheterogeneousbuttypicallythesegroupsquicklyxagainwith allcooperatorsoralldefectors.Whydoesthismatter?ThePDEmodelsuggestsa steady-statepopulationofgroupsthatareheterogeneous,thatis,someofthegroups 19

PAGE 32

insteady-statewillhaveamixedpopulationandthesimulationmodelsuggeststhe environmentwillxwithallhomogeneousgroups.Resolvingthispotentialconictis ofinterestinanattempttounderstandthesemodelsmoreclearly.Priortoresearch, itwashypothesizedthateitherthexingofpopulationstakesalongtime",soin practice,thegroupsdon'txforanextremelylongtimeorthatthedierencebetween thePDEmodelandthesimulationmodelresultsweremerelyanartifactofhowthe PDElimitmodelwasformulated.Itwillbeshowninchapter3thatthelateristrue; groupsxwithonetypeofindividualwithinasimulationtimeofapproximately 10 5 2typesof individualstobemodeled.Inparticular,acooperationcoecientwillbeintroduced whereapuredefectorhasacooperationcoecientof c 1 =0,apurecooperatorhasa cooperationcoecientof c N =1,andintermediatelevelsofcooperation 2orifcompletelydierentpopulation dynamicsresultfrommorethantwotypesofindividuals.Itisalsoofinteresthowthe steady-statepopulationsdierfordierentvaluesof N andifincreasing N speedsup orslowsdowntheevolutionofcooperation.Interestingly,twoexamplesinchapter4 willshowthatincreasingthenumberofintermediatelevelsofcooperationmayormay notleadtocompletelydierentsteady-statepopulations.Infact,theintroduction ofmultiplelevelsofcooperationcanhaveinterestingandunexpectedresults.The hybridmodelwasutilizedforthisresearchtopicforcomputationalspeedandbecause thegeneraldriftofthepopulationiseasiertovisualizewiththehybridmodel. 20

PAGE 33

III.FIXATIONTIMESINGROUP-STRUCTUREDPOPULATIONS FixationTimesfortheContinuous-TimeMoranProcess Considerapopulationofindividuals,whereeachindividualiseithertypeAor typeB.Acontinuous-timeMoranprocesshasstates f 0 ; 1 ;:::;N g wherestate i correspondsto i typeAindividualsand N )]TJ/F20 11.9552 Tf 11.968 0 Td [(i typeBindividuals,i.e.,therearealways atotalof N individuals.TypeAandBindividualshavexedpossiblydierent birthrates.Wheneveranindividualgivesbirth,itsospringisthesametype,andat thesameinstantanindividualchosenrandomlyfromtheoriginal N dies,keepingthe totalpopulationat N .Herewewillassumewithoutlossofgeneralitythattheper capitabirthratefortypeAis1+ s;s> )]TJ/F15 11.9552 Tf 9.299 0 Td [(1,andfortypeBis1.Togofromstate i to i +1meanstherewasatypeAbirthrate i + s andtheindividualchosento diewastypeBprobability N )]TJ/F21 7.9701 Tf 6.586 0 Td [(i N .Togofromstate i to i )]TJ/F15 11.9552 Tf 11.468 0 Td [(1meanstherewasatype Bbirthrate N )]TJ/F20 11.9552 Tf 11.955 0 Td [(i andtheindividualchosentodiewastypeAprobability i N . Theinnitesimalgenerator[14], Q ,forthecontinuous-timeMoranprocessthereforehas Q i;i +1 = + s i N )]TJ/F20 11.9552 Tf 11.956 0 Td [(i N III.1 Q i;i )]TJ/F18 7.9701 Tf 6.586 0 Td [(1 = N )]TJ/F20 11.9552 Tf 11.955 0 Td [(i i N III.2 Q i;i = )]TJ/F20 11.9552 Tf 9.299 0 Td [(i N )]TJ/F20 11.9552 Tf 11.955 0 Td [(i + s N III.3 Q i;j =0 ;j= 2f i )]TJ/F15 11.9552 Tf 11.955 0 Td [(1 ;i;i +1 g III.4 for i =1 ; 2 ;:::;N )]TJ/F15 11.9552 Tf 11.016 0 Td [(1.When i =0or i = N ,wehave Q i;j =0 ; 0 j N sincethey areabsorbingstates.Therowsandcolumnsoftheinnitesimalgenerator Q canbe rearrangedtobeintheblockform: Q = 2 6 4 ^ QP 00 3 7 5 III.5 Inthisform,thematrix ^ Q isan N )]TJ/F15 11.9552 Tf 10.006 0 Td [(1by N )]TJ/F15 11.9552 Tf 10.006 0 Td [(1matrixrepresentingthetransitions betweentransientstatesi.e., i =1 ; 2 ;:::N )]TJ/F15 11.9552 Tf 10.279 0 Td [(1, P representsthetransitionsbetween 21

PAGE 34

transientandabsorbingstates.Let F bethetimeuntilxationstartinginstate n= 2, i.e.,thetimeuntilabsorptionineitherstateor N .Let u i bearowvectorwith N )]TJ/F15 11.9552 Tf 11.522 0 Td [(1zerosexceptforthe i th entrywhichisequalto1,andlet 1 bea N )]TJ/F15 11.9552 Tf 11.521 0 Td [(1column vectorof N )]TJ/F15 11.9552 Tf 11.955 0 Td [(1ones. Fromtheory[14],thefollowingareobtainedfromtheinnitesimalgenerator. E [ F ]= )]TJ/F20 11.9552 Tf 9.299 0 Td [(u i ^ Q )]TJ/F18 7.9701 Tf 6.586 0 Td [(1 1 III.6 E [ F 2 ]=2 u i ^ Q )]TJ/F18 7.9701 Tf 6.587 0 Td [(2 1 III.7 Var F = E [ F 2 ] )]TJ/F15 11.9552 Tf 11.955 0 Td [( E [ F ] 2 III.8 Themeanandvarianceofthexationtimeofacontinuous-timeMoranprocess ofsizeNcanbecalculatedinthismanner.InthisMoranmodel,thetimeuntila groupishomogeneousisequaltothetimeuntilthepopulationreachesoneofthe twoabsorbingstates,namely i =0or i = N ,andthiswillbedenedasthexation time.Theprobabilitytheprocessreachesstate N beforestate0i.e.,typeAxes islim t !1 [ e Qt ] i;N ,whichcanbefoundanalytically[14]. Now,consideranenvironmentthathas K independentgroups,eachmodeledas aMoranprocessesof N individualsandtheintra-groupdynamicsaregovernedby continuous-timeMoranprocessesstartingfromstate i .Thetimeuntilall K groups havereachedoneoftheabsorbingstates,denedas F K ,isthetimeuntilallgroups arehomogeneous. F K = max f F 1 ;F 2 ;:::;F K g III.9 where F j isthexationtimeforthe j thgroup.Theexpectedvalueandvarianceof F K canbecalculatedfrom.9asfollows. 22

PAGE 35

P F K t III.11 = 1 )]TJ/F20 11.9552 Tf 11.955 0 Td [(u i e ^ Qt 1 K III.12 Notethatinprinciple,onecanalloweachgrouptostartinadierentstate,but forourpurposesherethataddedcomplexityisunnecessary.From.12,wehave E [ F K ]= Z 1 0 P F K >t dt III.13 = Z 1 0 )]TJ/F15 11.9552 Tf 5.479 -9.684 Td [(1 )]TJ/F20 11.9552 Tf 11.955 0 Td [(P F K t dt )]TJ/F20 11.9552 Tf 11.955 0 Td [(E [ F K ] 2 III.16 = Z 1 0 2 t 1 )]TJ/F26 11.9552 Tf 11.955 13.27 Td [( 1 )]TJ/F20 11.9552 Tf 11.955 0 Td [(u i e ^ Qt 1 K dt )]TJ/F20 11.9552 Tf 11.955 0 Td [(E [ F K ] 2 : III.17 NumericalintegrationusingSimpson'sRulewillbeusedtoevaluatetheseintegralsforavarietyofcases. 23

PAGE 36

ASimpleandUsefulHeuristicCalculation WhentheMoranprocessisinstate i itcanmovetothestates i )]TJ/F15 11.9552 Tf 11.475 0 Td [(1or i +1,but if s> 0thenthereisadrift"inthepositivedirection.Thedriftrateis d i = Q i;i +1 )]TJ/F20 11.9552 Tf 11.955 0 Td [(Q i;i )]TJ/F18 7.9701 Tf 6.587 0 Td [(1 = s i N )]TJ/F20 11.9552 Tf 11.955 0 Td [(i N III.18 sothetimeittakestogetfromstate i to i +1shouldhaveameanofabout d )]TJ/F18 7.9701 Tf 6.587 0 Td [(1 i .The expectedtimetogetfromstate i to N conditionedonthefactthatAxesis T i ! N N )]TJ/F18 7.9701 Tf 6.586 0 Td [(1 X j = i d )]TJ/F18 7.9701 Tf 6.586 0 Td [(1 i III.19 = N s N )]TJ/F18 7.9701 Tf 6.587 0 Td [(1 X j = i 1 i N )]TJ/F20 11.9552 Tf 11.955 0 Td [(i III.20 = 1 s N )]TJ/F18 7.9701 Tf 6.587 0 Td [(1 X j = i 1 i + 1 N )]TJ/F20 11.9552 Tf 11.955 0 Td [(i III.21 1 s Z N )]TJ/F18 7.9701 Tf 6.587 0 Td [(1 i 1 x + 1 N )]TJ/F20 11.9552 Tf 11.956 0 Td [(x dx III.22 = 1 s ln N )]TJ/F15 11.9552 Tf 11.955 0 Td [(1 )]TJ/F15 11.9552 Tf 11.955 0 Td [(ln i +ln N )]TJ/F20 11.9552 Tf 11.956 0 Td [(i III.23 Notethat T 1 ! N =2ln N )]TJ/F15 11.9552 Tf 10.778 0 Td [(1 =s and T N= 2 ! N =ln N )]TJ/F15 11.9552 Tf 10.779 0 Td [(1 =s ,sogiventhatararetype Amutantxes,itwillspendabouthalfthexationtimegettinghalfwaytoxation. a N =10 b N =100 c N =1000 Figure3.1:Expectedtimefromstate i to N for s =0 : 01usingthesimpleheuristic Notethatthissimpleheuristicisnotvalidif s 0unless N isverybig. 24

PAGE 37

Neutral-DriftMoranProcess Theneutral-driftcontinuous-timeMoranprocesscanbeanalyzedbysetting s = 0.Theexpectedvalueandvarianceofxationtimes,startinginstate N 2 ,were calculatedanalyticallyvianumericalintegrationfor1 N 1000individualsper groupand1 K 100groupsofindividuals.Theresultsareplottedbelowand wereveriedusingsimulation.AscanbeseeninFig.3.2,themeanxationtimeof KgroupsgrowslinearlyasafunctionofgroupsizeN. Figure3.2:MeanxationtimesforKneutral-driftcontinuous-timeMoranprocesses ofsizeN 25

PAGE 38

Ascanbeseeningure3.3,themeanxationtimeofgroupsofsize N grows logarithmicallyasafunctionofthenumberofgroups K .Let X i bethexation timeforgroup i whichisexponentiallydistributed.Thelogarithmicgrowthofmean xationtimesasafunctionofthenumberofgroups K canbejustiedasfollows. X i exp III.24 Y = max f X 1 ;X 2 ;:::;X k g III.25 P Y
PAGE 39

Figure3.3:MeanxationtimesforKneutral-driftcontinuous-timeMoranprocesses ofsizeN 27

PAGE 40

MoranProcesswithSelection Now,wewillconsiderthecase s> 0,thatis,thersttypeofindividualhasa competitiveadvantageoverthesecondtypeofindividual.Belowarethemeanand thevarianceofthexationtimeforonegroupforarangeofvaluesfortheasymmetry parameter, s . Figure3.4:Meanxationtimeforoneasymmetriccontinuous-timeMoranprocessof sizeN 28

PAGE 41

Asseenintheneutral-driftexamples s =0,themeanxationgrowslinearlyas afunctionofgroupsize.Intheasymmetriccases s 6 =0,meanxationtimeshave alimitthatthatislogarithmic,ascanbeseenfromequation.23. Figure3.5:Fixationtimevarianceforoneasymmetriccontinuous-timeMoranprocess ofsizeN 29

PAGE 42

FixationTimesforTwo-LevelPopulationDynamicsModels TheMoranprocessallowsonetostudyanidealizedmodelofxation.The strengthoftheMoranprocessliesinitssimplicitywhichallowsanalyticalresults. Butthesimplicityisalsoaweakness.Forexample,theconstantpopulationsize meansthattheMarkovchainhasarelativelysmallstatespace,butinordertokeep thepopulationconstantweareforcedtoimaginethateverybirthissimultaneously accompaniedbyadeath.Thissetupisinsensitivetosizedependenteects.Inmultigroupmodels,wewouldhavetoimaginethatmigrationeventswouldhavetooccur insuchawaythattherewasneveranetgainorlossineachgroup'spopulation. Dierencesinbirth,deathandmigrationratesduetovaryinggroupsizescannotbe studiedinMoran-basedmodels,andgroup-leveleventslikessioncannotbestudied sinceitchangesthesizeoftheaectedgroups.Forthesereasonswelookforamore generalmodelofgroup-structuredpopulations.InSimon,adynamicalpopulationmodelwasproposedthatfeatureduncoupledbirthsanddeathsofindividuals, groupssions,groupextinctions,andmigrationsofindividuals[ ? ].Inthismodel, therearenoarticialconstraintsonthenumberofgroupsinthepopulation,noron thenumberofindividualsineachgroup.Theindividual-levelandgroup-levelevent ratesarestate-dependent.Forexample,anindividual'sbirthrateisoftendetermined byitsexpectedpayoinagamelikeSnowdriftplayedwithitsgroupmatesand/or theindividual'stype.Sinceeventratesarestatedependent,itwillbeconvenient todenean x;y -grouptobeagroupwith x typeAcooperatorsand y typeB defectors. Dene b c x;y and b d x;y tobethepercapitabirthratesofcooperatorsand defectorsinan x;y -group.Severalexampleswillbestudiedfordierentchoicesof thebirthratefunctions.Theseexamplesincludeabaselinecasewherecooperators 30

PAGE 43

anddefectorshaveequalandxedbirthrates,aweakselection"casewherecooperatorsanddefectorshavexedandnon-equalbutsimilarbirthrates,twocaseswhere thebirthratesareafunctionoftheindividual'spayoinaPublicGood'sGame,and nally,acasewherebirthratesareafunctionoftheindividual'spayoinagameof Snowdrift. Inadditiontobirtheventsinthemodel,therearealsodeaths,migrations,extinctionsgroupdeaths,andssionsgroupbirths.Theseratefunctionswillbe xedacrosstheveexamplesinordertokeepthescopeofthisstudyfromgrowing uncontrollably. Wewillassumethatpercapitadeathratesforcooperatorsanddefectorsdepend onlyonthesizeofthegrouptheyresidein,i.e., d c x;y = d d x;y = x + y III.32 Weassumeindividualsmigratefromtheirgroupstoanothergroupatapercapita rateisconstant,i.e., m x;y = III.33 where isthemigrationrateparameter. Individualbirths,deaths,andmigrationswillbecalledindividual-leveleventsas denedin[20].Therearealsogroup-leveleventswhichincludegroupssionsgroup birthsandgroupextinctionsgroupdeaths.Tocontrolthenumberofgrouplevel events,therewillalsobeascalingparameter, s .When s =0,nogroup-levelevents occur.When s> 0,groupssionsandgroupextinctionsoccuratratesproportional to s . Dene f x;y tobethessionrateofan x;y -group. isassionrateparameter andissetto =0 : 0001inallourexamples.Weassumethessionrateisproportional tothegroup'ssize, f x;y = s x + y III.34 31

PAGE 44

Dene e x;y;n tobetheextinctionrateforan x;y -groupinapopulationwith n groups.Theextinctionratefunctionisparameterizedby 1 , 2 , 3 whicharesetto 1 =0 : 1, 2 =0 : 25, 3 =0 : 15inallourexamples. n isthenumberofgroupsnot countingemptygroups.Theextinctionratehastheform, e x;y;n = s 1 n e )]TJ/F21 7.9701 Tf 6.586 0 Td [( 2 x + y + 3 n III.35 Thischoiceofextinctionratefunctionwillresultinanincreasedlikelihoodofextinctionswhentheenvironmentiscrowded n islarge.Smallergroupsarealsomore likelytogoextinct.Additionally,theseparameterstypicallyresultinapproximately 40groupswithapproximately40totalindividualspergroup. Inthefollowingexamples,wewillbeexaminingthexationtimesfordierent choicesofbirthratefunctions,aswellasdierentchoicesofthemigrationrateparameter, ,andthegroup-leveleventratescalingparameter, s .Ineachcase,the initialenvironmentwillbesettoinclude40groupsof20cooperatorsand20defectorsandthexationtimewillbethetimeuntileachgrouphasonlycooperatorsor onlydefectors. Example1:NeutralSelection Inthisrstcase,thebirthrateofcooperatorsanddefectorsareequalandstate independent: b c x;y = b d x;y =0 : 06.Whengroup-leveleventsandmigrationsare notpresent,theinnitesimalgeneratorofthisMarkovprocesscanbeusedtocalculate theprobabilityasinglegroupxeswithallcooperatorsoralternatively,alldefectors andthemeanxationtime, E [ F ],fortheinitialstateof40groupswith20cooperatorsand20defectors.Inthisneutralselectionsetting,groupsareequallylikelytox withallcooperatorsoralldefectorsandtheexpectedxationtimefortheenvironmentof40groups,calculatedusingtheinnitesimalgenerator,is E [ F ] 1503 : 4.To conrmthisvalue,10,000simulationswerecompletedanda95%condenceinterval formeanxationtimewasfoundtobe1501 : 3
PAGE 45

usedtoanalyzedtheeectsofmigrationsandgroupleveleventsonthexationtimes. InFig.3.6,simulatedxationtimesareplottedasafunctionofthegrouplevel eventparameter, s ,wherenomigrationstakeplace =0.Thereisadownward trendinxationtimeasthegroupleveleventsparameterisincreasedandthisoccurs asextinctionsbecomemorecommon.As s isincreased,ssionsandextinctions areincreased,andinthisselectionofparameters,thesteadystateenvironmentis approximately20{30groups.Asaresult,moregroupleveleventstypicallyresults infewergroupswhichinturnresultsinasmallerxationtimesincefewergroups needtox. Figure3.6:Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andnomigrations, =0 33

PAGE 46

InFig.3.7,simulatedxationtimesareplottedasafunctionofthelogmigration rateparameter,log ,wherenogroupleveleventsoccur.Sincenogrouplevel eventsoccur,theenvironmentalwaysincludestheinitialconditionof40groups.An interestingrelationshipisseenbetweenmigrationratesandxationtimes.When migrationsratesarelow,thereislittleinteractionbetweenthegroups. Figure3.7:Simulatedxationtimesasafunctionofthemigrationrateparameter, ,andnogrouplevelevents, s =0 Inthisexample,abouthalfofthegroupsxwithallcooperatorsandabout halfofthegroupsxwillalldefectors.Asthemigrationrateincreases,thereisa 34

PAGE 47

homogenizingeectonthegroups,wheregroupstendtohavesimilarcompositions ofcooperatorsanddefectors.Withanincreaseinmigration,somegroupsinitially xwithonetypeofindividual,butthengetamigrantoftheoppositetypeandare nolongerxed.Thiscausesxationtimestoincrease.Whenthemigrationrateis highenough,groupsareallnearlyidenticalandtheenvironmentconsistsof40groups slowlymovingtowardeitherallcooperatorsoralldefectors.Sincethecomposition ofthegroupsissosimilar,thereappearstobeaslightdecreaseinxationtimein comparisontoasmallermigrationrate. Figure3.8:Simulatedxationtimesasafunctionofthemigrationrateparameter, ,andgroupleveleventsparameter, s neutralselection 35

PAGE 48

Finally,ingure3.8,simulatedxationtimeswereanalyzedasafunctionof thelogmigrationrateparameter,log ,andthegroupleveleventsparameter, s . Thisdatawassmoothedusingthird-orderpolynomialregressiononthecovariates. Asomewhatmorecomplicatedrelationshipbetweenthecovariatesandxationtime isnoted.Estimatedxationtimesarelowestforalowrateofmigrationandahigh rateofgrouplevelevents.Ontheotherhand,whengroupleveleventsarelow andmigrationsarerelativelyfrequent,xationtimesareatthehighest.Inaddition, xationtimesarehighestunderthechoiceofparametersthattendtofavoralldefector groupsandarelowestunderthechoiceofparametersthatfavorallcooperatorgroups. Example2:WeakSelection Inthissecondcase,thebirthratesofcooperatorsanddefectorsarestateindependent,butnon-equalwithasmalldierenceinmagnitude: b c x;y =0 : 059, b d x;y =0 : 06.Withnomigrationsorgroup-levelevents,itwasfoundthat42.2%of groupswouldxwithallcooperatorsandthemeanxationtimeforallgroupswould be E [ F ] 1488 : 8.In10,000simulations,42.1%ofgroupsxedwithallcooperators anda95%condenceintervalforthemeanxationtimewas1481 : 7
PAGE 49

Figure3.9:Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andnomigrations, =0weakselection 37

PAGE 50

Figure3.10:Simulatedxationtimesasafunctionofthemigrationrateparameter, ,andnogrouplevelevents, s =0weakselection 38

PAGE 51

Figure3.11:Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andmigrationrateparameter, weakselection Example3:PublicGood'sGame#1 Inthepreviousexamples,perbirthratesforcooperatorsanddefectorswere constantstateindependent.Itisalsopossibletomodelstatedependentbirth rates,e.g.,asafunctionofpayoinagameplayedwithotherindividualsinthe samegroup.Forthefollowingexample,birthratesarebasedontheaveragepayo forindividualsinaPublicGoodsGame.Birthratesforcooperatorsanddefectors 39

PAGE 52

inagroupareafunctionoftheindividual'stypecooperatorordefectorandthe compositionoftheindividual'sgroup.Forgroupwith x cooperatorsand y defectors, thepercapitabirthrateofacooperatorisasfollows. b c x;y = 1 + 2 x x + y )]TJ/F20 11.9552 Tf 11.956 0 Td [( 3 III.36 andthepercapitabirthrateofadefectoris b d x;y = 1 + 2 x x + y III.37 Inotherwords,thereisabaselinebirthrateof 1 whichisincreasedby 2 times thefractionofthegroupthatiscooperators.Thedierencebetweencooperatorsand defectorsisthatcooperatorshavetopayacost, 3 ,forcooperating,whiledefectors donot.Forthefollowingexample, 1 =0 : 04, 2 =0 : 05,and 3 =0 : 005.Using thesamesetofinitialconditions,asthepreviousexamples,with40groupsof20 cooperatorsand20defectors,theinitialbirthratesofcooperatorsanddefectors are0 : 06and0 : 065respectively.Whengroup-leveleventsandmigrationsarenot present,theinnitesimalgeneratorcanbeusedtocalculatetheexpectedxation time E [ F ] 1228 : 6andtheprobabilityagroupxeswithallcooperators.1%. Thesenumberswereveriedwith10,000simulationsthatfounda95%condence intervalformeanxationtimetobe1218 : 8 )]TJ/F15 11.9552 Tf 9.299 0 Td [(3,migrationsbecomecommonplaceenough thatgroupsbeingtoalllooksimilar.Inthelimit,allgroupshaveequalcomposition ofcooperatorsanddefectorsandthereisaslightdecreaseinxationtime. 40

PAGE 53

Figure3.12:Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andnomigrations, =0 41

PAGE 54

Figure3.13:Simulatedxationtimesasafunctionofthemigrationrateparameter, ,andnogrouplevelevents, s =0 42

PAGE 55

Whenmigrationsandgroup-leveleventsarepresent.14,xationtimesare highestwhenthemigrationrateishighandgroupstendtoxwithalldefectors. Whenthemigrationrateismoderateandthegroup-leveleventsparameterishigh, xationtimesarelowestandgroupstendtoxwithallcooperators. Figure3.14:Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andmigrationrateparameter, 43

PAGE 56

Example4:PublicGood'sGame#2 Example#4usesthesameparametersasexample#3exceptthat 3 =0 : 01 withallotherparametersremainingthesame.Theincreasein 3 decreasesthebirth ratesofcooperatorsbuthasnoimpactonthebirthratesofdefectors.Theresultof thischangeisthatcooperatorstendtobelesslikelytoxandforsomechoicesof parametersthisresultsinlowerxationtimes. Figure3.15:Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andnomigrations, =0 44

PAGE 57

Figure3.16:Simulatedxationtimesasafunctionofthemigrationrateparameter, ,andnogrouplevelevents, s =0 45

PAGE 58

Figure3.17:Simulatedxationtimesasafunctionofthegroupleveleventsparameter, s ,andmigrationrateparameter, 46

PAGE 59

OtherStandardGames Therearechoicesofbirthratefunctionsthatresultinxationoccurringmuch morequicklyormuchmoreslowlythanfortheexamplesconsideredabove.Consider thegeneral2-player,2-strategygamewithpayomatrix, P = 0 B @ cd cRS dTP 1 C A III.38 whereforconveniencewecallthestrategiescooperateanddefect.Birthratesfor individualsinthegroupcanbemodeledasproportionaltotheexpectedpayofora gameagainstarandomopponentfromthegroup, b d x;y = R x x + y + S y x + y III.39 b c x;y = T x x + y + P y x + y III.40 where isascalingparameter. When R =3 ;S =1 ;T =5 ;P =0,thegameisPrisoner'sDilemmawhere defectorshaveahigherbirthrateineverygroup.However,asiswellknown,if cooperativegroupshaveanadvantageoverless-cooperativegroupse.g.,asmaller extinctionratethencooperationcanthriveinthepopulation. If = 1 40 andthesameinitialconditionsareusedasinthepreviousexamples, theninitially, b c x;y =0 : 0375and b d x;y =0 : 075.Theaveragepercapitabirth ratehenceis0.05625whichisapproximatelyequaltothepreviousexamples.10,000 47

PAGE 60

simulationswerecompletedforthischoiceofgameandparametersanda95%condenceintervalforthemeanxationtimewascalculatedtobe274 : 4
PAGE 61

a t =10 b t =100 c t =1000 d t =10000 Figure3.18:Stateoftheenvironmentforsnowdriftexamplewithmigration 49

PAGE 62

Conclusions StudyingxationtimesofconstrainedpopulationmodelssuchastheMoran processcangivesomeinsightsintoxationtimesforunconstrained,morecomplex populationmodels.Inthecasewhereanenvironmentismodeledby N independent continuous-timeMoranprocesseseachwithtotalpopulation K ,xationtimesgrow linearlyasafunctionofgroupsize K andthenumberofgroups N .Inaddition, whenbirthratesareasymmetric,xationtimeshavealogarithmiclimitinwhich xationtimesdecreaseforhigherlevelsofbirthrateasymmetry. Studyingxationtimesdynamicpopulationmodelssuchastheonegiveninsection3diersfromtheconstrainedmodelsliketheMoranprocessinthatdynamic modelshavetime-varyingpopulationsizesandtime-varyingnumberofgroups.However,liketheMoranprocess,xationtimesinthedynamicpopulationmodelare aectedbytheasymmetryofindividualbirthrates.Whenbirthratesarexedand equalsymmetric,meanxationtimesarehigherthanwhenbirthratesarexed andnon-equal. Birthratescanalsobemodeledastheexpectedpayoutfromagamesuchas Prisoner'sDilemmaorSnowdrift.InthecaseofPrisoner'sDilemma,thereisan asymmetryinbirthrates,asdefectorswillalwayshaveahigherbirthratethan cooperatorsinthesamegroup.Whilethisseemstomakedefectorsfavoredover cooperators,groupswithahigherproportionofcooperatorshave,overall,higherbirth rates.Asaresultofthisbalancebetweendefectorshavingtheupperhandwithinany groupandgroupswithahigherproportionofcooperatorshaveadistinctadvantagein higherbirth,migrationsandgroup-leveleventshaveasignicantimpactonxation times.IntheexamplesusingPrisoner'sDilemmathatwerepresented,highergroupleveleventrateswereassociatedinanincreasedlikelihoodthatanygivengroupxed 50

PAGE 63

withallcooperators.Migrationtendstodotheoppositeinthesemodelsashigher migrationratestendtomakegroupsmorelikelytoxwithalldefectors.Fixation timeshaveamorecomplicatedrelationshipwiththesevariables. BeyondPrisoner'sDilemma,xationisnoteveneasilyobtainableforcaseswhere birthratesarebasedonagamesuchasSnowdriftwhereneithercooperatornor defectorsareanevolutionarystablestate. 51

PAGE 64

IV.MULTIPLELEVELSOFCOOPERATION GeneralizingtoMoreThanTwoTypesofIndividuals Upuntilthispointofthestudy,resultsfromthethreemodelshavebeenanalyzed anddiscussedwhentherearetwotypesofindividuals.Inthissection,wewillexplore theeectofhavingmorethantwotypesofindividualsandinparticular,individuals willhaveaxedcooperationlevelfrom0%cooperationpuredefectorto100% cooperationpurecooperator.Severalquestionscanbeexploredwiththismore generalizedmodel.Doenvironmentswithtwotypesofindividualscooperatorsand defectorshavesimilarpopulationdynamicscomparedtoenvironmentswithmany typesofindividualscooperators,defectors,andpartialcooperator/defectors.Does addingadditionallevelofintermediatecooperationchangethesteady-stategroup populationdistribution?Doesmultiplelevelsofcooperationleadtocooperation evolvingmorequicklyordoesit,infact,hindertheevolutionofcooperation? Thehybridmodelwillbeusedtoexplorethesequestionsofmultiplelevelsof cooperationfortworeasons.First,increasingthenumberoftypesofindividuals increasescomputationslinearlyandsincethehybridmodelismorecomputationally ecientthanthesimulationmodel,thehybridmodelmakessensetocompletethese morecomputationallyintensivecalculations.Second,ourmaingoalhereistostudy theoveralleectsofmultiplelevelsofcooperationonthepopulationdynamics,so sincethehybridsolutionbetterillustratestheoveralldriftofthepopulation,itis againpreferredtothesimulationmodelforthisapplication. ComputingBirthRateswhen k> 2 Whilethereareaninnitenumberofmethodstomodeleventrateswhenmore thantwotypesofindividualsarepresent,wewillusetheconceptof eectivecooperators and eectivedefectors .Supposeourmodelhas k typesofindividualsdistributed evenlyfrom0%cooperationpuredefectorto100%cooperationpurecooperator. Denethecooperationcoecientfortype i tobe c i = i )]TJ/F18 7.9701 Tf 6.587 0 Td [(1 k )]TJ/F18 7.9701 Tf 6.586 0 Td [(1 i 2f 1 ;:::;k g , c 2 [0 ; 1], 52

PAGE 65

whereatype-1"individualisapuredefector c 1 =0,andatypek "individualis apurecooperator c k =1.Wedenethenumberofeectivecooperators, n ec ,and thenumberofeectivedefectors, n ed ,foragroupwith N individualsof k typeswith n i individualsoftype i asfollows. n ec = k X i =1 c i n i IV.1 n ed = k X i =1 )]TJ/F20 11.9552 Tf 11.955 0 Td [(c i n i = N )]TJ/F20 11.9552 Tf 11.955 0 Td [(n ec IV.2 n ed + n ec = N = k X i =1 n i IV.3 Forexample,supposeagroupof60individualsconsistsof n 1 =10puredefectors c 1 =0, n 1 =20half-defector/half-cooperators c 2 =1 = 2,and n 3 =30pure cooperators c 3 =1.Aquickcalculationshowsthatthisgrouphas20eective defectorsand40eectivecooperators. Usingthissetup,eventratescanbecalculatedverysimilarlyasbeforewhere n ec and n ed aresubstitutedfor n c and n d inthecorrespondingformulasfordeathrates, groupextinctionrates,andgroupssionrates.Linearinterpolationcanbeusedto ndbirthratesofindividualswithcooperationcoecient c i ,i.e., b i = b d + c i b c )]TJ/F20 11.9552 Tf 11.955 0 Td [(b d IV.4 where b d isthebirthrateofadefectorand b c isthebirthrateofacooperator. ComputingtheMutationMatrixwhen k> 2 Theonlyadditionaldetailthatneedstobeaddressedishowtomodelmutations. Whenmodelingthepopulationdynamicsofanenvironmentwithtwotypesofindividuals,amutationprobabilityof =0 : 05meansthat5%birthsbycooperatorsare defectorsand5%ofbirthsbydefectorsarecooperators.Themutationmatrixfortwo 53

PAGE 66

typesofindividualsandaxedmutationprobabilityof =0 : 05isgivenasfollows. M = 0 B @ dc d 0 : 950 : 05 c 0 : 050 : 95 1 C A IV.5 Whentherearemorethantwotypesofindividuals k> 2,wecanstillmodel 5%mutationsbutwemustdecidehowtosplitthat5%betweentheother k )]TJ/F15 11.9552 Tf 12.907 0 Td [(1 individuals.Let M =[ m ij ]bethemutationmatrix,where m ij = P type j born j type i birthparentIV.6 Withaxedmutationrate , m ii =1 )]TJ/F20 11.9552 Tf 10.774 0 Td [( i 2f 1 ;:::;k )]TJ/F15 11.9552 Tf 11.955 0 Td [(1 g and P k )]TJ/F18 7.9701 Tf 6.587 0 Td [(1 i =0 m ij =1. Theeectsofchoosingdierentmutationprobabilitymassfunctionswillbeexploredlaterinthischapter,butrst,somepossiblemutationprobabilitymassfunctionswillbeintroduced. MutationMatrixMethod#1Gaussian: Therstmethodforcomputingthemutationmatrixwhen k> 2withaxed mutationrateusesaGaussiannormalrandomvariableprobabilitydensityfunction. Thismethodrequirestwoparameters,thexedmutationrate andamutation varianceparameter 2 .Let x;c i ; 2 = 1 p 2 2 e )]TJ/F19 5.9776 Tf 7.782 4.432 Td [( x )]TJ/F22 5.9776 Tf 5.756 0 Td [(c i 2 2 2 betheprobabilitydensity functionofanormalrandomvariablewithmean c i andvariance 2 evaluatedat x . Themutationmatrixforthismethodcanbecomputedasfollows. m ij = 8 > > < > > : 1 )]TJ/F20 11.9552 Tf 11.955 0 Td [(i = j c j ;c i ; 2 P i 6 = j c j ;c i ; 2 i 6 = j IV.7 Forexample,if k =6, =0 : 5,and 2 =0 : 1,thentheentriescorrespondingtoa typei birthareplottedingure4.2for i =1 ; 2 ;:::; 6andthecorrespondingmutation 54

PAGE 67

a i =1 b i =2 c i =2 d i =4 e i =5 f i =6 Figure4.1:MutationProbabilitiesfor i =0 ; 1 ;:::; 5MutationMethod#1 matrix M ispresentedinequationIV.8.Note =0 : 5waschosenforvisualization purposes;typically,modelsweresimulatedwith =0 : 05. M = 2 6 6 6 6 6 6 6 6 6 6 6 6 6 6 4 0 : 5000 : 2760 : 1520 : 0560 : 0140 : 002 0 : 1790 : 5000 : 1790 : 0980 : 0360 : 009 0 : 0830 : 1520 : 5000 : 1520 : 0830 : 031 0 : 0310 : 0830 : 1520 : 5000 : 1520 : 083 0 : 0090 : 0360 : 0980 : 1790 : 5000 : 179 0 : 0020 : 0140 : 0560 : 1520 : 2760 : 500 3 7 7 7 7 7 7 7 7 7 7 7 7 7 7 5 IV.8 MutationMatrixMethod#2Geometric: Thesecondmethodforgeneratingamutationmatrixwithaxedmutationprobability issimilartotherstmethodexceptthatageometricrandomvariableis usedinsteadofanormalrandomvariablewithparameter p .Let x;i;p = p j x )]TJ/F21 7.9701 Tf 6.587 0 Td [(i j , where x =1 ; 2 ;:::;k and p 2 ; 1.Themutationmatrixusingthesecondmethod 55

PAGE 68

iscomputedasfollows. m ij = 8 > > < > > : 1 )]TJ/F20 11.9552 Tf 11.955 0 Td [(i = j c j ;c i ;p P i 6 = j c j ;c i ;p i 6 = j IV.9 Forexample,if k =6, =0 : 5,and p =0 : 5,thentheentriescorresponding toatypei birthareplottedingure4.2for i =1 ; 2 ;:::; 6andthecorresponding mutationmatrix M ispresentedinequationIV.12. a i =1 b i =2 c i =3 d i =4 e i =5 f i =6 Figure4.2:MutationProbabilitiesfor i =0 ; 1 ;:::; 5MutationMethod#2 M = 2 6 6 6 6 6 6 6 6 6 6 6 6 6 6 4 0 : 5000 : 2580 : 1290 : 0650 : 0320 : 016 0 : 2580 : 5000 : 2580 : 1290 : 0650 : 032 0 : 1290 : 2580 : 5000 : 2580 : 1290 : 065 0 : 0650 : 1290 : 2580 : 5000 : 2580 : 129 0 : 0320 : 0650 : 1290 : 2580 : 5000 : 258 0 : 0160 : 0320 : 0650 : 1290 : 2580 : 500 3 7 7 7 7 7 7 7 7 7 7 7 7 7 7 5 IV.10 56

PAGE 69

MutationMatrixMethod#3Uniform: Thethirdmethodforgeneratingamutationmatrixwithaxedmutationprobability istomakeallmutationsequallylikely.Usingthissetup,themutationmatrix iscalculatedasfollows. m ij = 8 > > < > > : 1 )]TJ/F20 11.9552 Tf 11.955 0 Td [(i = j k )]TJ/F18 7.9701 Tf 6.586 0 Td [(1 i 6 = j IV.11 a i =1 b i =2 c i =3 d i =4 e i =5 f i =6 Figure4.3:MutationProbabilitiesfor i =0 ; 1 ;:::; 5MutationMethod#3 M = 2 6 6 6 6 6 6 6 6 6 6 6 6 6 6 4 0 : 50 : 10 : 10 : 10 : 10 : 1 0 : 10 : 50 : 10 : 10 : 10 : 1 0 : 10 : 10 : 50 : 10 : 10 : 1 0 : 10 : 10 : 10 : 50 : 10 : 1 0 : 10 : 10 : 10 : 10 : 50 : 1 0 : 10 : 10 : 10 : 10 : 10 : 5 3 7 7 7 7 7 7 7 7 7 7 7 7 7 7 5 IV.12 57

PAGE 70

Thechoiceofmutationmethodisuptothemodeleranddependingontheapplication,onemethodmaybemoreappropriatethantheothers.Inparticular,the varianceofmutationprobabilitymassfunctionsdier,soitmustbedeterminedhow quicklytheprobabilityofmutationsapproachzeroas j i )]TJ/F20 11.9552 Tf 11.955 0 Td [(j j increases. Twoexampleswillnowbepresentedshowingtheeectsofincreasingthenumber oflevelsofcooperation.Note:hyperlinkstovideosolutionsareavailableatendof eachexamplesection. 58

PAGE 71

Example1:PublicGoodsGame Webeginexplorationoftheeectsofmultiplelevelsofcooperationbyexploringa modelthatusestheexpectedpayoutinapublicgoodsgametodeterminepercapita birthrateswithbirthmutationprobabilityof =0 : 05. b c =0 : 04+0 : 05 n ec N )]TJ/F15 11.9552 Tf 11.955 0 Td [(0 : 015IV.13 b d =0 : 04+0 : 05 n ec N IV.14 Percapitadeathratesaremodeledasproportionaltothegroupsize. d c = d d =0 : 0008 N IV.15 Notethattotaldeathrateforindividualsoftype i isangroupisthepercapita deathratemultipliedbythenumberofindividualsoftype i .Asaresult,thetotal deathrateinagroupgrowsquadraticallywithgroupsize. Intheexample,groupssionratesareproportionaltothenumberofeective cooperatorsandthenumberofeectivedefectors,whereanincreaseinthenumber ofeectivedefectorsresultsinahighergroupssionratethananequalincreasein thenumberofeectivecooperators. f i =0 : 0008 n ec +0 : 0014 n ed IV.16 Groupextinctionratesareafunctionofthenumberofgroupsintheenvironment andgroupsize. e i =0 : 02 n g e )]TJ/F18 7.9701 Tf 6.586 0 Td [(0 : 2 N IV.17 Usingthissetup,cooperatorshavealowerbirthratethandefectorswithinthe samegroup,butgroupswithalargerproportionofcooperatorshavehigherindividual birthratesoverallcomparedtogroupswithalargerproportionofdefectors.Groups 59

PAGE 72

withahigherpopulationofdefectorsaremorelikelytossion.Also,asthenumber ofgroupsintheenvironmentincreases,thereisanincreaseingroupextinctionrates andsmallergroupsaremorelikelytossion. Thismodelwillrstbeanalyzedwhenthereare k =2typesofindividualsusing theinitialconditionsof50groupsconsistingof10cooperatorsand40defectorswith =0 : 05probabilityofmutation.Theseresultswillbecomparedtotheresultsfor when k> 2. ThePDEsolutionofthismodel,referencedinchapter2,wasrstpresentedin SimonandNielsen[21]andisshowningure4.4.Itshowshowaninitial environmentofpredominantlydefectorscanslowlymorphintoanenvironmentof predominantlycooperators. a t =0 b t =5 c t =7 d t =9 e t =12 f t =20 Figure4.4:Stateoftheenvironmentattime t usingthedeterministic/PDEmodel Beforeexaminingtheresultsofthehybridmodel,somestatisticswillbedened forthehybridmodelthatwillbeofinteresttocomparefordierentvaluesof k . Let c i betheaveragegroupcooperationrateforgroup i with n i individualsof 60

PAGE 73

type i ,i.e., c i = N X i =1 c i n i IV.18 Let C betheglobalaveragegroupcooperationrate,thatis,theaveragepercent cooperationlevelacrossallalivegroupsintheenvironment. C = n g X i =1 c i IV.19 C canbeestimatedfromasinglehybridsimulationbyrunningthesimulationfor longenoughtoassuretheenvironmentreachessteady-state"andthentakingthe averageoftheglobalcooperationrateforthelast10%ofthesimulation. Similarly,theaveragenumberofgroups, n g insteady-state"canbecalculatebytakingtheaverageofthenumberofgroupsforthelast10%ofthesimulation.Iftheenvironmenthas n g t groupsattime t andthesimulationisover t 2f 0 ; t; 2 t;:::;t end g ,then n g canbecalculatedasfollows. n g = P t 2 : 9 t end ;t end ] n g t P t 2 : 9 t end ;t end ] 1 IV.20 Theglobalcooperationstandarddeviationcanbeestimatedfromthesteadystatedistributionattheendofthesimulation,where N i isthenumberofindividuals oftype i intheentireenvironment. s C = q s 2 C = k X i =1 c i N 2 i )]TJ/F26 11.9552 Tf 11.955 20.444 Td [( k X i =1 c i N i ! 2 IV.21 Thehybridmodelwasrunfor k =2typesandmutationprobability =0 : 05with theinitialconditionsof50groupswith40defectorsand10cooperatorswhichhasan initialglobalgroupcooperationrate C =20%.By t =1000,thehybridmethodhas anapproximateglobalgroupcooperationrateof58 : 4%,asignicantincreasefromthe startingcondition.Additionally,itwascalculatedthat s c =49 : 3%and n g =604 : 6 groups.Ingure4.5,thestateoftheenvironmentat t =1000isdisplayedasa scatterplotinaandasaheatmapinc.Ahistogramofthedistributionofthe 61

PAGE 74

twotypesofindividualareplottedinbandthenumberofgroupsasafunctionof timeisplottedind. aStateoftheenvironment bHistogramofindividualtypes cHeatmapofstateoftheenvironment dNumberofgroupsasafunctionoftime Figure4.5:Hybridmodelresultsforpublicgoodsgameexampleat t =1000 k =2 Ofparticularnoteisthatthehybridsimulationproducesasteady-statepopulationthatisconsistentwiththePDEmodel.Bothmodelsshowanenvironmentthat isinitiallydominatedbydefectorsthatslowlyevolvestohaveamixedpopulation withasignicantlyhigherproportionofcooperators. Thehybridmodelwasnextrunfor k =3,sotheenvironmenthaspuredefectors c 1 =0,half-cooperator/half-defectors c 2 =1 = 2,andpurecooperators c 3 =1. Additionally,therewasaxed5%mutationprobability,wherethemutationmatrix wascomputedusingtheGaussianmethod 2 =0 : 01.Theresultsareplottedin 62

PAGE 75

aStateoftheenvironment bHistogramofindividualtypes cHeatmapofstateoftheenvironment dNumberofgroupsasafunctionoftime Figure4.6:Hybridmodelresultsforpublicgoodsgameexampleat t =1000 k =3 ?? .Withthreetypesofindividuals,theestimatedglobalcooperationaveragerate C =48 : 5%whichislowerthan C =58 : 4%for k =2.Insteady-state,groupstend tohavefewereectivecooperatorswhen k =3comparedtowhen k =2.Aswill beseen,increasing k resultsinaloweraverageglobalgroupcooperationrateforthis scenario. Theestimatedglobalcooperationstandarddeviationfor k =3is38 : 5%,adecreasefrom49 : 5%when k =2,andtheaveragenumberofgroupsatsteady-statefor k =3wasestimatedtobe603.1for k =3,asmalldecreasefromanestimated604.6 groupsatsteady-statewhen k =2. Thehybridmodelwasalsorunfor k =5gure4.7, k =10gure4.8, k =100 63

PAGE 76

gure4.7andtheresultsaresummarizedintable3.Infact,as k increases,the globalcooperationaveragedecreases,theglobalcooperationstandarddeviation,and theaveragenumberofgroupsatsteady-statedecreases. aStateoftheenvironment bHistogramofindividualtypes cHeatmapofstateoftheenvironment dNumberofgroupsasafunctionoftime Figure4.7:Hybridmodelresultsforpublicgoodsgameexampleat t =1000 k =5 Thisphenomenonthatcooperationis,infact,hinderedbyincreasingthenumber oflevelsofcooperationseemssomewhatcounterintuitiveandrequiresexplanation. When k =2,globalcooperationslowlyincreasesassomemajoritydefectorgroups ssionintosmallmajoritycooperatorgroupsbychanceandthesegroupsrapidly increasepopulationuntiltheyapproachpeakcapacity.Sincethedeathrateincreases quadraticallywithgroupsize,thereisanaturallimitonhowlargegroupscanget. Thespeedatwhichthecooperatorsareabletoreproduceinthesegroupsexceeds 64

PAGE 77

aStateoftheenvironment bHistogramofindividualtypes cHeatmapofstateoftheenvironment dNumberofgroupsasafunctionoftime Figure4.8:Hybridmodelresultsforpublicgoodsgameexampleat t =1000 k =10 Table3.:Steady-statestatisticspublicgoodsgame Numberof Types k GlobalCoop. Average C GlobalCoop. Std.Dev. s C AverageNumber ofGroups n g 2 58.4 49.3 604.6 3 48.5 38.5 603.1 5 31.7 27.5 335.1 10 15.1 13.3 181.1 100 7.2 7.4 156.7 65

PAGE 78

aStateoftheenvironment bHistogramofindividualtypes cHeatmapofstateoftheenvironment dNumberofgroupsasafunctionoftime Figure4.9:Hybridmodelresultsforpublicgoodsgameexampleat t =1000 k =100 therateatwhichdefectorsareableto.Astheseheavycooperatorgroupsapproach peakcapacity,thelikelihoodofassionincreasesandwhenthesemajoritycooperator groupsssion,thenewlyformedgroupsalsotendtobemajoritycooperator.When agroupsizereachesthispeakcapacity,defectorsslowlythriveattheexpenseof cooperators.Barringassion,thegroupwilleventuallyagainobtainamajorityof defectorsandthecyclewillbeginagain. Themutationmatrixplaysacriticalrolewhen k> 2.When k =2,eventhough defectorshaveahigherbirthratethancooperators,since =0 : 05,5%ofbirths bypure-defectorsarepure-cooperatorsandviceversa.When k isincreased,the mutationmethodtendstoresultinmutationsthatareclosertothecooperationlevel 66

PAGE 79

a k =2 b k =3 c k =10 d k =100 Figure4.10:Comparisonofsteady-statedistributionsfordierentvaluesof k oftheparenti.e.,mutantsofpure-defectorsstilltendtohavealowercooperation coecient,whereaswhen k =2amutantbirthofpure-defectorisapure-cooperator. Asaresult,when k increases,mutantbirthsfromdefectorsaretypicallystillhavea lowcooperationcoecientresultinginlesscooperation.This,inturn,meansthat fewcooperatormajoritygroupsresultfromssionsandinstead,groupssionsthat doresultinsomegroupswithintermediatelevelsofcooperationmorequicklyreturn tomajoritydefectorgroupsthanifthosegroupshadpure-cooperators. Inadditiontotherolethatthemutationmatrixplaysinthisinterestingphenomenon,addingtheintermediatelevelsofcooperationresultsinalowerglobalcooperationvariance,sothereismuchlessvariabilityingroupcompositionsthanwhen 67

PAGE 80

k =2.Inotherwords,increasing k hasahomogenizingeectongroupcompositions, i.e.,groupstendtohaveasimilarnumberofeachtypeofindividual. Linkstosupportingvideosforexample1: PDEsolution: https://youtu.be/JwJY4RHjeHk Hybridsolution,k=2: https://youtu.be/BPBDZqi1GCk Hybridsolution,k=3: https://youtu.be/5U6f_uvis9g Hybridsolution,k=5: https://youtu.be/Hv1UVdo73v8 Hybridsolution,k=10: https://youtu.be/n5qmSUOhFUo Hybridsolution,k=100: https://youtu.be/LDHnRLDw5A0 Example2:Snowdrift Asdiscussedinchapter2,birthratescanalsobemodeledasproportionalto theexpectedpayoutinagame.Consideratwo-player,two-strategygamewiththe payoutmatrix, P . P = 0 B @ cd cRS dTP 1 C A IV.22 Birthratesforcooperatorsanddefectorscanbecalculatedfromthispayout matrix. b c x;y = R x x + y + S y x + y IV.23 b d x;y = T x x + y + P y x + y IV.24 where isascalingparameter, x isthenumberofcooperators,and y isthenumber ofdefectors. When R = b )]TJ/F21 7.9701 Tf 14.635 4.707 Td [(c 2 , S = b )]TJ/F20 11.9552 Tf 13.157 0 Td [(c , T = b ,and P =0,thenthegameiscalled snowdrift.Thesnowdriftgamehasanevolutionarystablestatewithcooperatorsand defectors,sowewouldexpectamixturedistributionofcooperatorsanddefectorsat steady-state. 68

PAGE 81

Let b =2and c =1,so R =3 = 2 ;S =1 ;T =2 ;P =0aretheentriesareofa payomatrixcorrespondingtoagameofsnowdrift.Thesevalueswillbeusedforthe followingexamplealongwithscalingparameter = 1 18 .Usingthesevalues,weget thefollowingbirthratesforcooperatorsanddefectorsinagroupwith n ec eective cooperators, n ed eectivedefectors,and N = n ec + n ed totalindividuals. b c = 1 12 n ec N + 1 18 n ed N IV.25 b d = 1 9 n ec N IV.26 Theprobabilityofmutationisxedto =0 : 05andthepercapitadeathrates areagainmodeledasproportionaltogroupsizealbeitwithadierentdeathrate parameter, =0 : 0015. d c = d d =0 : 0015 N IV.27 Intheexample,groupssionratesareproportionaltothenumberofeective cooperatorsandthenumberofeectivedefectors,butunlikeexample1,cooperators anddefectorsequallycontributetothessionrate. f i =0 : 0001 n ec +0 : 0001 n ed =0 : 0001 N IV.28 Groupextinctionratesaremodeledexactlyliketherstexampleinthischapter asafunctionofthenumberofgroupsintheenvironmentandgroupsize. e i =0 : 02 n g e )]TJ/F18 7.9701 Tf 6.586 0 Td [(0 : 2 N IV.29 Recallthatthesimulationmethodwasrunforthisexactscenarioinsection3.2.5 andhadapproximatelyaratiooftwocooperatorsforeveryonedefectorwhichequates to C =67%. Thehybridmodelwasrunfor k =2withaninitialconditionof50groupswith 20puredefectorsand20purecooperatorsgure4.11.Acoupleofinteresting observationscanbemade.First,theenvironmentquicklyreachessteady-stateby 69

PAGE 82

aStateoftheenvironment bHistogramofindividualtypes cHeatmapofstateoftheenvironment dNumberofgroupsasafunctionoftime Figure4.11:Hybridmodelresultsforsnowdriftexampleat t =1000 k =2 approximately t =200withaglobalgroupcooperationlevelof C =63%which closelymatchesthesimulationresultsfoundinchapter3.Second,thesteady-state distributionofgrouppopulationshasverylittlevariation,thatis,mostgroupsare concentratedaround n ec ;n ed =30 ; 18whichequatestoagroupcooperationrate of63%. Afteranalyzing k =2,thehybridmodelwasrunfor k =3gure4.16, k =5 gure4.13, k =10gure4.14,and k =100gure4.15.Forallthesevaluesof k andforlargevaluesof t ,mostgroupsagainhaveapopulationofapproximately n ec ;n ed = ; 18.Oncetheyssion,thetwonewlycreatedgroupsquicklyreach steady-state.Also,when k increases, C slightlyincreasestoward67%whichwas 70

PAGE 83

approximatelytheaveragegroupcooperationinthesimulationmodelanalyzedin chapter3. aStateoftheenvironment bHistogramofindividualtypes cHeatmapofstateoftheenvironment dNumberofgroupsasafunctionoftime Figure4.12:Hybridmodelresultsforsnowdriftexampleat t =1000 k =3 Sowhydoesthisexamplehaveaveryconcentratedsteady-stategrouppopulation whilethepreviousexamplewiththepublicgoodsgamehadavariedsteady-state populationdistributionwithsmallvaluesof k ?Itturnsoutthatthereisstronger selection"inthissecondexampleinthatthedierentialbirthrateofdefectorsand cooperatorsisstrongerforthesecondexampleascomparedtotherstexample. Asanumericalexample,supposethereisagroupwith10eectivecooperators and30eectivedefectors.Fortherstexampleinvolvingthepublicgoodsgame,the 71

PAGE 84

aStateoftheenvironment bHistogramofindividualtypes cHeatmapofstateoftheenvironment dNumberofgroupsasafunctionoftime Figure4.13:Hybridmodelresultsforsnowdriftexampleat t =1000 k =5 percapitabirthratesforpurecooperatorsandpuredefectorsaregiven. b c = b 0 + b 1 n ec N )]TJ/F20 11.9552 Tf 11.955 0 Td [(b 2 =0 : 04+0 : 05 10 40 )]TJ/F15 11.9552 Tf 11.955 0 Td [(0 : 015=0 : 0375IV.30 b d = b 0 + b 1 n ec N )]TJ/F20 11.9552 Tf 11.955 0 Td [(b 2 =0 : 04+0 : 05 20 40 =0 : 0525IV.31 Forthepublicgoodsgameexample,defectorsalwayshaveaslightlyhigherbirth ratethandefectors b d )]TJ/F20 11.9552 Tf 12.819 0 Td [(b c =0 : 015andforagroupof20purecooperatorsand 20puredefectors, b c =0 : 05and b d =0 : 065.Ontheotherhand,forthesnowdrift example,thepercapitabirthratesforpurecooperatorsandpuredefectorsdier moresignicantly. b c = 1 12 n ec N + 1 18 n ed N = 1 12 10 40 + 1 18 30 40 =0 : 0625IV.32 72

PAGE 85

aStateoftheenvironment bHistogramofindividualtypes cHeatmapofstateoftheenvironment dNumberofgroupsasafunctionoftime Figure4.14:Hybridmodelresultsforsnowdriftexampleat t =5000 k =10 b d = 1 6 10 40 =0 : 0278IV.33 Forthesnowdriftexample,groupsthatdon'thaveacompositionclosetothe steady-statemeanof n ec ;n ed = ; 18willhavelargerdierentialbirthratebetweencooperatorsanddefectorsthatwillcausethesegroupstoquicklyreachsteadstate.Inthepublicgoodsgameexample,thedierentialbirthrateismuchlowerfor mostchoicesof n ec ;n ed ,sogroupsdon'tconvergetowardssteady-stateasquickly. Usingtheexpectedpayoutsfromagameofsnowdriftisinterestingbecauseit hasaninternalevolutionarystablestate,thatis,atsteady-statetherewillbepure cooperatorsandpuredefectorsfor k =2.Whatthisstudyshowsisthatwhen k isincreased,thereisverysimilarsteady-statepopulationdistributionintermsofeective 73

PAGE 86

aStateoftheenvironment bHistogramofindividualtypes cHeatmapofstateoftheenvironment dNumberofgroupsasafunctionoftime Figure4.15:Hybridmodelresultsforsnowdriftexampleat t =5000 k =100 Table4.:Steady-statestatisticssnowdrift Numberof Types k GlobalCoop. Average C GlobalCoop. Std.Dev. s C AverageNumber ofGroups n g 2 62.8 48.3 183.0 3 63.4 39.1 136.3 5 64.9 33.2 114.3 10 66.0 28.6 173.9 100 66.0 25.8 63.7 74

PAGE 87

cooperatorsandeectivedefectorsbutthemajorityofindividualsatsteady-stateare neitherpure-cooperatorsnorpure-defectors. a k =2 b k =3 c k =10 d k =100 Figure4.16:Comparisonofsteady-statedistributionsfordierentvaluesof k Linkstosupportingvideosforexample2: Hybridsolution,k=2: https://youtu.be/VnrPjcJwStI Hybridsolution,k=3: https://youtu.be/q_3zYArUjOU Hybridsolution,k=5: https://youtu.be/noc5RxaiwlMx Hybridsolution,k=10: https://youtu.be/meF07qrk74w Hybridsolution,k=100: https://youtu.be/mC-1UOtq8V8 75

PAGE 88

Conclusions Multiplelevelsofcooperationcanaecttheoveralldynamicsinmanyinteresting ways.Aswasseenintherstexampleusingthepublicgood'sgame,whilecooperators wereinthemajorityastimeapproachedinnitywhen k =2typesofindividuals, defectorstendedtobeinthemajoritywhenintermediatelevelsofcooperation k> 2 wereintroduced.Forthisexample,multiplelevelsofcooperationseemstoinhibitthe evolutionofcooperationthoughcooperatorsdostillexistastimeapproachesinnity. Ontheotherhand,theexampleinvolvingthesnowdriftgamehadanapproximately 2:1cooperator:defectorratiowhen k =2andwhen k isincreased,theglobalaverage groupcooperationpercentagedoesnotchangemuch.Takentogether,theseexamples showthattheaveragerateofcooperationforgroupscanpotentiallydiersignicantly if k isincreasedasintherstexampleortheaveragerateofcooperationforgroups couldstayapproximatelyequalif k isincreasedasinthesecondexample. 76

PAGE 89

V.FUTUREWORK Thisdissertationexploredtwospecictopicsintwo-levelevolutionarypopulation dynamics,xationtimesandmultiplelevelsofcooperation.Therearenumbersof topicsthatcanberesearchedtobothextendtheresultspresentedhere,aswellas topicsrelatedtoevolutionarypopulationdynamicsnotdiscussedinthisstudy. Themostobviousextensionoftheresearchoutlinedinthispaperistoextendthe PDEmodelandstochasticmodeltoallowformorethan k =2typesofindividuals. First,thePDEmodelwith k> 2couldbestudiedtoseeifthereareanyunique qualitiesthatdon'tshowupinthehybridorsimulationmodel.Forinstance,does thePDEmodelpredictasimilarsteady-statedistributionasthehybridmodel?Does thisextendedPDEmodelagaintofailtopredicteventualxingofthepopulation likethe k =2case?Thiscertainlyseemslikely.Second,ageneralizedsimulation modelfor k> 2couldbeusedtoestimatexationtimeslikechapter3andmaybe moreinterestingly,thetypesofindividualsthatgroupseventuallyxwithcouldbe studied.Inthesnowdriftexampleinchapter4with k =100,pure-cooperatorsare themostcommontypeofindividualwithnearpure-cooperators c i 1beingthe nextmostcommon.Whengroupseventuallyxwithonlyonetypeofindividual,do thesegroupstendtoxwithallpurecooperators?Thisseemslikethemostlikely outcome,butfurtherresearchneedstobecompletedtoverifythis.Itcouldalso bestudiedhowthesteady-statedistributiondiersforwhentheintermediatelevels ofcooperationarenotevenlydistributedbetweenpuredefector c 1 =0andpure cooperator c k =1. Outsideofxationtimesandmultiplelevelsofcooperation,therearemanytangentiallyrelatedtopicsthatcouldbeinvestigated.Howdochoicesof R;S;T;P for apayomatrixaecttheoverallpopulationdynamicswhenbirthratesaremodeled asproportionaltoagame'sexpectedpayout.Underwhatchoicesofthesevariables iscooperationmostlikelyandleastlikelytoevolve?Finally,theultimategoalof thesemodelscouldbetoestimateactualpopulationdynamicsinnature.Thiswould requireestimatingallofthevariouseventparametersanddeterminingwhatgame wouldbemostappropriatetomodelbirthratesobservedinnature. 77

PAGE 90

REFERENCES [1] C.Darwin ,1859. OnTheOriginoftheSpecies ,HarvardUniversityPress, Cambridge. [2] Darwin,C. ,1871. TheDescentofMan .Murray,London. [3] Frank,S. ,1995.GeorgePrice'sContributionstoEvolutionaryGenetics", JournalofTheoreticalBiology , 175 :373-388. [4]Gillespie,D.,1977.ExactStochasticSimulationofCoupledChemicalReactions", TheJournalofPhysicalChemistry , 25 :2340-2361.8. [5] Hamilton,W.D. ,1964.Thegeneticalevolutionofsocialbehaviour", Journal ofTheoreticalBiology . 7 . [6] Keller,L.,Gordon,E. ,2010. TheLivesofAnts ,OxfordUniversityPress, Oxford,England. [7] Majerus,M. ,2008.IndustrialMelanisminthePepperedMoth,Bistonbetularia:AnExcellentTeachingExampleofDarwinianEvolutioninAction", Evolution:EducationandOutreach . 2 :107. [8] McClean,M. ,2014.Datadensityplot," https://www.mathworks.com/ matlabcentral/fileexchange/31726-data-density-plot . [9] Moran,P. ,1958.Randomprocessesingenetics", MathematicalProceedings oftheCambridgePhilosophicalSociety . 54 . [10] Moreland,K. ,2018.DivergingColorMapsforScienticVisualization," http://www.kennethmoreland.com/color-maps/ . [11] Nowak,M.,Tarnita,Wilson,E. ,2010.Theevolutionofeusociality", Nature , 466 :1057{1062. [12] Nowak,M. ,2006. EvolutionaryDynamics .HarvardPress,Boston. [13] Okasha,S. ,2009.EvolutionsandtheLevelsofSelection".OxfordUniversity Press,London. [14] Oksendal,B. ,2003. StochasticDierentialEquations:AnIntroductionwith Applications .Springer,Berlin. [15] Puhalskii,A.,Simon,B. ,2011.Discreteevolutionarybirth-deathprocesses andtheirlargepopulationlimits", StochasticModels , 28 . 78

PAGE 91

[16] Puhalskii,A.,Simon,B. ,2018.Alarge-populationlimitforaMarkovian modelofgroup-structuredpopulations".Unpublishedmanuscriptcurrentlyin submission. [17] Ronan,C. ,1995. TheShorterScienceandCivilisationinChina:AnAbridgement .CambridgeUniversityPress,NewYork. [18] Ross,S. ,2010. IntroductiontoProbabilityModels .Elsevier,SanDiego,CA. [19] Simon,B. ,2010.ADynamicalModelofTwo-LevelSelection", Evolutionary EcologyResearch . 12: 555-588. [20] Simon,B.,Fletcher,J.,Doebeli,M. ,2012.TowardsaGeneralTheory ofGroupSelection", Evolution . 67 :1561-1572. [21] Simon,B.,NielsenA. ,2012.Numericalsolutionsandanimationsofgroup selectiondynamics", EvolutionaryEcologyResearch . 14 :757-768. [22] Sober,E.,Wilson,D.S. ,1998. UntoOthers .HarvardUniversityPress,Cambridge,MA. [23] Spencer,H. ,1864. PrinciplesofBiology .WilliamandNorgate,London. [24] Taylor,C.,Iwasa,Y.,Nowak,M. ,2006.Asymmetryofxationtimesin evolutionarydynamics", JournalofTheoreticalBiology . 243 :245{251. [25] Torrey,H.,Felin,F. ,1937.WasAristotleanEvolutionist?", TheQuarterly ReviewofBiology , 12 :1-18. [26] vanVeelen,M. ,2005.OntheuseofthePriceEquation", JournalofTheoreticalBiology , 237 :412-426. [27] vanVeelen,M.,Garca,J.,Sabelis,M.,Egas,M. .Groupselectionand inclusivetnessarenotequivalent;thePriceequationvs.modelsandstatistics", JournalofTheoreticalBiology , 299 :64-80. [28] Waggoner,B. ,2000.CarlLinnaeus-1778", Evolutiononlineexhibit . UniversityofCaliforniaMuseumofPaleontology,Berkeley,CA. [29] Webster,D. ,2004. TheMerriam-Websterdictionary ,PocketBooks,United States. [30] Wilson,E. ,1975. Sociobiology:TheNewSynthesis .HarvardUniversityPress, Cambridge,MA. [31] Wu,B.,Altrock,P.,Wang,L.,Traulsen,A. ,2010.Universalityof WeakSelection', Phys.Rev.E . 82 . [32] Wynne-Edwards,V. ,1962.AnimalDispersioninRelationtoSocialBehaviour".Oliver&Boyd,London. 79

PAGE 92

APPENDIXA MATLABCODE Author'snote: MATLABwasprimarilyusedinthisstudyforgeneratingdata,runningsimulations,computinganalyticalresults,andcreatingmoviesforexamples. FilenamePageFilenamePage calc_approx_fix.m 81 moran_partial.m 131 calc_multiple_moran_fix_time.m 88 moran_selection.m 134 calc_single_moran_fix_time.m 92 MoranFixDist.m 136 dataDensity.m 94 plot_determ_path.m 139 DataDensityPlot.m 96 plot_dynamics_ipd.m 142 gen_brates_payoff_matrix.m 99 plot_dynamics_pgg.m 145 gen_hybrid_sims.m 101 plot_hybrid.m 151 gen_trans_matrix_simon.m 102 sim_moran.m 160 gen_moran_inf.m 106 sim_pgg_calc_approx_fix.m 162 gen_payoff_matrix.m 107 sim_simon_small_payoff.m 178 hybrid_dist.m 111 sim_simon_small.m 182 hybrid_updated.m 113 simondist.m 186 moran_neutral.m 130 80

PAGE 93

%File:calc_approx_fix.m %functiontorunmultiplesimulationstocalcfixationtimes. 5 out_file=strcatdatestrdatetime'today','.csv'; fid=fopenout_file,'w'; n_sims=5; 10 fix_times=zerosn_sims,1; %param.birth_option=1;%PGG param.birth_option=2; %gamebasedonpayoffmatrix 15 param.payoff=[02;13/2]/18; %snowdrift %param.payoff=[15;03]/40;%prisoner'sdilemma param.max_groups=200; 20 param.initial_groups=40; param.initial_size=40; param.initial_sd=0; param.n_types=2; param.mutant=0; 25 param.b1=0.04; 81

PAGE 94

param.b2=0.05; %originallyb3=0.004 )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(adjustingthisto0.008 %thirdruniswith0.001,now0.005 30 param.b3=0.005; param.d1=0.0015; param.f1=0.0001; param.m1=0.00001; %param.e1=0.2; 35 param.e1=0.1; param.e2=0.25; param.e3=0.015; param.s=1; 40 param.c=0.05; repeat_flag=1; %m1=0:0.0001:0.001; 45 %m1= )]TJ/F55 10.9091 Tf 8.485 0 Td [(6:0.25: )]TJ/F55 10.9091 Tf 8.485 0 Td [(2; m1=-2; n_m1=lengthm1; %s=0:0.1:3; param.group_events=1; 50 n_s=lengths; fix_times=zerosn_m1,n_s; output=zerosn_m1*n_s*n_sims,6; 82

PAGE 95

fprintffid,'s,m1,fixtype,fixtime,ngroups,ndefectgroupsn'; 55 count=1; fprintf'Simulation:n',count; fork=1:n_sims fori=1:lengthm1 60 ifm1i==0 param.m1=0; else param.m1=10^m1i; 65 end forj=1:lengths param.s=sj; %param.s=sj; 70 %param.b1=0.2 rand; %param.b2=0.2 rand; %param.b3=0.02 rand; %param.d1=0.01 rand; 75 %param.f1=0.001 rand; %param.e1=0.5 rand; %param.e2=rand; %param.e3=0.5 rand; %param.mutant=0.05 rand; 80 83

PAGE 96

%param.m1=10^ )]TJ/F55 10.9091 Tf 8.485 0 Td [(6; %param.s=i 0.1; %ifi<43 85 %param.s=0.5 modi )]TJ/F55 10.9091 Tf 8.484 0 Td [(1,7; %param.m1=10^ )]TJ/F55 10.9091 Tf 8.485 0 Td [(0.5 modi )]TJ/F55 10.9091 Tf 8.485 0 Td [(1,6 )]TJ/F55 10.9091 Tf 8.485 0 Td [(3.5; %else %param.s=3 rand; %param.m1=10^ )]TJ/F55 10.9091 Tf 8.485 0 Td [(6 rand; 90 %end %switchi %case1 %param.m1=10^ )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 8.485 0 Td [(rand )]TJ/F55 10.9091 Tf 8.485 0 Td [(4; 95 %param.s=2 rand+1; %case2 %param.m1=10^ )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 8.485 0 Td [(rand )]TJ/F55 10.9091 Tf 8.485 0 Td [(4; %param.s=2 rand+1; %case3 100 %param.m1=10^ )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 8.485 0 Td [(rand )]TJ/F55 10.9091 Tf 8.485 0 Td [(4; %param.s=2 rand+1; %case4 %param.m1=10^ )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 8.485 0 Td [(rand 2 )]TJ/F55 10.9091 Tf 8.485 0 Td [(3; %param.s=2 rand+1; 105 %otherwise %param.m1=round^ )]TJ/F55 10.9091 Tf 8.485 0 Td [(2 rand )]TJ/F55 10.9091 Tf 8.485 0 Td [(2 100000/100000; %param.s=round rand 2+1/100000; 84

PAGE 97

%end 110 %fprintf , ! ' \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000)]TJ/F55 10.9091 Tf 364.85 0 Td [( , ! n'; fprintf... '%dlogm=%1.1f,s=%1.1f,t=',count,m1i,sj; [out]=sim_pgg_calc_approx_fixparam; 115 fix_timescount=out.fixation_time; fprintf'%1.1f,%1.1f%%defectorsn',out.fixation_time,... 100*out.n_defect_groups/out.n_alive_groups; ifisemptyout.fixation_type 120 out.fixation_type=-1; end outputcount,:=[param.s,param.m1,... out.fixation_time,out.fixation_type,... 125 out.n_alive_groups,out.n_defect_groups]; %fprintffid,'%1.5f,',param.b1; %fprintffid,'%1.5f,',param.b2; %fprintffid,'%1.5f,',param.b3; 130 %fprintffid,'%1.5f,',param.d1; %fprintffid,'%1.5f,',param.f1; %fprintffid,'%1.5f,',param.e1; 85

PAGE 98

%fprintffid,'%1.5f,',param.e2; %fprintffid,'%1.5f,',param.e3; 135 fprintffid,'%1.5f,',param.s; %fprintffid,'%1.5f,',param.mutant; fprintffid,'%1.10f,',param.m1; fprintffid,'%d,',out.fixation_type; fprintffid,'%1.5f,',out.fixation_time; 140 fprintffid,'%1.5f,',out.n_alive_groups; fprintffid,'%1.5fn',out.n_defect_groups; %fprintf' )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG [-600()]TJ/F55 10.9091 Tf 264 0 Td [(n'; %fprintf'Fixationtime:%5.1fn',out.fixation_time; 145 %fprintf'Fixationtype:%dn',out.fixation_type; %fprintf' \000\000\000\000\000\000\000\000\000\000\000\000\000)1(\000\000\000 nnn , ! '; count=count+1; end end 150 end fix_times meanfix_times 155 %varfix_times histfix_times 86

PAGE 99

160 %end 87

PAGE 100

%File:calc_multiple_moran_fix_times.m %functiontoestimatefixationtimesformultiplecont.time %moranprocesses 5 function[out]=calc_multiple_moran_fix_timesizes,num_groups n=lengthsizes; ET=zerosn,1; 10 VarT=zerosn,1; ETk=zerosn,1; VarTk=zerosn,1; s=0; n_int=100; 15 fid=fopen'analytical_out.csv','w'; tic fprintf's=%1.3f,calculatingforn=n',s; 20 out=[]; 25 forj=1:lengthsizes N=sizesj; 88

PAGE 101

fork=1:lengthnum_groups t1=toc; n_groups=num_groupsk; 30 fprintf... 'N:%d,K:%dgroupsCurrenttime:%1.1fminutesn',... N,n_groups,toc/60; u=zeros,N-1;ufloorN/2=1;Q=zerosN-1,N-1; Q,1=-N-1*+s/N;Q,2=N-1*+s/N; 35 QN-1,N-2=N-1/N;QN-1,N-1=-N-1*+s/N; fori=2:N-2 Qi,i-1=N-i*i/N;Qi,i=... -N-i*i*+s/N;Qi,i+1=N-i*i*+s/N; end 40 Qinv=invQ; ETj=-u*Qinv*onesN-1,1; VarTj=2*u*Qinv^2*onesN-1,1-ETj^2; 45 Tmax=ETj+10*sqrtVarTj; n_step=Tmax/n_int; n_int_steps=length:n_step:Tmax; 50 step=0; Tval=zerosn_int_steps,1; Tval2=zerosn_int_steps,1; 89

PAGE 102

fort=0:n_step:Tmax 55 step=step+1; Tvalstep=--u*expmQ*t*onesN-1,1^n_groups; Tval2step=2*t*--... u*expmQ*t*onesN-1,1^n_groups; 60 ifremstep-1,10==0 fprintf... 'T:%1.3f,Value:%1.3f,...Step:%d/%d%1.1fminn',... t,Tvalstep,step-1,n_int_steps-1,toc/60-t1/60; end 65 %ETk=ETk+... % )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.031 0 Td [( )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(u expmQ t onesN2,1^n_groups dt; %VarTk=VarTk+... %2 t )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.031 0 Td [( )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(u expmQ t onesN2,1^K dt; 70 end simp_vec=2*onesn_int+1,1; simp_vecrem:n_int+1,2==0=4; simp_vec=1; 75 simp_vecend=1; simp_approxj=sumsimp_vec.*Tval*n_step/3; simp_approx2j=sumsimp_vec.*Tval2*n_step/3; simp_approx3j=simp_approx2j-simp_approxj^2; 80 std_approxj=sumn_step*Tval; 90

PAGE 103

fprintf'nMultipleGroupsETStandard:%1.3fn',... std_approxj; fprintf'MultipleGroupsETSimpson:%1.3fn',... 85 simp_approxj; fprintf'MultipleGroupsVarTSimpson:%1.3fn',... simp_approx3j; fprintf'Totaltime:%1.1fminutesnn',toc/60-t1/60; out=[s,sizesj,n_groups,simp_approxj,... 90 simp_approx3j]; fprintffid,'%d,%d,%d,%1.3f,%1.3fn',... s,N,n_groups,simp_approxj,simp_approx3j; end 95 end fclosefid; fprintf'Done!%1.1fsecs',roundtoc*10/10; 100 %out=[sizes'simp_approx'simp_approx3']; end 91

PAGE 104

%File:calc_single_moran_fix_time.m %functiontocalcualtefixationtimeforasinglemoranprocess 5 function[out]=calc_single_moran_fix_timesizes n=lengthsizes; ET=zerosn,1; VarT=zerosn,1; 10 s=0; tic fprintf's=%1.3f,calculatingforn=n',s; 15 forj=1:lengthsizes N=sizesj; fprintf'%d%1.1fsecsn',N,round*toc/10; u=zeros,N-1;ufloorN/2=1;Q=zerosN-1,N-1; Q,1=-N-1*+s/N;Q,2=N-1*+s/N; 20 QN-1,N-2=N-1/N;QN-1,N-1=-N-1*+s/N; fori=2:N-2 Qi,i-1=N-i*i/N; Qi,i=-N-i*i*+s/N; Qi,i+1=N-i*i*+s/N; 25 end 92

PAGE 105

Qinv=invQ; ETj=-u*Qinv*onesN-1,1; 30 VarTj=2*u*Qinv^2*onesN-1,1-ETj^2; end fprintf'Done!%1.1fsecs',roundtoc*10/10; 35 out=[sizes'ETVarT]; end 93

PAGE 106

%File:dataDensity.m %thisisafunctiontocreateaheatmapofgrouppopulations %originallywrittenbymalcolmmclean 5 %seebibliographyfordetails function[dmap]=... dataDensityx,y,width,height,limits,fudge %DATADENSITYGetadatadensityimageofdata 10 %x,y )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(twovectorsofequallengthgivingscatterplotx,y %width,height )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(dimensionsofthedatadensityplot,inpx %limits )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [([xminxmaxyminymax] )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(defaultstodatamax/min %fudge )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(theamountofsmear,defaultstosizeofpixeldiag % 15 %ByMalcolmMcLean % ifnargin==4 limits=0; limits=50; 20 limits=50; limits=0; end deltax=limits-limits/width; deltay=limits-limits/height; 25 ifnargin<6 fudge=sqrtdeltax^2+deltay^2; 94

PAGE 107

end dmap=zerosheight,width; forii=0:height-1 30 yi=limits+ii*deltay+deltay/2; forjj=0:width-1 xi=limits+jj*deltax+deltax/2; dd=0; forkk=1:lengthx 35 dist2=xkk-xi^2+ykk-yi^2; dd=dd+1/dist2+fudge; end dmapii+1,jj+1=dd; end 40 end end 95

PAGE 108

%File:DataDensityPlot.m %thisisafunctiontocreateaheatmapofgrouppopulations %originallywrittenbymalcolmmclean 5 %seebibliographyfordetails function[f]=DataDensityPlotx,y,levels %DATADENSITYPLOTPlotthedatadensity %Makesacontourmapofdatadensity 10 %x,y )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(dataxandycoordinates %levels )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(numberofcontourstoshow % %ByMalcolmMclean % 15 map=dataDensityx,y,256,256; map=map-minminmap; map=floormap./maxmaxmap*levels-1; %f=figure; 20 %thiscolorpalettewascreatedbykennethmoreland %http://www.kennethmoreland.com/ %seebibliographyfordetails cmap=[0.334790850.283084370.75649522; 0.3584625290.329960830.777133955; 25 0.3841974670.3755950890.796252091; 0.4120657840.4204110670.813918378; 96

PAGE 109

0.4421186320.4646522750.830208424; 0.4743920810.5084626660.845204261; 0.5089106440.5519269420.858993977; 30 0.5456902340.5950924690.871671409; 0.5847404880.6379820050.883335904; 0.626066470.6806014940.894092128; 0.6696698230.7229450430.90404994; 0.7155494850.7649982360.913324306; 35 0.7637020560.8067403990.922035256; 0.8141219040.8481462140.930307876; 0.8668011080.8891868950.938272315; 0.9217292740.929831080.946063796; 0.9431067330.9258433760.914368911; 40 0.9294148970.8773202920.844885684; 0.9157855650.8284973250.777697451; 0.9020579730.7793588810.7129041; 0.888093190.7298743980.650599984; 0.8737720680.6799930390.590874501; 45 0.8589930490.6296356460.533812934; 0.8436699250.5786821280.479497629; 0.827729660.526950770.428009612; 0.8111103230.4741624190.379430755; 0.7937591850.4198740140.333846612; 50 0.7756309960.363343180.291350021; 0.7566864730.3032137330.252045386; 0.736890990.2366217830.216053135; 0.7162134950.155522750.183512887; 97

PAGE 110

0.6946256250.002964610.154581828]; 55 imagemap; colormapcmap; colorbar setgca,'XTick',[1128256]; 60 setgca,'XTickLabel',[02550]; setgca,'YTick',[1128256]; setgca,'YTickLabel',[50250]; ax=gca; ax.YLabel.String='NumberofEffectiveDefectors'; 65 ax.XLabel.String='NumberofEffectiveCooperators'; %uiwait; end 98

PAGE 111

%File:gen_brates_payoff_matrix.m function[out]=gen_brates_payoff_matrixvars 5 vars.payoff vars.pop R=vars.payoff,1;S=vars.payoff,2; T=vars.payoff,1;P=vars.payoff,2; 10 vars.group_pop=sumvars.pop; fork=1:vars.n_alive_groups vars.brate,k=R*vars.pop,k+... S*vars.pop,k/vars.group_popk; 15 vars.brate,k=T*vars.pop,k+... P*vars.pop,k/vars.group_popk; end out=vars.brate; 20 end 99

PAGE 112

mutant_sigma=[0.01:0.01:0.04,0.05:0.05:0.5]; n_sims=5; %all_def_by_mut_sigma.ss_n_groups=[]; %all_def_by_mut_sigma.ss_avg_coop=[]; 5 %all_def_by_mut_sigma.time_to_ss=[]; %all_def_by_mut_sigma.mutant_sigma=[]; %all_def_by_mut_sigma.final_dist=[]; forj=1:1 10 mutant_sigmaj out=hybrid_distmutant_sigmaj,n_sims; out.time_to_ss out.ss_n_groups out.ss_avg_coop 15 out.final_dist all_def_by_mut_sigma.time_to_ss=... [all_def_by_mut_sigma.time_to_ss;out.time_to_ss]; all_def_by_mut_sigma.ss_n_groups=... [all_def_by_mut_sigma.ss_n_groups;out.ss_n_groups]; 20 all_def_by_mut_sigma.ss_avg_coop=... [all_def_by_mut_sigma.ss_avg_coop;out.ss_avg_coop]; all_def_by_mut_sigma.mutant_sigma=... [all_def_by_mut_sigma.mutant_sigma;... repmatmutant_sigmaj,n_sims,1]; 25 all_def_by_mut_sigma.final_dist=... [all_def_by_mut_sigma.final_dist;out.final_dist]; 100

PAGE 113

all_def_by_mut_sigma.description=... 'hybridsimulationsby10typesforsamestartingconfig'; 30 end all_def_by_mut_sigma.param=out.param; 101

PAGE 114

%File:gen_trans_matrix_simon.m %functiontoanalyticallycalculatefixationprobabilities 5 function[Q,coords]=gen_trans_matrix_simonn tic [A,B]=meshgrid:n,0:n; c=cat,A',B'; coords=reshapec,[],2; 10 %idx=coords:,1+coords:,2>n+1; %coordsidx,:=[]; n1=lengthcoords; 15 Q=zerosn1,n1; b1=0.04; b2=0.05; b3=0.005; d1=0.0015; 20 fori=1:n1 tot=0; curr_coord=coordsi,:; nd=curr_coord; 25 nc=curr_coord; nt=nc+nd; 102

PAGE 115

ifnd==0||nc==0 absorb=1; 30 else absorb=0; bc=b1+b2*nc/nt-b3*nc; bd=b1+b2*nc/nt*nd; dc=d1*nc*nt; 35 dd=d1*nd*nt; tot=bc+bd+dc+dd; end new_coord1=[curr_coord-1,curr_coord]; 40 new_idx1=findcoords:,1==new_coord1&... coords:,2==new_coord1; new_coord2=[curr_coord+1,curr_coord]; new_idx2=findcoords:,1==new_coord2&... coords:,2==new_coord2; 45 new_coord3=[curr_coord,curr_coord-1]; new_idx3=findcoords:,1==new_coord3&... coords:,2==new_coord3; new_coord4=[curr_coord,curr_coord+1]; new_idx4=findcoords:,1==new_coord4&... 50 coords:,2==new_coord4; ifabsorb==0 forj=1:4 103

PAGE 116

switchj 55 case1 ifnew_coord1>=0 Qi,new_idx1=dd/tot; end case2 60 ifnew_coord2~=n+1 Qi,new_idx2=bd/tot; else Qi,i=Qi,i+bd/tot; end 65 case3 ifnew_coord3>=0 Qi,new_idx3=dc/tot; end case4 70 ifnew_coord4~=n+1 Qi,new_idx4=bc/tot; else Qi,i=Qi,i+bc/tot; end 75 end end else Qi,i=1; end 80 104

PAGE 117

end toc QisnanQ=0; 85 start_c=20; start_d=20; abs_rows=finddiagQ==1; non_abs_rows=finddiagQ~=1; 90 non_abs_coords=coordsnon_abs_rows,:; abs_coords=coordsabs_rows,:; start_idx=findnon_abs_coords:,1==start_d&... non_abs_coords:,2==start_c; 95 absorb_d=findabs_coords:,1~=0&abs_coords:,2==0; absorb_c=findabs_coords:,1==0&abs_coords:,2~=0; toc Qhat=Qnon_abs_rows,non_abs_rows; R=Qnon_abs_rows,abs_rows; 100 Qhat_dim=sizeQhat; Qhat_dim=Qhat_dim; abs_probs=inveyeQhat_dim-Qhat*R; toc p_abs_d=sumabs_probsstart_idx,absorb_d 105 p_abs_c=sumabs_probsstart_idx,absorb_c end 105

PAGE 118

%File:gen_moraninf.m %functiontogeneratetheinfinitesimalgeneratorformoranpr 5 N=10; %numberofindividuals s=0.0; %birthrateasymmetry r=1+s; Q=zerosN+1,N+1; 10 fori=2:N Qi,i-1=N-i*i/r*i+N-i/N; Qi,i+1=r*i*N-i/r*i+N-i/N; end 106

PAGE 119

%File:gen_payoff_matrix.m %functiontogeneratepayoffmatrixforiter.pris.dilemma 5 function[param,vars]=gen_payoff_matrixparam,vars %payoffmatrix %R=3; %S=0; 10 %T=5; %P=1; R=vars.payoff,1; 15 S=vars.payoff,2; T=vars.payoff,1; P=vars.payoff,2; %n=sqrtparam.n_types; 20 n=param.n_types; p=:n-1/n-1; p=0.01; pend=0.99; 25 vars.pq=zerosn^2,2; 107

PAGE 120

[s1,s2,r1,r2,p1,p2,q1,q2]=deal; vars.G=zerosn^2,n^2; vars.coop_mat=zerosn^2,n^2; 30 vars.mu=param.mutant/param.n_types-1*onesn^2,n^2; fori=1:n forj=1:n vars.pqn*i-1+j,1=pj; 35 vars.pqn*i-1+j,2=pi; end end fori=1:n^2 40 forj=1:n^2 p1=vars.pqi,1;p2=vars.pqj,1; q1=vars.pqi,2;q2=vars.pqj,2; r1=p1-q1; r2=p2-q2; 45 s1=q2*r1+q1/-r1*r2; s2=q1*r2+q2/-r1*r2; vars.coop_mati,j=s1; vars.coop_matj,i=s2; vars.Gi,j=R*s1*s2+S*s1*-s2+T*-s1*s2+... 50 P*-s1*-s2; end vars.mui,i=1-param.mutant; end 108

PAGE 121

55 mu=zerosn,n,n,n; fori1=1:n forj1=1:n fori2=1:n 60 forj2=1:n ifi1==i2&&j1==j2 mui1,j1,i2,j2=1-param.mutant; ifi1==1||i1==n mui1,j1,i2,j2=mui1,j1,i2,j2+... 65 param.mutant/4; end ifj1==1||j1==n mui1,j1,i2,j2=mui1,j1,i2,j2+... param.mutant/4; 70 end else ifi11 mui1,j1,i1-1,j1=param.mutant/4; end ifj1
PAGE 122

ifj1>1 mui1,j1,i1,j1-1=param.mutant/4; end end 85 end end end end 90 end 110

PAGE 123

%File:hybrid_dist.m %functiontogeneratealotofhybridsimulations 5 function[data]=hybrid_distn_types,n_sims %n_types=10; data=[]; 10 data.time_to_ss=zerosn_sims,1; data.ss_avg_coop=zerosn_sims,1; data.ss_n_groups=zerosn_sims,1; data.coop_hist=zerosn_sims,n_types; 15 fori=1:n_sims out=hybrid_updatedn_types; data.time_to_ssi=out.time_to_ss; data.ss_avg_coopi=out.ss_avg_coop; data.ss_n_groupsi=out.ss_n_groups; %findfinaldistribution 20 data.final_disti,:=... squeeze*sumout.pop_time:,:,end,2./... sumsumout.pop_time:,:,end,2'; end 25 data.param=out.param; data.last_sim=out; 111

PAGE 124

data.n_types=n_types; end 112

PAGE 125

%File:hybrid_updated.m %Thisisthehybridsimulationmodel 5 function[out]=hybrid_updatedn_types rng'default'; rng 10 %closeallforce tic % \000\000\000\000)]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 82.909 0 Td [(Step1:EnterparametersHERE! \000\000\000\000)]TJ0 g 0 GETq1 0 0 1 104.812 348.343 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQq1 0 0 1 543.188 348.343 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQ1 1 0 0 k 1 1 0 0 KBT/F19 5.9776 Tf 90.732 355.537 Td [(15 param.initial_groups=50; %numberofinitialgroups param.initial_size=40; param.initial_coop=20; param.initial_def=20; param.initial_sd=0; 20 param.n_types=2; param.max_groups=1000; %maxnumberofgroups param.mutant=0.05; ifnargin 25 param.n_types=n_types; else 113

PAGE 126

param.n_types=2; end 30 param.t_delta=5; %unitsoftimeinbetweenframes param.t_total=5000; %totaltime param.dt=.01; %timestepforhybrid param.group_events=1; %0=off,1=on 35 %param.birth_option=1;%PGG param.birth_option=2; %snowdrift param.payoff=[02;13/2]/18; 40 param.fission_option=1; %linearingrouppopulation param.extinction_option=1; %exponentialingrouppopulation,linearinnumberofgroups 45 param.f_time=500; % \000\000\000\000)]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 82.909 0 Td [(Step2:Initialize \000\000\000\000)]TJ0 g 0 GETq1 0 0 1 104.812 192.438 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQq1 0 0 1 543.188 192.438 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQq1 0 0 1 104.812 168.457 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQq1 0 0 1 543.188 168.457 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQBT/F51 11.9552 Tf 108 175.652 Td [(vars.pop=zerosparam.n_types,param.max_groups; 50 vars.pop,1:param.initial_groups=param.initial_def+... param.initial_sd*randn,param.initial_groups; vars.popend,1:param.initial_groups=param.initial_coop+... 114

PAGE 127

param.initial_sd*randn,param.initial_groups; 55 fori=2:param.n_types-1 vars.popi,1:param.initial_groups=0*param.initial_coop+... param.initial_sd*randn,param.initial_groups; end 60 %Setgroupswithnegativepopulationstozeros vars.popvars.pop:,1:param.initial_groups,1<0=0; vars.old_pop=vars.pop; 65 vars.group_pop=sumvars.pop; out.time=0:param.t_delta:param.t_total; out.pop_time=zerosparam.n_types,param.max_groups,... 70 lengthout.time; out.eff_pop_time=zeros2,param.max_groups,... lengthout.time; out.eff_coop=zeroslengthout.time,1; out.n_groups=zeroslengthout.time,1; 75 out.fix_flag=0; out.fix_time=0; %Setupvariablesthatchangeeachiteration vars.curr_time=0; 80 vars.end_time=param.t_delta; 115

PAGE 128

vars.alive_groups=sumvars.pop>0; vars.n_alive_groups=param.initial_groups; vars.extinct_groups=sumvars.pop==0; vars.n_extinct_groups=sumvars.extinct_groups; 85 vars.birth_ind=zerosparam.n_types,param.max_groups; vars.brate=zerosparam.n_types,param.max_groups; vars.death_ind=zerosparam.n_types,param.max_groups; vars.drate=zerosparam.n_types,param.max_groups; vars.frate=zeros,param.max_groups; 90 vars.erate=zeros,param.max_groups; vars.ebrate=zerosparam.n_types,param.max_groups; vars.rand_fission=zerosparam.n_types,param.max_groups; vars.rand_extinction=zerosparam.n_types,param.max_groups; vars.rand_birth=zerosparam.n_types,param.max_groups; 95 vars.rand_death=zerosparam.n_types,param.max_groups; vars.end_idx=0; vars.eff_pop=zeros2,param.max_groups; vars.avg_coop=zerossizeout.time; vars.group_coop=zerosparam.max_groups,lengthout.time; 100 vars.alive_idx=[]; %Calculatemutationmatrix param=calc_mutation_matrixparam; param=calc_coop_vecparam; 105 % \000\000\000\000)]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 82.909 0 Td [(Step3:HybridODEsimulation \000\000\000\000)]TJ0 g 0 GETq1 0 0 1 104.812 72.537 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQq1 0 0 1 543.188 72.537 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQ0 g 0 GBT/F15 11.9552 Tf 522.441 54 Td [(116

PAGE 129

out.pop_time:,:,1=vars.pop; 110 h=waitbar,'PleaseWait...'; time_len=lengthout.time; out.param=param; 115 fori=1:time_len waitbari/time_len,h; %Setthetimeforthenextframe vars.end_time=out.timei; 120 %Runthehybridsimulationupuntilthetimeofthenextframe [param,vars,out]=hybridparam,vars,out; %Updategrouppopulations out.pop_time:,:,i=vars.pop; 125 out.eff_coopi=sumvars.pop,2'*... param.coop_vec/sumsumvars.pop*100; [param,vars,~,~]=calc_eff_coopparam,vars; out.eff_pop_time:,:,i=vars.eff_pop; 130 out.n_groupsi=sumsumvars.eff_pop>0; ifremi-1,10==0 f=sprintf... 'Timerunning:%2.1fminutes%d%%completen',... 117

PAGE 130

135 toc/60,round*i/time_len,toc/i/time_len-toc/60; waitbari/time_len,h,f; end 140 end closeh toc plot_flag=0; 145 %choice=questdlg'PlotResults?',... %'PlotResults?','Yes','No','Yes'; % %switchchoice 150 %case'Yes' %plot_flag=1; %case'No' %plot_flag=0; %end 155 whileplot_flag==1 fork=1:lengthout.time plotout.eff_pop_time,:,k,... 160 out.eff_pop_time,:,k,'k.','MarkerSize',20; axis[01000100]; 118

PAGE 131

x_axis_label1=strcat'NumberofEffectiveCooperators'; y_axis_label1=strcat'NumberofEffectiveDefectors'; xlabelx_axis_label1 165 ylabely_axis_label1 title1=strcat'Time=',num2strroundout.timek; titletitle1 drawnow; end 170 choice=questdlg'Plotagain?',... 'Plotagain?','Yes','No','Yes'; switchchoice 175 case'Yes' plot_flag=1; case'No' plot_flag=0; end 180 end end function[param,vars,out]=hybridparam,vars,out 185 %Initializesomevariables` idx=1; new_pop=zerosparam.n_types,1; 119

PAGE 132

190 fork=1:roundvars.end_time-vars.curr_time/param.dt vars.alive_idx=findvars.alive_groups==1; %Killthesimulationifthemaximumnumber 195 %ofgroupshasbeenexceeded ifparam.max_groups
PAGE 133

%%Updategrouppopulations %vars.group_pop=sumvars.pop; %vars.alive_idx=findvars.alive_groups==1; 220 fori1=1:vars.n_alive_groups i=vars.alive_idxi1; %GeneratetwouniformRV 225 r1=rand; r2=rand; %Firstseeifthepopisdead.Ifso,don'tdoanything ifvars.group_popi==0 230 %Seeifagroupextinctionoccurred elseifr10 new_popj=rand*vars.popj,i; 121

PAGE 134

else new_popj=0; 245 end end ifisemptyn_idx n_idx=vars.n_alive_groups+1; 250 end vars.pop:,n_idx=new_pop; vars.pop:,i=vars.pop:,i-new_pop; 255 %Ifagroupfissionorextinctiondidnotoccur, %updateitspopulation else vars.pop:,i=vars.pop:,i+vars.ebrate:,i*param.dt; end 260 end vars.popvars.pop<0=0; vars.extinct_groups=sumvars.pop<0.000001; vars.n_extinct_groups=sumvars.extinct_groups; 265 vars.alive_groups=1-vars.extinct_groups; vars.n_alive_groups=sumvars.alive_groups; vars.old_pop=vars.pop; 122

PAGE 135

270 %Incrementcurrenttime vars.curr_time=vars.curr_time+param.dt; end 275 %Setcurrenttimetoendtimethisisdonebecausethereisa %smalldifferenceatthispointofaverysmallmagnitudethat %screwsotherstuffup vars.curr_time=vars.end_time; 280 vars.end_idx=idx; end 285 function[param,vars]=gen_eff_birth_ratesparam,vars %param.d1=0.0008; param.d1=0.0015; 290 %publicgoodsgame ifparam.birth_option==1 param.b1=0.04; 295 param.b2=0.05; param.b3=0.015; 123

PAGE 136

%param.b1=0.04; %param.b2=0.05; 300 %param.b3=0.005; %param.d1=0.0015; vars.birth_ind=param.b1+param.b2*vars.eff_coop-... 305 param.b3*param.coop_vec; vars.brate=vars.birth_ind.*vars.pop; elseifparam.birth_option==2 R=param.payoff,1;S=param.payoff,2; 310 T=param.payoff,1;P=param.payoff,2; vars.birth_ind,:=R*vars.eff_pop,:+... S*vars.eff_pop,:./vars.group_pop; vars.birth_indend,:=T*vars.eff_pop,:+... 315 P*vars.eff_pop,:./vars.group_pop; vars.birth_ind=param.double_coop_vec*... [vars.birth_ind,:;vars.birth_indend,:]; vars.brate=vars.birth_ind.*vars.pop; vars.brateisnanvars.brate=0; 320 end vars.death_ind=param.d1*vars.group_pop; 124

PAGE 137

vars.drate=vars.death_ind.*vars.pop; 325 vars.ebrate=param.mut_mat*vars.brate-vars.drate; temp_idx=vars.pop<0|isnanvars.ebrate; vars.ebratetemp_idx=0; 330 end function[param,vars]=gen_fission_ratesparam,vars param.f1=0.0001; 335 param.f2=0.0001; vars.frate=param.f2*vars.pop,:+param.f1*vars.pop,:; %turnofffissions 340 vars.frate=vars.frate*param.group_events; end function[param,vars]=gen_extinction_ratesparam,vars 345 param.e1=0.02; param.e2=0.2; param.e3=0.0; 350 vars.erate=param.e1*vars.n_alive_groups*... 125

PAGE 138

exp-param.e2*vars.group_pop*... expparam.e3*vars.n_alive_groups; %turnoffextinctions 355 vars.erate=vars.erate*param.group_events; end function[param,vars,group_avg,overall_avg]=... 360 calc_eff_coopparam,vars %effectivenumberofcooperators vars.eff_pop,:=sumvars.pop.*param.coop_vec; 365 %effectivenumberofdefectors %vars.eff_pop,:=vars.group_pop )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(vars.eff_pop,:; vars.eff_pop,:=sumvars.pop.*-param.coop_vec; %effectivegroupcooperationproportion 370 vars.eff_coop=vars.eff_pop,:./vars.group_pop; group_avg=meanvars.eff_pop,vars.alive_idx./... vars.group_popvars.alive_idx; overall_avg=sumvars.eff_pop,:/sumvars.group_pop; 375 end 126

PAGE 139

function[param]=calc_mutation_matrixparam 380 param.mut_type=4; %1=normalcdf,2=geometric, %3=normalpdf,4=normalpdfwithfixedmutationrate param.sigma=0.1; param.mut_mat=zerosparam.n_types,param.n_types; 385 n_levels=param.n_types-1; temp_breaks=1/2*1/n_levels:1/n_levels:1; norm_breaks=[-Inftemp_breaksInf]; 390 switchparam.mut_type case1 fori=1:param.n_types forj=1:param.n_types param.mut_mati,j=... 395 normcdfnorm_breaksi+1,1/n_levels*... j-1,param.sigma-... normcdfnorm_breaksi,1/n_levels*j-1,param.sigma; end end 400 case2 temp_prop=fliplr.^:n_levels-1; temp_sum=sumtemp_prop; temp_prop=temp_prop/temp_sum; fori=1:param.n_types 127

PAGE 140

405 forj=1:param.n_types ifi==j param.mut_mati,j=1-param.mutant; else param.mut_mati,j=param.mutant*temp_propabsi-j; 410 end end end case3 temp_prop=:n_levels/n_levels; 415 fori=1:param.n_types param.mut_mati,:=... normpdftemp_prop,temp_propi,param.sigma/... sumnormpdftemp_prop,temp_propi,param.sigma; end 420 case4 temp_prop=:n_levels/n_levels; fori=1:param.n_types param.mut_mati,:=normpdftemp_prop,... temp_propi,param.sigma; 425 param.mut_mati,i=0; param.mut_mati,:=param.mutant*... param.mut_mati,:/sumparam.mut_mati,:; param.mut_mati,i=1-param.mutant; end 430 end 128

PAGE 141

param.mut_mat; end 435 function[param]=calc_coop_vecparam param.coop_vec=:param.n_types-1/param.n_types-1'; param.double_coop_vec=[1-param.coop_vecparam.coop_vec]; 440 end 129

PAGE 142

%File:moran_neutral.m %functiontosimulateneutralmoranprocess 5 function[]=moran_neutraln_sims,N tot=0; tot2=0; fori=1:n_sims 10 state=N/2; steps=0; whilestate~=0&&state~=N r=rand; 15 ifr
PAGE 143

end ET=tot/n_sims 30 VarT=tot2/n_sims-ET^2 fprintf... 'Approximate95%%confintervalforTbar:%2.2f,%2.2fn',... ET-1.96*sqrtVarT/sqrtn_sims,ET+... 1.96*sqrtVarT/sqrtn_sims; 35 end 131

PAGE 144

%File:moran_partial.m %functiontosimulatemoranprocesswithselection 5 function[]=moran_partialbrate_c,brate_d,n_sims,N_total tic times=zerosn_sims,1; 10 fix_group=zerosn_sims,1; steps=zerosn_sims,1; state_steps=zerosN_total-1,1; state_time=zerosN_total-1,1; fix_state=100; 15 forj=1:n_sims N=N_total; nc=1; %numberofcooperators 20 t=0; whilenc~=0&&nc~=fix_state down=-logrand/N-nc*brate_d*nc/N; up=-logrand/nc*brate_c*N-nc/N; 25 ifdown
PAGE 145

state_timenc=state_timenc+down; nc=nc-1; t=t+down; 30 stepsj=stepsj+1; else state_stepsnc=state_stepsnc+1; state_timenc=state_timenc+up; nc=nc+1; 35 t=t+up; stepsj=stepsj+1; end end 40 ifnc==fix_state fix_groupj=1; else fix_groupj=0; end 45 timesj=t; end 133

PAGE 146

%File:moran_selection.m %simulateasymmetricmoranprocess 5 function[]=moran_selectionn_sims,N,f1,g1 tot=0; tot2=0; fori=1:n_sims 10 state=N/2; steps=0; whilestate~=0&&state~=N r=rand; 15 p1=g1*N-state/f1*state+g1*N-state*state/N; p2=f1*state/f1*state+g1*N-state*N-state/N; ifr
PAGE 147

tot=tot+steps; tot2=tot2+steps^2; end 30 ET=tot/n_sims VarT=tot2/n_sims-ET^2 fprintf'Approximate95%%confidenceintervalforTbar:%2.2f,%2.2f , ! n',... ET-1.96*sqrtVarT/sqrtn_sims,ET+1.96*sqrtVarT/sqrtn_sims , ! ; 35 end 135

PAGE 148

%File:MoranFixDist.m %functiontocalculatemoranfixationtimesanalytically 5 %findsgroupfixationtimedist,anddistofmaxforwholepop clear s=0; %birthrateasymmetry.type1rateis1+s,type2rateis1 dt=1; 10 forNN=1:10 N=10*NN n=floorN/2; forKK=1:10 K=1+10*KK-1; 15 u=zeros,N-1;un=1;Q=zerosN-1,N-1; Q,1=-N-1*+s/N;Q,2=N-1*+s/N; QN-1,N-2=N-1/N;QN-1,N-1=-N-1*+s/N; fori=2:N-2 Qi,i-1=N-i*i/N; 20 Qi,i=-N-i*i*+s/N; Qi,i+1=N-i*i*+s/N; end ET=-u*invQ*onesN-1,1; VarT=2*u*invQ^2*onesN-1,1-ET^2; 25 ET VarT 136

PAGE 149

break; Tmax=ET+5*sqrtVarT; %PT>Tmaxisverysmall. %meanandvarianceofmaxfixationtimeforKgroups 30 ETk=0;VarTk=0; fort=1:dt:Tmax ETk=ETk+... --u*expmQ*t*onesN-1,1^K*dt; %VarTk=VarTk+2 t ,.. 35 % )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.031 0 Td [( )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(u expmQ t onesN )]TJ/F55 10.9091 Tf 8.484 0 Td [(1,1^K dt; end VarTk=VarTk-ETk^2; BigN=N*K;Bign=n*K; %singlebiggrouptocompare Q2=zerosBigN-1,BigN-1; 40 bigu=zeros,BigN-1;biguBign=1; u=zeros,BigN-1;uBign=1; Q=zerosBigN-1,BigN-1; Q2,1=-BigN-1*+s/BigN; Q2,2=BigN-1*+s/BigN; 45 Q2BigN-1,BigN-2=BigN-1/BigN; Q2BigN-1,BigN-1=-BigN-1*+s/BigN; fori=2:BigN-2 Q2i,i-1=BigN-i*i/BigN; Q2i,i=-BigN-i*i*+s/BigN; 50 Q2i,i+1=BigN-i*i*+s/BigN; end EBigT=-u*invQ2*onesBigN-1,1; VarBigT=2*bigu*invQ2^2*onesBigN-1,1-EBigT^2; 137

PAGE 150

ANN,KK=ETk;BNN,KK=EBigT; 55 end end 138

PAGE 151

%File:plot_determ_path.m %functiontoplotthedeterministicpathofahybridsimulation 5 function[]=plot_determ_pathstart_time,end_time,dt,... plot_delta,start_pop time=start_time:dt:end_time; n_time=lengthtime; 10 curr_pop=start_pop; curr_time=time1; beta=.04; 15 b=.05; c=.02; gamma=.0008; mutant=.05; 20 brate=zeros2,1; birth_rate=zeros2,1; death_rate=zeros2,1; eff_birth_rate=zeros2,1; prev_pop=start_pop; 25 plotstart_pop1,start_pop2,'o'; 139

PAGE 152

fori=2:n_time group_pop=sumcurr_pop; 30 brate1=beta+b*curr_pop1/group_pop-c; brate2=beta+b*curr_pop1/group_pop; birth_rate1=brate1*curr_pop1; 35 birth_rate2=brate2*curr_pop2; death_rate1=gamma*group_pop*curr_pop1; death_rate2=gamma*group_pop*curr_pop2; 40 eff_birth_rate1=1-mutant*birth_rate1... +mutant*birth_rate2-death_rate1; eff_birth_rate2=1-mutant*birth_rate2... +mutant*birth_rate1-death_rate2; 45 curr_pop1=curr_pop1+eff_birth_rate1*dt; curr_pop2=curr_pop2+eff_birth_rate2*dt; curr_time=timei; ifmodcurr_time,plot_delta==0 50 plotcurr_pop1,curr_pop2,'o' plot[curr_popprev_pop],... [curr_popprev_pop],':' prev_pop=curr_pop; 140

PAGE 153

end 55 end 141

PAGE 154

%File:plot_dynamics_ipd.m %functiontoplotstochasticsimulationsof %iter.prisonersdilemma 5 function[]=plot_dynamics_ipdplot_input warning'off' closeall 10 time=plot_input.time; pop_time=plot_input.pop_time; n_time=lengthtime; 15 n_groups=sizepop_time,2; n_alive_groups=zerosn_time,1; %bottomleftcornerdefectors %coop_idx=[356789]; 20 %def_idx=[124]; %rightsidecooperators coop_idx=[369]; def_idx=[124578]; 25 cur_coop=zerosn_groups,1; 142

PAGE 155

cur_def=zerosn_groups,1; cur_pop=zerosn_groups,1; group1_pop=zerosn_time,1; 30 group2_pop=zerosn_time,1; figure'units','normalized','position',[.05.05.9.9] fori=1:n_time subplot,2,1; 35 cur_coop=sumpop_timecoop_idx,:,i; cur_def=sumpop_timedef_idx,:,i; cur_pop=cur_coop+cur_def; group1_popi=cur_pop; group2_popi=cur_pop; 40 n_alive_groupsi=sumcur_pop>0; plotcur_coop,cur_def,'ko'; axis[06000600]; x_axis_label1=strcat'Numberof"Cooperators"'; y_axis_label1=strcat'Numberof"Defectors"'; 45 xlabelx_axis_label1 ylabely_axis_label1 title1=strcat... 'GroupDynamicsTime=',num2strtimei,''; titletitle1 50 subplot,2,2 plottime:i,n_alive_groups1:i xlabel'Time'; 143

PAGE 156

ylabel'NumberofAliveGroups'; 55 title'NumberofAliveGroupsvs.Time'; subplot,2,3 plottime:i,squeezepop_time[1,3,6,9],1,1:i'; holdon; 60 plottime:i,group1_pop:i holdoff; legend'Defect','TFT','GTFT',... 'Cooperate','Total','Location','northwest'; xlabel'Time' 65 ylabel'IndividualPopulations' title'Group#1populationdynamics'; subplot,2,4 plottime:i,squeezepop_time[1,3,6,9],2,1:i'; 70 holdon; plottime:i,group2_pop:i holdoff; legend'Defect','TFT','GTFT','Cooperate',... 'Total','Location','northwest'; 75 xlabel'Time' ylabel'IndividualPopulations' title'Group#2populationdynamics'; drawnow; 80 end 144

PAGE 157

%File:plot_dynamics_pgg.m %functiontoplotpublicgoodsgamestochasticsimulations 5 function[]=plot_dynamics_pggplot_input warning'off' closeall 10 time=plot_input.time; pop_time=plot_input.pop_time; n_time=lengthtime; n_groups=sizepop_time,2; 15 n_alive_groups=zerosn_time,1; n_types=sizepop_time,1; %bottomleftcornerdefectors %coop_idx=[356789]; 20 %def_idx=[124]; %rightsidecooperators def_idx=1:ceiln_types/2; coop_idx=ceiln_types/2+1:n_types; 25 cur_coop=zerosn_groups,1; 145

PAGE 158

cur_def=zerosn_groups,1; cur_pop=zerosn_groups,1; group1_pop=zerosn_time,1; 30 group2_pop=zerosn_time,1; figure'units','normalized','position',[.05.05.9.9] ifn_types>2 35 fori=1:n_time cur_coop=sumpop_timecoop_idx,:,i; cur_def=sumpop_timedef_idx,:,i; cur_pop=cur_coop+cur_def; 40 group1_popi=cur_pop; group2_popi=cur_pop; n_alive_groupsi=sumcur_pop>0; subplot,2,1; 45 plotcur_coop,cur_def,'ko'; axis[01000100]; x_axis_label1=strcat'Numberof"Cooperators"'; y_axis_label1=strcat'Numberof"Defectors"'; xlabelx_axis_label1 50 ylabely_axis_label1 title1=strcat... 'GroupDynamicsTime=',num2strtimei,''; titletitle1 146

PAGE 159

55 subplot,2,2 plottime:i,n_alive_groups:i xlabel'Time'; ylabel'NumberofAliveGroups'; title'NumberofAliveGroupsvs.Time'; 60 subplot,2,3 plottime:i,squeezesumpop_timedef_idx,1,1:i; holdon; plottime:i,squeezesumpop_timecoop_idx,1,1:i; 65 plottime:i,group1_pop:i; holdoff; legend'Defectors','Cooperators',... 'Total','Location','northwest'; xlabel'Time' 70 ylabel'IndividualPopulations' title'Group#1populationdynamics'; subplot,2,4 plottime:i,squeezesumpop_timedef_idx,2,1:i; 75 holdon; plottime:i,squeezesumpop_timecoop_idx,2,1:i; plottime:i,group2_pop:i; holdoff; legend'Defectors','Cooperators',... 80 'Total','Location','northwest'; 147

PAGE 160

xlabel'Time' ylabel'IndividualPopulations' title'Group#2populationdynamics'; drawnow; 85 %keyboard end 90 elseifn_types==2 fori=1:n_time cur_coop=pop_timeend,:,i; 95 cur_def=pop_time,:,i; cur_pop=cur_coop+cur_def; group1_popi=sumpop_time:,1,i; group2_popi=sumpop_time:,2,i; n_alive_groupsi=sumcur_pop>0; 100 subplot,2,1; plotcur_coop,cur_def,'ko'; axis[01000100]; x_axis_label1=strcat'Numberof"Cooperators"'; 105 y_axis_label1=strcat'Numberof"Defectors"'; xlabelx_axis_label1 ylabely_axis_label1 148

PAGE 161

title1=strcat... 'GroupDynamicsTime=',num2strtimei,''; 110 titletitle1 subplot,2,2 plottime:i,n_alive_groups:i xlabel'Time'; 115 ylabel'NumberofAliveGroups'; title'NumberofAliveGroupsvs.Time'; subplot,2,3 plottime:i,squeezepop_time,1,1:i; 120 holdon; plottime:i,squeezepop_timeend,1,1:i; plottime:i,group1_pop:i; holdoff; legend'Defectors','Cooperators',... 125 'Total','Location','northwest'; xlabel'Time' ylabel'IndividualPopulations' title'Group#1populationdynamics'; 130 subplot,2,4 plottime:i,squeezepop_timedef_idx,2,1:i; holdon; plottime:i,squeezepop_timecoop_idx,2,1:i; plottime:i,group2_pop:i; 149

PAGE 162

135 holdoff; legend'Defectors','Cooperators',... 'Total','Location','northwest'; xlabel'Time' ylabel'IndividualPopulations' 140 title'Group#2populationdynamics'; drawnow; %keyboard 145 end end 150

PAGE 163

%File:plot_hybrid.m %functiontoplotfourwindowsforhybridresults %caneasilybemodifiedtoplotstochasticresultsifneeded 5 function[F]=plot_hybridout closeallforce 10 all_plots=1; single_plot=0; faster=1; count=1; 15 plot_flag=1; pics_flag=1; n_types=sizeout.pop_time,1; 20 n_time=sizeout.pop_time,3; coop_mat=:n_types-1/n_types-1; %figure'position',[0100500350]; figure'position',[01001000700]; 25 %preprocessing 151

PAGE 164

out.pop_split=zerossizeout.eff_pop_time; out.pop_split,:,:=sumout.pop_time:end/2,:,:,1; out.pop_split,:,:=sumout.pop_timeend/2+1:end,:,:,1; 30 out.coop_time=squeeze*sumout.eff_pop_time,:,:./... sumout.eff_pop_time,:,:+sumout.eff_pop_time,:,:; out.coop_hist=squeeze*sumout.pop_time,2./... sumsumout.pop_time,2; 35 bin_edges=round:100/n_types:100; bin_edges1=round:100/*n_types:100; bin_names1=[]; fori=1:lengthbin_edges1 40 ifremi,2==1 bin_names1{i}=num2strbin_edges1i; else bin_names1{i}=['Type',num2stri/2]; end 45 end %fprintf'Readytoplot!Pressthespacebartocontinue.nn'; %pause 50 ifall_plots whileplot_flag 152

PAGE 165

fork=1:faster:lengthout.time 55 x=out.eff_pop_time,:,k; y=out.eff_pop_time,:,k; x1=out.eff_pop_time,1,k; y1=out.eff_pop_time,1,k; idx=x>0|y>0; %idxofalivegroups 60 x=xidx; y=yidx; subplot,2,1 plotx,y,'k.','MarkerSize',20; axis[050050]; 65 x_axis_label1=strcat'NumberofEffectiveCooperators'; y_axis_label1=strcat'NumberofEffectiveDefectors'; xlabelx_axis_label1 ylabely_axis_label1 title1=strcat'Time=',num2strroundout.timek; 70 titletitle1 %holdon; %plotx1,y1,'k.','MarkerSize',20,'Color','Green'; %holdoff; 75 subplot,2,2 bin_counts=out.coop_hist:,k'; histogram'BinEdges',bin_edges,'BinCounts',bin_counts ifn_types>5 %xticksbin_edges 80 else 153

PAGE 166

xticksbin_edges1; xticklabelsbin_names1; xtickangle; end 85 x_axis_label2=strcat'%cooperation'; xlabelx_axis_label2; y_axis_label2=strcat'PercentFrequency'; ylabely_axis_label2; title2=strcat'HistogramofIndividualStrategies'; 90 titletitle2; axis[-010001.1*maxbin_counts] subplot,2,3 DataDensityPlotx,y,64; 95 subplot,2,4 plotout.time:k,out.coop_time:k x_axis_label3=strcat'Time'; xlabelx_axis_label3; 100 y_axis_label3=strcat... 'GlobalAverageGroupCooperation%'; ylabely_axis_label3; title3=strcat... 'GlobalAverageGroupCooperationCurrently:',{''},... 105 num2strroundout.coop_timek,'%'; titletitle3; axis[-1out.timek-1100]; 154

PAGE 167

drawnow; 110 Fcount=getframegcf; count=count+1; %pause.1 end 115 %choice=questdlg'Plotagain?',... %'Plotagain?','Yes','No','Yes'; % %switchchoice 120 %case'Yes' %plot_flag=1; %case'No' %plot_flag=0; %end 125 plot_flag=0; end end 130 ifsingle_plot fork=1:faster:lengthout.time x=out.eff_pop_time,:,k; y=out.eff_pop_time,:,k; 155

PAGE 168

135 x1=out.eff_pop_time,1,k; y1=out.eff_pop_time,1,k; idx=x>0|y>0; %idxofalivegroups x=xidx; y=yidx; 140 plotx,y,'k.','MarkerSize',20; axis[050050]; x_axis_label1=strcat'NumberofEffectiveCooperators'; y_axis_label1=strcat'NumberofEffectiveDefectors'; xlabelx_axis_label1 145 ylabely_axis_label1 title1=strcat'Time=',num2strroundout.timek; titletitle1 holdon; plotx1,y1,'k.','MarkerSize',20,'Color','Green'; 150 holdoff; drawnow; Fcount=getframegcf; count=count+1; end 155 end video=VideoWriter'new_video','MPEG-4'; video.FrameRate=10; openvideo; 160 writeVideovideo,F; closevideo; 156

PAGE 169

ifpics_flag closeall; 165 k=lengthout.time; x=out.eff_pop_time,:,k; y=out.eff_pop_time,:,k; x1=out.eff_pop_time,1,k; 170 y1=out.eff_pop_time,1,k; idx=x>0|y>0; %idxofalivegroups x=xidx; y=yidx; plotx,y,'k.','MarkerSize',20; 175 axis[050050]; x_axis_label1=strcat'NumberofEffectiveCooperators'; y_axis_label1=strcat'NumberofEffectiveDefectors'; xlabelx_axis_label1 ylabely_axis_label1 180 title1=strcat'Time=',num2strroundout.timek; titletitle1 saveasgcf,'temp1.png' bin_counts=out.coop_hist:,k'; 185 histogram'BinEdges',bin_edges,'BinCounts',bin_counts ifn_types>5 %xticksbin_edges else 157

PAGE 170

xticksbin_edges1;xticklabelsbin_names1;xtickangle; 190 end %x_axis_label2=strcat'%cooperation'; xlabelx_axis_label2; y_axis_label2=strcat'PercentFrequency'; ylabely_axis_label2; 195 title2=strcat'HistogramofIndividualStrategies'; titletitle2; axis[-010001.1*maxbin_counts] saveasgcf,'temp2.png' 200 DataDensityPlotx,y,64; saveasgcf,'temp3.png' plotout.time:k,out.coop_time1:k x_axis_label3=strcat'Time'; 205 xlabelx_axis_label3; y_axis_label3=strcat'GlobalAverageGroupCooperation%'; ylabely_axis_label3; title3=strcat... 'GlobalAverageGroupCooperationCurrently:',... 210 {''},num2strroundout.coop_timek,'%'; titletitle3; axis[-1out.timek-1100]; saveasgcf,'temp4.png' 215 fprintf'n'; 158

PAGE 171

coop_sd=100*sqrtbin_counts/100*out.param.coop_vec.^2-... bin_counts/100*out.param.coop_vec.^2; 220 fid=fopen'ss_stats.txt','w'; fprintffid,'SSGlobalCooperationAverage:%3.1fn',... meanout.coop_timeround.9*k:k; fprintffid,'SSGlobalCooperationVariance:%3.1fn',coop_sd; fprintffid,'SSAverageNumberofGroups:%3.1fn',... 225 meanout.n_groupsround.9*k:k; fclosefid; end 230 closeall; end 159

PAGE 172

%File:sim_moran.m %functiontosimulatecontinuoustimemoranprocess 5 function[s,N,K,mean_time,var_time]=sim_morans,N,K %N=10;%groupsize %K=10;%numberofgroups %s=.1;%birthrateasymmetry 10 n_sims=1000; temp_fix=zerosK,1; temp_fix2=zerosK,1; fix_max=zerosn_sims,1; 15 fix_max2=zerosn_sims,1; rand_left=0; rand_right=0; fori=1:n_sims 20 forj=1:K n=floorN/2; %beginningposition t=0; t_steps=0; whilen>0&&n
PAGE 173

ifrand_left
PAGE 174

%File:sim_pgg_calc_approx_fix.m %functiontorunstochasticsimulationmodelfor %two )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 8.485 0 Td [(leveldynamicsmustfeeditaparameterobject 5 %calculatesfixationtime function[out]=sim_pgg_calc_approx_fixparam closeallforce 10 tic % \000\000\000\000)]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 82.909 0 Td [(Step1:EnterparametersHERE! \000\000\000\000)]TJ0 g 0 GETq1 0 0 1 104.812 372.323 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQq1 0 0 1 543.188 372.323 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQq1 0 0 1 104.812 348.343 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQq1 0 0 1 543.188 348.343 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQ1 1 0 0 k 1 1 0 0 KBT/F19 5.9776 Tf 90.732 355.537 Td [(15 %Parameterspassedtofunction %param.group_events=1; %0=groupeventsoff,1=groupeventson 20 param.fission_option=1; %linearingrouppopulation param.extinction_option=5; % \000\000\000\000)]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 82.909 0 Td [(Step2:Initialize \000\000\000\000)]TJ0 g 0 GETq1 0 0 1 104.812 108.542 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQq1 0 0 1 543.188 108.542 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQ1 1 0 0 k 1 1 0 0 KBT/F19 5.9776 Tf 90.732 115.736 Td [(25 vars.pop=zerosparam.n_types,param.max_groups; 162

PAGE 175

vars.pop:,1:param.initial_groups=round... param.initial_sd*param.initial_size*... 30 randn[param.n_typesparam.initial_groups]+... param.initial_size/param.n_types; %Setgroupswithnegativepopulationstozeros vars.popvars.pop:,1:param.initial_groups,1<0=0; 35 vars.group_pop=sumvars.pop; out.fixation_time=0; out.fixation_type=0; 40 out.n_alive_groups=0; %Setupvariablesthatchangeeachiteration vars.curr_time=0; vars.alive_groups=sumvars.pop>0; 45 vars.n_alive_groups=param.initial_groups; vars.extinct_groups=sumvars.pop==0; vars.n_extinct_groups=sumvars.extinct_groups; vars.birth_ind=zerosparam.n_types,param.max_groups; vars.brate=zerosparam.n_types,param.max_groups; 50 vars.death_ind=zerosparam.n_types,param.max_groups; vars.drate=zerosparam.n_types,param.max_groups; vars.frate=zeros,param.max_groups; vars.erate=zeros,param.max_groups; 163

PAGE 176

vars.ebrate=zerosparam.n_types,param.max_groups; 55 vars.rand_fission=zerosparam.n_types,param.max_groups; vars.rand_extinction=zerosparam.n_types,param.max_groups; vars.rand_birth=zerosparam.n_types,param.max_groups; vars.rand_death=zerosparam.n_types,param.max_groups; vars.end_idx=0; 60 vars.eff_pop=zeros2,param.max_groups; vars.prop=zeros1,param.max_groups; vars.alive_idx=[]; vars.total_pop=0; vars.type_pop=0; 65 vars.fix_flag=0; vars.update_time=0; vars.update_time1=0; vars.time_step=10; vars.t_grab_shots=[10100100010000]; 70 % \000\000\000\000)]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 82.909 0 Td [(Step3:Simulation \000\000\000\000)]TJ0 g 0 GETq1 0 0 1 104.812 264.378 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQq1 0 0 1 543.188 264.378 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQq1 0 0 1 104.812 240.398 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQq1 0 0 1 543.188 240.398 cm[]0 d 0 J 0.398 w 0 0 m 0 23.98 l SQ0.0 0.4 0.0 rg 0.0 0.4 0.0 RGBT/F55 10.9091 Tf 108 247.592 Td [(%out.pop_time:,:,1=vars.pop; 75 [param,vars,out]=simparam,vars,out; end function[param,vars,out]=simparam,vars,out 80 164

PAGE 177

%Initializesomevariables %idx=1; new_pop=zerosparam.n_types,1; 85 whilevars.fix_flag==0 vars.alive_idx=findvars.alive_groups==1; %Killthesimulationifthemaximumnumberofgroups 90 %hasbeenexceeded ifparam.max_groups
PAGE 178

%Calculateextinctionrate [param,vars]=gen_extinction_ratesparam,vars; 110 %Calculatemigrationrate [param,vars]=gen_migration_ratesparam,vars; %Updategrouppopulations 115 vars.group_pop=sumvars.pop; vars.alive_idx=findvars.alive_groups==1; %Nowgenerateexponentialrandomvariables %withthecalculatedrates 120 vars.rand_fission=-1./vars.frate:param.max_groups.*... logrand1,param.max_groups; vars.rand_extinction=-1./vars.erate:param.max_groups.*... logrand1,param.max_groups; vars.rand_birth=-1./vars.brate:,1:param.max_groups.*... 125 lograndparam.n_types,param.max_groups; vars.rand_death=-1./vars.drate:,1:param.max_groups.*... lograndparam.n_types,param.max_groups; vars.rand_migration=-1./vars.mrate:param.max_groups.*... logrand1,param.max_groups; 130 %Findtheminimumofeachevent'sRV min_birth=minminabsvars.rand_birth; min_death=minminabsvars.rand_death; min_fission=minabsvars.rand_fission; 166

PAGE 179

135 min_extinction=minabsvars.rand_extinction; min_migration=minabsvars.rand_migration; %Findtheminimumofallevents %thisistheeventthatoccurred 140 min_event=min[min_birthmin_deathmin_fission... min_extinctionmin_migration]; ifmin_event==min_birth %Nexteventisabirth %Findthetypeofbirthandthegroupwhereitoccurred 145 [type_idx,grp_idx]=findvars.rand_birth==min_birth; %GenerateauniformRVtoseeifthebirthwasamutation ifrand
PAGE 180

r=rand; ifr
PAGE 181

190 vars.extinct_groupsn_idx=0; vars.n_alive_groups=vars.n_alive_groups+1; forj=1:param.n_types ifvars.popj,grp_idx>0 195 new_popj=randivars.popj,grp_idx+1-1; else new_popj=0; end end 200 ifisemptyn_idx n_idx=vars.n_alive_groups+1; end vars.pop:,n_idx=new_pop; 205 vars.pop:,grp_idx=vars.pop:,grp_idx-new_pop; else %Nexteventisanextinction %Findwhichgroupwentextinct grp_idx=findvars.rand_extinction==min_extinction; 210 %Setpopulationtozero vars.pop:,grp_idx=0; %Addtolistofextinctgroups vars.extinct_groupsgrp_idx=1; 215 vars.n_alive_groups=vars.n_alive_groups-1; 169

PAGE 182

end %Killthesimulationifthemaximumnumber %ofgroupshasbeenexceeded 220 ifvars.n_alive_groups>param.max_groups error'Maximumnumberofgroupsreached' end %Updatethetimebasedontheeventthatoccurred 225 vars.curr_time=vars.curr_time+min_event; %Updateindex %idx=idx+1; 230 vars.popvars.pop<0=0; vars.extinct_groups=sumvars.pop<0.01; vars.n_extinct_groups=sumvars.extinct_groups; vars.alive_groups=1-vars.extinct_groups; vars.n_alive_groups=sumvars.alive_groups; 235 vars.total_pop=sumsumvars.pop; vars.type_pop=sumvars.pop,2; ifvars.fix_flag==0 240 ifsumsumvars.pop==vars.pop,:|... sumvars.pop==vars.pop,:==param.max_groups %ifsumvars.prop>param.c<1 170

PAGE 183

out.fixation_time=vars.curr_time; out.fixation_type=findvars.total_pop==vars.type_pop; 245 out.n_defect_groups=sumvars.pop,:~=0; out.n_coop_groups=sumvars.pop,:~=0; out.n_alive_groups=vars.n_alive_groups; vars.type_pop; vars.fix_flag=1; 250 end end ifvars.curr_time>vars.update_time1 %fprintf'Timerunning:%2.1fminutes, 255 %SimulationTime:%1.0fn',... %toc/60,vars.curr_time; vars.update_time1=vars.update_time1+100*vars.time_step; end 260 ifvars.curr_time>vars.update_time %fprintf'Timerunning: %%2.1fminutes,SimulationTime:%1.0fn',... %toc/60,vars.curr_time; vars.update_time=vars.update_time+vars.time_step; 265 ifminabsroundvars.curr_time-vars.t_grab_shots==0 plotvars.pop,findvars.alive_groups,... vars.pop,findvars.alive_groups,... 171

PAGE 184

270 'k.','MarkerSize',20; axis[01000100]; x_axis_label1=strcat'NumberofCooperators'; y_axis_label1=strcat'NumberofDefectors'; xlabelx_axis_label1 275 ylabely_axis_label1 title1=strcat... 'Time=',num2strroundvars.curr_time,',Groups=',... num2strvars.n_alive_groups; titletitle1 280 drawnow; saveasgcf,strcat't',num2strroundvars.curr_time,... '.png' else plotvars.pop,:,vars.pop,:,'k.','MarkerSize',20; 285 axis[01000100]; x_axis_label1=strcat'Numberof"Cooperators"'; y_axis_label1=strcat'Numberof"Defectors"'; xlabelx_axis_label1 ylabely_axis_label1 290 %title1=strcat'Time=',num2strroundvars.curr_time,', %Groups=',num2strvars.n_alive_groups; titletitle1 drawnow; end 295 end 172

PAGE 185

end end 300 function[param,vars]=gen_eff_birth_ratesparam,vars ifparam.birth_option==1 305 fori=1:param.n_types vars.birth_indi,:=param.b1+... param.b2*vars.eff_pop,:./vars.group_pop-.... param.b3*i-1/param.n_types-1; 310 vars.bratei,:=vars.birth_indi,:.*vars.popi,:; vars.death_indi,:=vars.group_pop*param.d1; vars.dratei,:=vars.death_indi,:.*vars.popi,:; end 315 end ifparam.birth_option==2 R=param.payoff,1;S=param.payoff,2; T=param.payoff,1;P=param.payoff,2; 320 vars.birth_ind,:=R*vars.pop,:+... S*vars.pop,:./vars.group_pop; vars.birth_ind,:=T*vars.pop,:+... 173

PAGE 186

P*vars.pop,:./vars.group_pop; 325 vars.brate,:=vars.birth_ind,:.*vars.pop,:; vars.brate,:=vars.birth_ind,:.*vars.pop,:; vars.brateisnanvars.brate=0; vars.death_ind,:=vars.group_pop*param.d1; 330 vars.death_ind,:=vars.group_pop*param.d1; vars.drate,:=vars.death_ind,:.*vars.pop,:; vars.drate,:=vars.death_ind,:.*vars.pop,:; end 335 %Don'tallowpopulationstogonegative temp_idx=vars.pop<=0&vars.ebrate<0; vars.ebratetemp_idx=0; 340 %Seteffectivebirthratesofextinctgroupstozero temp_idx=vars.group_pop==0; vars.ebrate:,temp_idx=0; end 345 function[param,vars]=gen_migration_ratesparam,vars vars.mrate=param.m1*vars.group_pop; 350 %turnoffmigrations 174

PAGE 187

vars.mrate=vars.mrate*param.group_events; end 355 function[param,vars]=gen_fission_ratesparam,vars %fission_option==1linearfission ifparam.fission_option==1 vars.frate=param.s*param.f1*vars.group_pop; 360 elseifparam.fission_option==2 vars.frate=param.f1*vars.eff_pop,:+... param.f2*vars.eff_pop,:; vars.fratevars.extinct_groups==1=0; end 365 %turnofffissions vars.frate=vars.frate*param.group_events; end 370 function[param,vars]=gen_extinction_ratesparam,vars ifparam.extinction_option==1 vars.erate=param.e1*vars.n_alive_groups*... 375 exp-param.e2*vars.group_pop*... expparam.e3*vars.n_alive_groups; vars.eratevars.extinct_groups==1=0; 175

PAGE 188

elseifparam.extinction_option==2 380 vars.erate=param.e1*vars.n_alive_groups*... exp-param.e2*vars.eff_pop,:+... param.e3*vars.eff_pop,:; vars.eratevars.extinct_groups==1=0; 385 elseifparam.extinction_option==3 vars.erate=param.e1*vars.n_alive_groups*... exp-param.e2*vars.eff_pop,:+... 390 param.e3*vars.eff_pop,:*... exp.005*vars.n_alive_groups; vars.eratevars.extinct_groups==1=0; elseifparam.extinction_option==4 395 keyboard vars.erate=param.e1*vars.n_alive_groups*... exp-param.e2*vars.eff_pop,:+... param.e3*vars.eff_pop,:; vars.eratevars.extinct_groups==1=0; 400 elseifparam.extinction_option==5 vars.erate=param.s*param.e1*vars.n_alive_groups./... vars.group_pop.^2; vars.eratevars.extinct_groups==1=0; end 176

PAGE 189

405 %turnoffextinctions vars.erate=vars.erate*param.group_events; end 410 function[param,vars]=calc_eff_coopparam,vars ifparam.birth_option==1 415 %calculateeffectivedefectors vars.eff_pop,:=param.n_types-1:-1:0/... param.n_types-1*vars.pop; %calculateeffectivecooperators vars.eff_pop,:=:param.n_types-1/... 420 param.n_types-1*vars.pop; end end 177

PAGE 190

%File:sim_simon_small_payoff.m %functiontosimulatewithnogroupeventsfora %givenpayoffmatrix 5 function[]=sim_simon_small_payoff tic flag=0; time=0; 10 payoff=[02;13/2]; R=payoff,1; S=payoff,2; T=payoff,1; 15 P=payoff,2; b1=1/18; d1=0.0015; 20 n_sims=10000; sims=zerosn_sims,1; n_groups=40; abs_c=0; 25 abs_d=0; 178

PAGE 191

n_birth=0; n_death=0; 30 fori=1:n_sims groups=zerosn_groups,1; fork=1:n_groups time=0; 35 nc=20; nd=20; flag=0; 40 whileflag~=1 nt=nc+nd; bc=b1*T*nd/nt+P*nc/nt*nc; bd=b1*R*nd/nt+S*nc/nt*nd; dc=d1*nc*nt; 45 dd=d1*nd*nt; r1=-logrand/bd; r2=-logrand/bc; r3=-logrand/dd; 50 r4=-logrand/dc; min_r=min[r1,r2,r3,r4]; 179

PAGE 192

55 ifr1==min_r nd=nd+1; n_birth=n_birth+1; elseifr2==min_r nc=nc+1; 60 n_birth=n_birth+1; elseifr3==min_r nd=nd-1; n_death=n_death+1; else 65 nc=nc-1; n_death=n_death+1; end time=time+min_r; 70 ifnc==0 flag=1; abs_d=abs_d+1; elseifnd==0 75 flag=1; abs_c=abs_c+1; end end 80 groupsk=time; 180

PAGE 193

end simsi=maxgroups; 85 end avg_time=meansims var_time=varsims 90 histsims abs_c/n_sims*n_groups abs_d/n_sims*n_groups avg_n_birth=n_birth/n_sims 95 avg_n_death=n_death/n_sims avg_ind_events=avg_n_birth+avg_n_death toc 181

PAGE 194

%File:sim_simon_small.m %functionthatisasmallstandalonesimulation %withnogroupevents 5 function[]=sim_simon_small tic flag=0; time=0; 10 b1=0.06; b2=0.0; b3=0.0; d1=0.0015; 15 n_sims=10; sims=zerosn_sims,1; 20 n_groups=40; abs_c=0; abs_d=0; n_birth=0; 25 n_death=0; 182

PAGE 195

fori=1:n_sims groups=zerosn_groups,1; 30 fork=1:n_groups time=0; nc=20; nd=20; nt=nc+nd; 35 flag=0; whileflag~=1 nt=nc+nd; 40 bc=b1+b2*nc/nt-b3*nc; bd=b1+b2*nc/nt*nd; dc=d1*nc*nt; dd=d1*nd*nt; 45 r1=-logrand/bd; r2=-logrand/bc; r3=-logrand/dd; r4=-logrand/dc; 50 min_r=min[r1,r2,r3,r4]; ifr1==min_r 183

PAGE 196

nd=nd+1; 55 n_birth=n_birth+1; elseifr2==min_r nc=nc+1; n_birth=n_birth+1; elseifr3==min_r 60 nd=nd-1; n_death=n_death+1; else nc=nc-1; n_death=n_death+1; 65 end time=time+min_r; ifnc==0 70 flag=1; abs_d=abs_d+1; elseifnd==0 flag=1; abs_c=abs_c+1; 75 end end groupsk=time; end 80 184

PAGE 197

simsi=maxgroups; end 85 avg_time=meansims var_time=varsims histsims abs_c/n_sims*n_groups 90 abs_d/n_sims*n_groups avg_n_birth=n_birth/n_sims avg_n_death=n_death/n_sims avg_ind_events=avg_n_birth+avg_n_death 95 toc 185

PAGE 198

%File:simondist.m %functiontoestimateparametersinvolvinginfinitesimalgen 5 clear tic n_int=50; N=120; %N2=N^2; 10 n1=20; n2=20; n_groups=40; [Q,coords]=gen_inf_gen_simonN; 15 N2=lengthcoords; idx=findcoords:,1==n1&coords:,2==n2; u=zeros,N2;uidx=1; 20 fprintf'nInfinitesimalGeneratorGeneratedN=%dn',N; %expectationandvarianceforonegroup ET=-u*invQ*onesN2,1; fprintf'nSingleGroupET:%1.3f%1.1fsecondsn',ET,toc; 25 VarT=2*u*invQ^2*onesN2,1-ET^2; 186

PAGE 199

fprintf'SingleGroupVarT:%1.3f%1.1fsecondsn',VarT,toc; Tmax=ET+10*sqrtVarT; %PT>Tmaxisverysmall. 30 fprintf'Tmax:%1.3f%1.1fsecondsnn',Tmax,toc; %expectationandvarianceforKgroups ETk=0;VarTk=0; %meanandvarofmaxfixtimeforKgroups 35 n_step=Tmax/n_int; n_int_steps=length:n_step:Tmax; step=0; Tval=zerosn_int_steps,1; Tval2=zerosn_int_steps,1; 40 fort=0:n_step:Tmax step=step+1; Tvalstep=--u*expmQ*t*onesN2,1^n_groups; Tval2step=2*t*--u*expmQ*t*onesN2,1^n_groups; 45 ifremstep-1,10==0 %fprintf...'Time:%1.3f,Value:%1.3f,Num.Int.Step%d/%d %%1.1fminutesn',t,Tvalstep,step )]TJ/F55 10.9091 Tf 8.485 0 Td [(1,n_int_steps )]TJ/F55 10.9091 Tf 8.485 0 Td [(1,toc/60; end 50 %ETk=ETk+ )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [( )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.031 0 Td [(u expmQ t onesN2,1^n_groups dt; %VarTk=VarTk+2 t )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.031 0 Td [( )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(u expmQ t onesN2,1^K dt; end 187

PAGE 200

55 simp_vec=2*onesn_int+1,1; simp_vecrem:n_int+1,2==0=4; simp_vec=1; simp_vecend=1; 60 simp_approx=sumsimp_vec.*Tval*n_step/3; simp_approx2=sumsimp_vec.*Tval2*n_step/3; simp_approx3=simp_approx2-simp_approx^2; std_approx=sumn_step*Tval; 65 fprintf'nMultipleGroupsETStandard:%1.3fn',std_approx; fprintf'MultipleGroupsETSimpson:%1.3fn',simp_approx; fprintf'MultipleGroupsVarTSimpson:%1.3fn',simp_approx3; ETk; VarTk; 70 VarTk=VarTk-ETk^2; fprintf'Totaltime:%1.1fminutesnn',toc/60; % 75 %BigN=N K;Bign=n K;%singlebiggrouptocompare %Q2=zerosBigN )]TJ/F55 10.9091 Tf 8.484 0 Td [(1,BigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1; %bigu=zeros,BigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1;biguBign=1; %u=zeros,BigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1;uBign=1;%Q=zerosBigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1,BigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1; %Q2,1= )]TJ/F55 10.9091 Tf 8.485 0 Td [(BigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1 +s/BigN;Q2,2=BigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1 +s/BigN; 80 %Q2BigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1,BigN )]TJ/F55 10.9091 Tf 8.484 0 Td [(2=BigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1/BigN; 188

PAGE 201

%Q2BigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1,BigN )]TJ/F55 10.9091 Tf 8.484 0 Td [(1= )]TJ/F55 10.9091 Tf 8.485 0 Td [(BigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1 +s/BigN; %fori=2:BigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(2 %Q2i,i )]TJ/F55 10.9091 Tf 8.484 0 Td [(1=BigN )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 8.485 0 Td [(i i/BigN; %Q2i,i= )]TJ/F55 10.9091 Tf 8.485 0 Td [(BigN )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 8.485 0 Td [(i i +s/BigN; 85 %Q2i,i+1=BigN )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 8.485 0 Td [(i i +s/BigN; %end %EBigT= )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 8.485 0 Td [(u invQ2 onesBigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1,1; %VarBigT=2 bigu invQ2^2 onesBigN )]TJ/F55 10.9091 Tf 8.485 0 Td [(1,1 )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(EBigT^2; %ANN,KK=ETk;BNN,KK=EBigT; 189

PAGE 202

APPENDIXB RCODE Author'snote: Rwasprimarilyusedinthisstudyforplotting,curvetting,and somestatisticalanalysis. FilenamePage analytical_results.R 191 mean_fix_times.R 193 neutral_plots.R 194 plot_ly_surface.R 196 plot_mut_functions.R 198 plot_neutral_all.R 200 plot_pmf.R 202 plot_smoothed_surfaces.R 203 var_fix_times.R 204 190

PAGE 203

#file:analytical _ results.R #thisfunctionplotsanalyticalresultsformultiplelevelsof , ! cooperation neutral_drift<-read_csv"~/Documents/MATLAB/fixationtimes/moran/ , ! neutraldrift/analytical_results.csv", 5 col_types=colsK=col_factorlevels=c"1" , ! ,"2","5","10","20","50","100" namesneutral_drift=c"s","group_size","K","mean_time","var_time" neutral_drift=neutral_drift[neutral_drift$K!="2",] 10 neutral_drift=neutral_drift[neutral_drift$K!="20",] neutral_drift$K=factorneutral_drift$K ggplotneutral_drift,aesx=group_size,y=mean_time,color=K,order=K , ! + geom_lineaeslinetype=K+ 15 geom_point+ labsx="GroupSizeN",y="MeanFixationTime",color="Kgroups",lty= , ! "Kgroups"+ themeplot.title=element_texthjust=0.27,size=12 neutral_drift2<-read_csv"~/Documents/MATLAB/fixationtimes/moran/ , ! neutraldrift/analytical_results2.csv", 20 col_types=colsgroup_size=col_factor 191

PAGE 204

, ! levels=c"10","50","100","500","1000" , ! ggplotneutral_drift2,aesx=logn_groups,y=mean_time,color=group_ , ! size,order=group_size+ geom_lineaeslinetype=group_size+ 25 geom_point+ labsx="logKgroups",y="MeanFixationTime",color="GroupSizeN" , ! ,lty="GroupSizeN"+ themeplot.title=element_texthjust=0.27,size=12 192

PAGE 205

#file:mean _ fix _ times.R #plotmeanfixationtimesonegroup )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(simulation libraryreadr 5 one_group_simulation
PAGE 206

#file:neutral _ plots.R #functiontoplotsymmetrictwo )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 8.485 0 Td [(leveldynamics libraryreadr 5 out_neutral_migrations<-read_csv"~/Documents/MATLAB/fixationtimes/ , ! simon/neutral/out_neutral_migrations.csv", col_names=FALSE log_fix_times=log10out_neutral_migrations$X3 log_m=log10out_neutral_migrations$X2 10 mig_subset=log_m>=-6&log_m<=-2 log_m=log_m[mig_subset] log_fix_times=log_fix_times[mig_subset] 15 migrations.df=data.framelog_fix_times,log_m ss3=smooth.splinelogm,logfixtimes,df=3 20 ggplotmigrations.df,aesx=log_m,y=log_fix_times+geom_point , ! + geom_smoothspan=1,se="false"+labsx="logmigrationrate",y="log , ! fixationtime" 194

PAGE 207

25 libraryreadr out_neutral_group_events<-read_csv"~/Documents/MATLAB/fixation , ! times/simon/neutral/out_neutral_group_events.csv", col_names=FALSE 30 log_fix_times=log10out_neutral_group_events$X3 s=out_neutral_group_events$X1 group_events.df=data.framelog_fix_times,s 35 ggplotgroup_events.df,aesx=s,y=log_fix_times+geom_point+ geom_smoothspan=1,se="false"+labsx="groupeventsparameter",y=" , ! logfixationtime" 195

PAGE 208

#file:plot _ ly _ surface.R #functiontoplotusingplot _ lyframework libraryreadr 5 approx_out2<-read_csv"~/Documents/MATLAB/approx_out4.csv" approx_out2$logm1=round*log10approx_out2$m1/10 s_values=sortuniqueapprox_out2$s logm1_values=sortuniqueapprox_out2$logm1 10 fix_values=matrix,lengths_values,lengthlogm1_values foriin1:lengthapprox_out2$logm1{ s_idx=whichs_values==approx_out2$s[i] logm1_idx=whichlogm1_values==approx_out2$logm1[i] 15 fix_values[s_idx,logm1_idx]=log10approx_out2$fixtime[i] } p<-plot_lyz=tfix_values,x=s_values,y=logm1_values,type=" , ! contour"%>% layouttitle="LogFixationtimes", 20 scene=list xaxis=listtitle="group_rate_param", yaxis=listtitle="log_migration_rate", zaxis=listtitle="fix_time" 25 p 196

PAGE 209

#chart _ link=plotly _ POSTp,filename="test" #chart _ link 197

PAGE 210

#file:plot _ mut _ functions.R #functiontoplotmutationpmfs libraryreadr 5 x1<-read_csv"~/Documents/MATLAB/x1.csv", col_names=FALSE x2<-read_csv"~/Documents/MATLAB/x2.csv", col_names=FALSE x3<-read_csv"~/Documents/MATLAB/x2.csv", 10 col_names=FALSE x4<-read_csv"~/Documents/MATLAB/x2.csv", col_names=FALSE n10x=x1$X1*10 15 n10y=x1$X2 n10.df=data.framen10x,n10y n100x=x2$X1*100 n100y=x2$X2 20 n100.df=data.framen100x,n100y n1000x=x3$X1*1000 n1000y=x3$X2 n1000.df=data.framen1000x,n1000y 25 n10000x=x4$X1*10000 198

PAGE 211

n10000y=x4$X2 n10000.df=data.framen10000x,n10000y 30 p0=ggplotn10.df,aesx=n10x,y=n10y+geom_point+xlab"i"+ , ! ylabexpressionT[i%->%N]+ylim,500+ scale_x_continuousbreaks=pretty_breaks:10,limits=c,10+ , ! geom_line p1=ggplotn100.df,aesx=n100x,y=n100y+geom_point+xlab"i"+ , ! ylabexpressionT[i%->%N]+ylim,1000+ scale_x_continuousbreaks=pretty_breaks:100,limits=c,100 , ! +geom_line p2=ggplotn1000.df,aesx=n1000x,y=n1000y+geom_point+xlab"i" , ! +ylabexpressionT[i%->%N]+ylim,1000+ 35 scale_x_continuousbreaks=pretty_breaks:1000,limits=c , ! ,1000+geom_line p3=ggplotn10000.df,aesx=n10000x,y=n10000y+geom_point p0 199

PAGE 212

#file:plot _ neutral _ all.R #functiontoviewvariousfixationtimeplots libraryggplot2 5 libraryplotly libraryreadr neutral<-read_csv"~/Documents/MATLAB/fixationtimes/simon/neutral/ , ! neutral_all.csv", col_names=c"s","m","fixtime","fixtype" 10 neutral$logm=log10neutral$m neutral$logft=log10neutral$fixtime m=lmlogft~polymlogm,s,degree=4,raw=TRUE,data=neutral 15 neutral$fitted=m$fitted.values s_values=sortuniqueneutral$s logm_values=sortuniqueneutral$logm 20 fix_values=matrix,lengths_values,lengthlogm_values foriin1:lengthneutral$logm{ s_idx=whichs_values==neutral$s[i] logm_idx=whichlogm_values==neutral$logm[i] 25 fix_values[s_idx,logm_idx]=neutral$fitted[i] 200

PAGE 213

} p<-plot_lyz=tfix_values,x=s_values,y=logm_values,type=" , ! contour"%>% colorbartitle="LogFixTime"%>% 30 layouttitle="EstimatedFixationTime", xaxis=listtitle="groupeventsparameter", yaxis=listtitle="logmigrationrate" p 201

PAGE 214

#file:plot _ pmf.R #functiontoplotmutationpmf librarylatex2exp 5 libraryggplot2 sigma2=0.1 p=0.5 mut=0.5 10 k=6 i=5 ci=:k-1/k-1 cin=0:k-1 m=repmut/k-1,k 15 m[i+1]=0 m[i+1]=1-mut ggplotdata=data.framex=roundci,2,y=m,yend=rep,k, aesx=roundx,2,y=y,xend=x,yend=yend+ 20 geom_point+geom_segment+ scale_x_continuousbreaks=roundci,2,limits=c,1+ labsx=expressionc[i],y=expressionmu[ij]+ scale_y_continuouslimits=c.0,1+ themeplot.title=element_texthjust=0.5, 25 text=element_textsize=15 202

PAGE 215

#file:plot _ smoothed _ surfaces.R #functiontoplotsmoothedsurfaces libraryreadr 5 no_migrations<-read_csv"~/Documents/MATLAB/no_migrations.csv" plotfixtime~s,data=no_migrations smoothingSpline=smooth.splineno_migrations$s,no_migrations$fixtime , ! ,spar=0.35 linessmoothingSpline,col="red",lwd=2 10 no_group_events<-read_csv"~/Documents/MATLAB/no_group_events.csv" plotfixtime~m1,data=no_group_events smoothingSpline=smooth.splineno_group_events$m1,no_group_events$ , ! fixtime,spar=0.35 linessmoothingSpline,col="red",lwd=2 15 no_group_events<-read_csv"~/Documents/MATLAB/combined.csv" plotfixtime~m1,data=no_group_events smoothingSpline=smooth.splineno_group_events$m1,no_group_events$ , ! fixtime,spar=1 linessmoothingSpline,col="red",lwd=2 203

PAGE 216

#file:var _ fix _ times.R #plotvariancefixationtimesonegroup )]TJ0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG0 g 0 G0.0 0.4 0.0 rg 0.0 0.4 0.0 RG/F55 10.9091 Tf 15.03 0 Td [(simulation libraryreadr 5 one_group_analytical<-read_csv"~/Documents/MATLAB/fixationtimes/ , ! moran/onegroup/simulationresults/simulation_results.csv", col_types=colss=col_factor levels=c"0","0.0001","0.001","0.01 , ! ","0.1" #cbPalette