---
title: Supplementary materials---Social contact patterns can buffer costs of forgetting in the evolution of
  cooperation
author:
- Jeffrey R. Stevens
- Jan K. Woike
- Lael J. Schooler
- Stefan Lindner
- Thorsten  Pachur
output:
  pdf_document:
    fig_caption: yes
    keep_tex: yes
header-includes:
- \usepackage{float}
- \usepackage{graphicx}
- \usepackage{lineno}
- \usepackage{multirow}
- \usepackage{rotating}
- \usepackage{setspace}
- \usepackage{subcaption}
- \captionsetup[subfigure]{justification=justified,singlelinecheck=false}
- \usepackage[numbers,square,comma,sort&compress]{natbib}
csl: prsb.csl
bibliography: ipd_contact.bib
---

<!--# Supplementary materials-->

# R packages

This project used `R` version 3.4.4, [@R2018] and the `R` packages *car* (version 3.0-0, [@Fox2011]), *ggplot2* (version 2.2.1, [@Wickham2016]), and *here* (version 0.1, [@Mueller2017]).

# Additional simulation methods

## Social network size
To assess the effect of different social network sizes on cooperation, we conducted a set of simulations in which we paired each agent not only with the other agents in their social network of 10 but also with a 'filler' agent.  This increased the total number of interactions experienced by the population agents. The filler agents had no strategy and we did not track their behavior or payoffs.  This allowed us to increase the number of intervening interactions between interactions for each pair to estimate the effects of larger social networks without the computational load of tracking an increased number of interactions.  We added 100, 400, and 1,400 filler interactions to the existing 100 core interactions to mimic social network sizes of 20, 50, and 150 partners. Figure 1b illustrates the original social network size (10 partners/100 interactions), plus these larger networks across the three contact pattern skews for the $\lambda = 0.87$, $\psi = 0.22$, skipping condition.


---
nocite: | 
  @Rapoport1965, @Axelrod1980b, @Nowak1992b, @Boyd1989, @Friedman1971, @Kraines1989, @Nowak1993, @Pachur2014, @Baker1987, @Kimura1978
...

\renewcommand{\thetable}{S\arabic{table}}
\setcounter{table}{0}
\renewcommand{\thefigure}{S\arabic{figure}}
\setcounter{figure}{0}

