Simulating contests to determine the relative importance of correlated traits on the winning chances
Abstract
In intraspecific agonistic interactions, it is expected that traits that are more important in determining the winning chances should exhibit greater differences between winners and losers than traits that are less important. However, several of the traits used to determine the winning chances are correlated. When these traits vary in their importance to win, it becomes hard (if not impossible) to disentangle an effect due to trait correlation from the true effect of each trait on winning. To test the impact of trait correlation on the relative importance of each trait on winning chances, we developed an individual-based simulation model that investigates how different values of trait correlation and the relative importance of each trait impact the expression of trait differences between winners and losers. The simulation was made in R and generates traits according to a normal distribution. Traits are correlated with each other through the function rnorm_multi. In each iteration, the values are generated from scratch. Through many simulations, we see the same patterns emerge. We hypothesized that less important traits may show smaller winner-loser differences than more important traits for small trait correlation values. Surprisingly, we found that the most important trait for winning had a detectably larger difference between winners and losers than the less important trait for strong correlations (up to 0.9). Also, for correlation values around 0.5, it was harder to detect the difference between winners and losers, even for the trait that was more important in determining victory. We provide a suggested guide on how the patterns obtained in our model may be used to identify the relative importance of correlated traits on winning chances in empirical studies.
The stochastic model of agonistic interactions regarding code1.R
This is an individual-based simulation model, in which we establish scenarios combining different levels of correlation between attributes and their relative importance in determining Fighting Capacity. This model was used to investigate emerging patterns of differences between winners and losers for each attribute involved in the fight.
The correlated attributes used to exemplify the system were body size and weapon size.
Setting up the environment
These packages were used:
fauxdplyrtidyversebootsciplotggplot2ggthemesdevtools
Main function
The main function is called simulation.
Its parameters are:
cor.weapon.body: the value of the correlation between the traits weapon and bodyweapon.imp: the relative importance of the weapon size trait for the chance of winning a contestbody.imp: the relative importance of the body size trait for the chance of winning a contest. Since this is a consequential value ofweapon.impIt is calculated within the function.
Inside the function
The following empty vectors will store the corresponding data:
mean.body.win: the mean of the body size values of the individuals that wonmean.body.los: the mean of the body size values of the individuals that lostmean.weap.win: the mean of the weapon size values of the individuals that wonmean.weap.los: the mean of the weapon size values of the individuals that lostbody.diff: the difference between the mean body size of winners and losersweap.diff: the difference between the mean weapon size of winners and losers
Creating Individuals
group.1andgroup.2These are objects that store two sets of data. Thernorm_multiA function is used to create two correlated normal distributions.- The correlation value is set outside the function.
- One distribution represents body size, the other weapon size.
data.1Is the data frame where the information is stored?group.1andgroup.2are added to the data frame so each individual's body and weapon size is in a separate column.
Simulate fight
Each row of data.1 represents a fight between a pair of individuals.
data.1$FC.1anddata.1$FC.2: columns that store the Fighting Capacity of individuals fromgroup.1andgroup.2data.1$FCdiff: the difference between the Fighting Capacity ofgroup.1andgroup.2data.1$prob.win.cont: probability (between 0 and 1) of the individual fromgroup.1winning the fight
Determine winner
data.1$prob.win: stores a value of1or0depending on the win probability- A value of
1means the individual fromgroup.1won; a value of0means the individual fromgroup.2won
Store data about winners and losers
data.1$win.body: stores the body size of the winner- If
prob.winis1, it usesgroup.1; otherwise,group.2
- If
data.1$los.body: stores the body size of the loser- The opposite of the winner's source group
data.1$win.weap: stores the weapon size of the winner- If
prob.winis1, it usesgroup.1; otherwise,group.2
- If
data.1$los.weap: stores the weapon size of the loser- The opposite of the winner's source group
Determine differences between winners and losers
data.1$diff.body: stores the difference in body size between the winner and the loserdata.1$diff.weap: stores the difference in weapon size between the winner and the loser
Means
The following lists store the mean values from each iteration of the loop:
mean.body.win[m]: mean body size of winnersmean.body.los[m]: mean body size of losersmean.weap.win[m]: mean weapon size of winnersmean.weap.los[m]: mean weapon size of losersbody.diff[m]: mean difference in body size between winners and losersweap.diff[m]: mean difference in weapon size between winners and losers
The for loop ends here
Means and Confidence Intervals
mean.mean.body: mean across iterations for body size differencesmean.mean.weap: mean across iterations for weapon size differencesbody.mean.CI: confidence interval for body size differenceweap.mean.CI: confidence interval for weapon size differencedata.2: the return object from the simulation function. It includes:mean.mean.bodymean.mean.weapbody.mean.CIweap.mean.CI
The simulation function ends here
Applying the simulation function
func.valuesis an empty vector used in the loop to store output values- The loop index
iranges from 80 to 99- Each
iis divided by 100, resulting in correlation values from 0.80 to 0.99 (incremented by 0.01)
- Each
- The
weapon.impThe parameter can be adjusted, but in this example, it is set to0.5
Organize data for the figure
treatments: a list of labels (mean.mean.body,mean.mean.weap,body.mean.CI,weap.mean.CI) repeated 20 times (for the 20 simulations)correlations: labels for the correlation values corresponding to each outputdata.mix: a new data frame that combines the labels and their respective outputsdata.fig: a similar data frame where confidence intervals are moved to their own column to support figure creation
