M. Drew LaMar
March 2, 2022
Question #1: What dynamics of the system and what model outcomes
emerge - arise in relatively complex and unpredictable ways - from what behaviors of the agents and what characteristics of their environment?
Question #2: What other model dynamics and outcomes are instead
imposed - forced to occur in direct and predictable ways - by the model’s assumptions?
Discuss: Do the butterfly model’s corridor width results (system-level phenomenon) meet the three criteria for being emergent?
From Info
tab:
“This is a simple model of population genetics. There are two populations, the REDS and the BLUES. Each has settable birth rates. The reds and blues move around and reproduce according to their birth rates. When the carrying capacity of the terrain is exceeded, some agents die (each agent has the same chance of being selected for death) to maintain a relatively constant population. The model allows you to explore how differential birth rates affect the ratio of reds to blues.”
Using BehaviorSpace to run in silico experiments.
Question: Why do we need to run experiments?
Answer: When all parameters are fixed,
stochasticity in the system leads to results that are different each time it is run. Thus, we need to estimate the average results, as well as the variability around those averages.
Experiments allow us to include replicates of several different scenarios, where a scenario is the model with a specific set of parameters, initial conditions, and inputs.
Two main types of experiments:
The contrast scenario is most similar to typical experimental designs with a control and treatment.
mydata <- read.csv("Simple Birth Rates experiment-table.csv", header=TRUE, skip=6)
str(mydata)
'data.frame': 300 obs. of 6 variables:
$ X.run.number. : int 6 5 3 4 7 10 11 9 8 13 ...
$ carrying.capacity: int 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 ...
$ red.fertility : int 2 2 2 2 2 2 2 2 2 2 ...
$ blue.fertility : num 2.6 2.5 2.3 2.4 2.7 3 3.1 2.9 2.8 3.3 ...
$ X.step. : int 22 38 52 46 28 20 20 28 42 17 ...
$ ticks : int 22 38 52 46 28 20 20 28 42 17 ...
We need to replicate this figure:
First, we need the blue fertility values:
(bf.vals <- unique(mydata$blue.fertility))
[1] 2.6 2.5 2.3 2.4 2.7 3.0 3.1 2.9 2.8 3.3 3.4 3.5 3.2 2.2 3.7 3.8 3.6 3.9 4.1
[20] 4.0 4.2 4.4 4.3 4.5 4.7 4.6 4.8 4.9 5.0 2.1
Second, we need to compute the average ticks until red extinction.
N <- length(bf.vals) # How many bf.vals?
time.to.red.extinction <- rep(0,N) # Initialize
sdev <- rep(0,N)
for (i in 1:N) {
# Subset the data
tmp <- subset(mydata, mydata$blue.fertility == bf.vals[i])
# Compute average over subsetted data
time.to.red.extinction[i] <- mean(tmp$ticks)
# Compute standard deviation over subsetted data
sdev[i] <- sd(tmp$ticks)
}
Let's plot!
plot(bf.vals, time.to.red.extinction, pch=19, xlab="Blue fertility", ylab="Ticks until red extinction")
arrows(bf.vals, time.to.red.extinction-sdev, bf.vals, time.to.red.extinction+sdev, length=0.05, angle=90, code=3)