\begin{sidewaystable}[t]
\small
\caption{Decision rules determining each strategy's actions.}
 \begin{center}
  \begin{tabular}{cp{6cm}cccccccc} \hline
	Name & Strategy & Round 1 & Round $t - 2$ &  Round $t - 2$ &  Round $t - 1$ &  Round $t - 1$ & Reaction & Source \\
	& & & (Agent) & (Partner) & (Agent) & (Partner) & & \\ \hline
	ALLC & Always cooperate & C & * & * & * & * & C &  \\  \hline
	ALLD & Always defect & D & * & * & * & * & D \\  \hline
	TFT & \multirow{2}{6cm}{Tit-for-tat: cooperate in the first round, then copy partner's most recent move} & C & * & * & * & C & C & [5]  \\ 
	 &  & C & * & * & * & D & D &   \\ \hline
	TF2T & \multirow{3}{6cm}{Tit-for-two-tats: Like TFT but only reciprocates partner's defection following two consecutive defections} & C & * & D & * & D & D & [6]\\
	&  & C & * & * & * & C & C  \\
	&  & C & * & C & * & * & C \\  \hline
	GTFT & \multirow{2}{6cm}{Generous tit-for-tat: mirrors partner's move stochastically, with a higher probability of copying following cooperation ($p=0.99$) than following defection ($p=0.67$)} & C & * & * & * & C & 0.99C/0.01D$^{\dag}$ & [7] \\
	&  &C &  * & * & * & D & 0.33C/0.67D\hspace{1mm} &  \\ \\ \\ \\ \hline
	CTFT & \multirow{4}{6cm}[2mm]{Contrite tit-for-tat: behaves as TFT but forgives defection that was a response to a mistake on its part} & C & * & * & * & C & C & [8] \\
	&  & C & D & C & * & D & C \\
	&  & C & C & * & * & D & D \\
	&  & C & * & D & * & D & D \\  \hline
	GRIM & \multirow{3}{6cm}{Grim trigger or Friedman: cooperates until the other party defects once and then defects in all subsequent interactions} & C & * & * & * & D & D & [9] \\
	 &  & C & * & * & D & * & D \\
	&  & C & * & * & C & C & C \\  \hline
	WSLS & \multirow{4}{6cm}{Win-stay-lose-shift, Simpleton, or Pavlov: starts with a cooperative choice and then cooperates when, in the previous round, the actions matched (both cooperated or both defected) and defects when the actions did not match} & C & * & * & C & C & C & [5,10,11] \\
	  &  & C & * & * & C & D & D \\
	  &  & C & * & * & D & C & D \\
	&  & C & * & * & D & D & C \\ \\ \\  \hline
	RAND & Random: chooses randomly  & 0.5C/0.5D & * & * & * & * & 0.5C/0.5D \\ \hline
  \end{tabular}  
 \end{center}
\emph{Note}: * = any value would trigger the rule, C stands for cooperation and D for defection; numbers represent probabilities when reactions are stochastically determined. \\
 $^{\dag}$ We chose $p=0.99$ because Nowak and Sigmund (1992) found that this stochastic version of GTFT outperformed other stochastic variants in a simulation. But the results do not change if this probability is deterministic, $p=1.0$ (Figure S8).\\

\end{sidewaystable}

\clearpage
\begin{figure}[t]
  \centering
 \begin{subfigure}[t]{5in}
  \caption{}
  \includegraphics[width=5in]{figures/skew.png}
 \end{subfigure}
 \\
 \begin{subfigure}[t]{0.32\textwidth}
  \centering
  \caption{}
  \includegraphics[width=\textwidth]{figures/no_skew_matrix.png}
 \end{subfigure}
 \begin{subfigure}[t]{0.32\textwidth}
  \centering
  \caption{}
  \includegraphics[width=\textwidth]{figures/low_skew_matrix.png}
 \end{subfigure}
 \begin{subfigure}[t]{0.32\textwidth}
  \centering
  \caption{}
  \includegraphics[width=\textwidth]{figures/high_skew_matrix.png}
 \end{subfigure}
 \caption{(a) We tested three contact patterns in our simulation.  In the no-skew distribution, agents experienced 10 interactions with all 10 network members. In the low-skew distribution, agents experienced between 4-19 interactions with their network members. In the high-skew distribution, agents experienced between 1-33 interactions with their network members.  The high skew distribution mirrored an empirical estimate of contact frequency [11] with slight modifications based on the constraints of the simulation. Networks graphs of subsamples of the full networks illustrate example contact patterns for (b) no skew, (c) low skew, and (d) high skew. More interactions are illustrated by thicker lines in the edge connections.}
\end{figure}

<!-- Figure: Memory functions -->
\begin{figure}[h]
 \begin{center}
  \includegraphics[width=5in]{figures/memory_functions.png}
  \end{center}
 \caption{The probability of correctly remembering an interaction decreased with the number of intervening interactions. The curves were generated using the forgetting function: $p = \lambda(k + 1) ^{- \psi}$, where  $\lambda$ and $\psi$ specify the starting point and decay rate of the forgetting function, and $k$ represents the number of interactions between the target and the current interaction ($k=0$ if the target interaction was the most recent interaction).}
\end{figure}

<!-- Figure: Changed choices -->
\begin{figure}[t]
 \begin{subfigure}[t]{0.5\textwidth}
  \centering
  \caption{}
  \label{fig:COOPERATION}   
  \includegraphics[width=\textwidth]{figures/abs_change.png}
 \end{subfigure}
 \begin{subfigure}[t]{0.5\textwidth}
  \centering
  \caption{}
  \label{fig:ROBUST}   
  \includegraphics[width=\textwidth]{figures/net_change.png}
 \end{subfigure}
 \caption{Effects of skew, memory error type, and forgetting rate on action selection. We conducted a series of simulations that measured how forgetting changed the actions selected by agents. For each of four sets of memory parameters, two skew levels, and the two memory error types plus perfect memory, we conducted 20 first generation (i.e., with equal numbers of strategies) simulations and tracked the frequencies of the C and D actions selected by agents. We conducted 20 repetitions of the simulations in which we used the same social network structure (i.e., identical connections between agents/strategies) for all 24 of the skew/forgetting/memory error conditions. The 20 repetitions allowed us to average over stochasticity introduced by GTFT and RAND. We then conducted 1,000 replications with randomly chosen network structure. For each simulation, we compared actions under perfect memory with those under imperfect memory for both memory error types (guessing and skipping). We calculated the percent change in C actions ($\Delta_{C}$) and D actions ($\Delta_{D}$) from perfect to imperfect memory (with positive values representing a change toward cooperation and negative values representing a change toward defection). (a) Summing the absolute values ($abs(\Delta_{C}) + abs(\Delta_{D})$) gives the total percent change in actions---that is, how many differences in actions imperfect memory caused.  Guessing errors generated 4-5 times as many action changes than skipping errors. (b) We then calculated the net change in actions by summing the changes in C and D actions ($\Delta_{C} + \Delta_{D}$) to generate a percent shift toward cooperation.  Guessing errors resulted in large shifts toward defection, whereas skipping errors caused shifts toward more cooperation. Shaded areas highlight the empirically derived forgetting parameters.}
\end{figure}

<!-- Figure: Payoff matricies--cooperation -->
\begin{figure}[h]
 \begin{center}
  \includegraphics[width=6.5in]{figures/cooperation_matrix.png}
  \end{center}
 \caption{Effect of payoff matrix on cooperation. We used Axelrod's classic payoff matrix for the original analysis: CC=3, DC=5, CD=0, DD=1. To test the robustness of the findings to the payoff matrix, we conducted simulations with a new matrix (CC=4, DC=5, CD=0, DD=1) for a subset of the conditions (four sets of forgetting parameters, two memory error types, and two skew conditions) for 250 generations and 1,000 replicates. The new matrix increased cooperation, but skew and memory error types had similar effects as with the original matrix. Shaded area highlights the empirically derived forgetting parameters.  Standard error of the mean error bars are not shown because they are smaller than the data point symbols.}
\end{figure}

<!-- Figure: Payoff matrices--strategies -->
\begin{figure}[h]
 \begin{center}
  \includegraphics[width=6.5in]{figures/matrix_strategies.png}
  \end{center}
 \caption{Effect of payoff matrix on strategy frequency for TFT family and WSLS. We used Axelrod's classic payoff matrix for the original analysis: CC=3, DC=5, CD=0, DD=1. To test the robustness of the findings to the payoff matrix, we conducted simulations with a new matrix (CC=4, DC=5, CD=0, DD=1) for a subset of the conditions (four sets of forgetting parameters, two memory error types, and two skew conditions) for 250 generations and 1,000 replicates. The strategy frequencies differed between the two matrices, but the overall pattern remained the same: if there was a difference across skews, TFT family and WSLS were more frequent with high skew. TFT family was always more frequent than WSLS in both matrices. Shaded area highlights the empirically derived forgetting parameters.  Standard error of the mean error bars are not shown because they are smaller than the data point symbols.}
\end{figure}

<!-- Figure: Selection operators -->
\begin{figure}[h]
 \begin{center}
  \includegraphics[width=6.5in]{figures/cooperation_operator.png}
  \end{center}
 \caption{Effect of selection operator on cooperation. We used a standard roulette-wheel fitness selection operator for the original analysis. To test the robustness of the findings to the selection operator, we conducted simulations with two other selection operators using a subset of the conditions (two forgetting parameters, two memory error types, and two skew conditions) for 250 generations and 1,000 replicates. Stochastic universal sampling (SUS) is an unbiased selection operator that samples at evenly spaced intervals [13]. Truncation selection only samples from the top fraction of the population [14]: our simulation allowed the top 20 of the 90 agents to populate the next generation.  Though the specific cooperation levels varied between selection operators, the overall effects of skew and memory error types remained. Shaded area highlights the empirically derived forgetting parameters.  Standard error of the mean error bars are not shown because they are smaller than the data point symbols.}
\end{figure}

<!-- Figure: All strategy proportions -->
\begin{figure}[th]
 \begin{center}
  \includegraphics[width=6.5in]{figures/all_strategies.png}
  \end{center}
 \caption{Mean percentage of each strategy in the population varied based on level of skew in contact pattern (no skew, low skew, high skew), forgetting rate ($\lambda$ specifies starting point, $\psi$ specifies decay rate), and type of memory error (guessing or skipping).  Shaded area highlights the empirically derived forgetting parameters.  Standard error of the mean error bars are not shown because they are smaller than the data point symbols.}
\end{figure}

<!-- Figure: GTFT variants -->
\begin{figure}[h]
 \begin{center}
  \includegraphics[width=6.5in]{figures/cooperation_gtft.png}
  \end{center}
 \caption{Effect of different GTFT versions on cooperation. GTFT has a probability $p$ of cooperating following the partner cooperating. The primary analyses defined $p=0.99$ based on Nowak and Sigmund's (1992) stochastic simulation illustrated in their Figure 1. We also conducted deterministic simulations defining $p=1$ using a subset of the conditions (five forgetting parameters, two memory error types, and two skew conditions) for 250 generations and 1,000 replicates. These two values of $p$ yielded the same cooperation rates.}
\end{figure}

\clearpage
\newpage

# References
\bibliography{ipd_contact.bib}
