Today’s investigation. A standard rule in nature is that of surviving. As a result, both predator and prey populations are under constant selective pressure; the former evolving adaptations to trap prey and the latter evolving counter-adaptations against predators. This ongoing evolutionary arms race shapes the distribution of prey in space, a concept known as “Landscapes of Fear”. Identifying the factors shaping the landscape of fear of a prey population provides valuable information about the way they see and interpret their environment. One way to study these factors is through the analysis of population proportions using the binomial test. Today, we will examine hypotheses about the drivers of landscapes of fear in Amazonian bird flocks using field data from CSULB Avian Ecology Lab.


Introduction

In this lab we will examine hypotheses about population proportions using binomial probabilities in order to identify important drivers of landscapes of fear in Amazonian bird flocks. The landscape of fear is an ecological concept that defines the level of fear of predation a prey experiences across its home range (Laundré et al.; Figure 1). This concept assumes that animals have the ability or can learn to differentiate dangerous habitats from safer ones. For many bird species, the major factor affecting their landscape of fear is their ability to interpret alarm calls. This is significant for eavesdropping birds that use the behavioral cues of other neighbors to mitigate risk without the cost of gathering information by themselves. Interpreting these calls from sentinel birds allows them to distinguish the presence of particular predators with direct consequences on fitness.

Today, we will examine hypotheses about population proportions in order to estimate the probability of sentinel birds to produce an alarm call. For this, we will use CSULB Avian Ecology Lab data from field experiments lead by Dr. Ari Martínez on Amazonian birds (Figure 1). In his experiments, Dr. Martínez used trained raptors to examine the extent to which different alarm calling birds produced alarm calls in their presence and evaluated different predator contexts. So, let’s explore the binomial distribution and how the binomial test is a useful statistical tool for testing whether the relative frequency of alarm calls produced - or successes - in the presence of a raptor matches a null expectation.


**Figure 1. Theoretical landscape of fear and studied Amazonian birds**. The *x*- and *y*-axis represent the physical coordinates of the study area. The predation risk is measured as indices of fear, e.g. vigilance. From this example, we can conclude that the intensity of space used by the prey population (colors) correlates negatively with predation risk. The landscape of fear is studied by CSULB Avian Ecology Lab using a system of eavesdropping and setinel Amazonian birds: (A) Dusky-throated Antshrike (sentinel), (B) White-eyed Antwren and (C) Carmiol's Tanager (eavesdropping). Images: Ari Martínez and Juan Pablo Bueno.

Figure 1. Theoretical landscape of fear and studied Amazonian birds. The x- and y-axis represent the physical coordinates of the study area. The predation risk is measured as indices of fear, e.g. vigilance. From this example, we can conclude that the intensity of space used by the prey population (colors) correlates negatively with predation risk. The landscape of fear is studied by CSULB Avian Ecology Lab using a system of eavesdropping and setinel Amazonian birds: (A) Dusky-throated Antshrike (sentinel), (B) White-eyed Antwren and (C) Carmiol’s Tanager (eavesdropping). Images: Ari Martínez and Juan Pablo Bueno.


Upon completion of this lab, you should be able to:


References


Worked example

To get started, let’s define the binomial distribution and its assumptions:


1. Estimating the binomial formula

The binomial formula gives the probability of X successes in n trials, where the outcome of any single trial is either success or failure. Thus, we employ the binomial distribution when we are testing the probability of two outcomes, exclusively, or two mutually exclusive events. Recall from Chapter 4 that mutually exclusive events cannot both occur at the same time and their probabilities add to 1.

The probability of getting X successes in n trials is

\(\Pr[X\ successes] = \frac{n!}{X!(n-X)!}p^X(1-p)^{n-X}\),


where X is the number of successes, n is the number of independent trials, and p is the probability of success in every single trial.

Keep in mind that the binomial coefficient \(\frac{n!}{X!(n-X)!}\) represents the number of combinations in which we can get X successes from n trials.

For example, let’s say we randomly sample n = 4 salamanders from a population. There are 16 possible combinations of successes (represented by 1) and failures (represented by 0) we can obtain with 4 independent trials:


[1111; 0111; 1011; 0011; 1101; 0101; 1001; 0001; 1110; 0110; 1010; 0010; 1100; 0100; 1000; 0000]


If we define success here as body color = red, the number of combinations in which we can get exactly 1 success, or 1 red salamander, out of 4 independent trials is 4 [0001; 0010; 0100; 1000]. Thus, the binomial coefficient when X = 1 and n = 4 is 4 or \(\frac{4!}{1!(4-1)!}\). From the binomial formula above, is obvious that binomial probabilities also depend on p, or the probability of success in each trial. Assuming there is 65% chance that an individual salamander is red in any given trial (p = 0.65), then we can say that the probability that exactly 1 of the salamanders in our sample population is red is

\[ \begin{aligned} \Pr[1\ red\ salamander]&=\frac{4!}{1!(4-1)!}(0.65)^1(1-0.65)^{4-1}\\\\ &=0.1115 \end{aligned} \]


2. Estimating the binomial probability distribution

According to this, there is 11% chance of getting exactly 1 red salamander out of 4 independent trials. If we continue, we can estimate all the probabilities of the sampling distribution with n = 4 and p = 0.65. For our salamander example, it looks like this:

Figure 2. Probability distribution of successes for sample size *n* = 4 and probability *p* = 0.65.

Figure 2. Probability distribution of successes for sample size n = 4 and probability p = 0.65.

Because the probability of getting a red salamander per trial is relatively high (65%), we can expect to have a low probability (11%) of finding just 1 out of 4 trials!


3. Estimating the standard error of a proportion

The precision of our estimates of population proportions can be calculated. Say that we perform the 4 independent trials in our salamander population and get 3 red salamanders. In this case, the actual estimate of the proportion of red salamanders in this sample population is


\(\hat{p}=\frac{X}{n}\)

For our example,


\[ \begin{aligned} \hat{p}&=\frac{3}{4}=0.75\\\\ \end{aligned} \]

where \(\hat{p}\) represents the sample proportion, in contrast to the true proportion in the population. We often do not know p but we can approximate the standard error using \(\hat{p}\) in the following way:


\(SE_\hat{p}=\sqrt{\frac{\hat{p}(1-\hat{p})}{n}}\)

For our example,
\[ \begin{aligned} SE_\hat{p}&=\sqrt{\frac{0.75(1-0.75)}{4}}=0.217 \end{aligned} \]


Thus, the standard error of the estimate of the proportion who are red is 0.217. Remember from Chapter 4 that the SE is a measure of spread (the standard deviation of the sampling distribution). In other words, our sample estimate (\(\hat{p}\)) on average is ± 0.217 from the population proportion (p).


4. Testing hypotheses: the binomial test

We can also use the binomial distribution to test whether the relative frequency of successes in the population (p) matches a null expectation \(p_{0}\). For this, we follow the same steps to estimate the binomial formula but assuming p = \(p_{0}\) and testing whether the resulting p-value is below the conventional significance level of \(\alpha\) = 0.05.

For example, say we expect color to be equally distributed in salamanders and thus we expect 50% of the salamanders to be red by chance and the other 50% to be not red:

Following the example above were we found 3 red salamanders out of 4 independent trials, the probability of getting 3 or more red salamanders assuming the null hypothesis is true is the sum over these mutually exclusive binomial probabilities of having 3 or more red salamanders in a trial of 4:


\[ \begin{aligned} Pr[number\ of\ succsesses \ge 3]&=Pr[3]+Pr[4]=0.313 \end{aligned} \]


Because this is a two-tailed test, we account for all extreme values at both tails by doubling this probability to get the p-value:
\[ \begin{aligned} p&=(2)(0.313)=0.626 \end{aligned} \]


We can see p is well above the significance level and thus we do not reject the null hypothesis and conclude that the probability that a salamander is red is 50%.


Info-Box! In Chapter 5, we learned how to document our results in any report or manuscript. Here we add another information; degrees of freedom:

  • test statistics
  • degrees of freedom
  • sample size
  • p-value

For example, the results from the Worked Example, part 4, could be reported as: The proportion of red salamanders is not different from the proportion of salamanders with other color (\(\hat{p}=0.75\), n = 4, df = 3, p-value = 0.63).



Materials and Methods

Today’s activity Avian Alarm Calls in the Tropics is organized into two main exercises testing different hypotheses about the proportion of sentinel birds making alarm calls in the presence of predators using the binomial distribution and associated tests. These exercises will also motivate inferences about the factors shaping the landscape of fear of Amazonian bird flocks.



Avian Alarm Calls in the Tropics


Research question 1: Does the presence of a predator increases the proportion of alarm calls produced by sentinel birds?

1. Import the data Let’s start by importing the “alarm” dataset to RStudio and exploring it.


Questions:

  1. How many variables and observations does “alarm” have?
  2. Considering the research question, what are our variables of interest?
  3. Considering our response variable, what represents a success?


2. Estimate the binomial formula

Let’s first estimate the variables needed for the binomial formula; X, n, and p. Because the research question does not differentiate between predator attributes, let’s analyze the data assuming no difference among predators (raptors in this case).

First, we need to make sure we differentiate between predator trials and control trials (i.e., no predator) by filtering our data.

# levels in the variable RAPTOR
levels(as.factor(alarm$RAPTOR))

# filtering "alarm" for control trials only 
library(tidyverse)
control <- filter(alarm,RAPTOR=="CONTROL")

# filtering "alarm" for raptor trials only 
raptor <- filter(alarm,RAPTOR!="CONTROL")


Let’s estimate the binomial formula using the data in “raptor”.

# number of trials n 
n <- length(raptor$RAPTOR)

# number of successes X (alarms)
X <-sum(raptor$Alarm_Call)

# observed proportion of successes in sample population p_hat
p_hat <- X/n


Now that we have all the variables needed to estimate binomial distributions, let’s use the function dbinom() to estimate the binomial formula. The first argument in this function is X, the second is n, and the third is p_hat.

# example: the probability of getting exactly 100 alarm calls with n=337 and p_hat=0.303.
dbinom(100,n,p_hat)

According to this, there is about 5% chance that exactly 100 birds out of 337 randomly sampled birds will produce an alarm call in the presence of a raptor.


3. Estimate the binomial probability distribution

We can use this same function dbinom() to get all the possible binomial probabilities for all values in n.

# all possible values of X out of n trials
X_success <- 0:n
X_success 

# binomial probabilities (same function as above)
prob_X <- dbinom(X_success, n, p_hat)
prob_X


To plot the binomial probability distribution using ggplot2, we need to first create a dataframe with the probabilities.

# generating a dataframe with X_success and binomial probabilities for the plot
probTable <- data.frame(X_success, prob_X)
probTable

# binomial probability distribution plot
library(ggplot2)

p1 <- ggplot(probTable,aes(x=X_success,y=prob_X)) +
  geom_bar(stat = "identity") +
  ylab("Probability") +
  xlab("Number of alarm calls") +
  theme_classic(20)
p1


Questions:

  1. What is the probability that about 120 sentinel birds out of 337 trials produce an alarm call?
  2. What is the number of alarm calls with the highest probability?


4. Estimate the standard error of the proportion.

We can estimate the standard error of “p_hat” using the squared root function sqrt(). We can do it step by step, or all at once as below.

# standard error of p
SE <- sqrt((p_hat*(1-p_hat))/n)
SE

According to this, 0.30 ± 0.03 sentinel birds (mean±SE) produce an alarm call in the presence of raptors.


5. Test the hypothesis using the binomial test.

We estimated the binomial probabilities given X, n, and p. This is different from testing a hypothesis, which requires a null probability of success \(p_0\) and a p-value.


Stop, Think: In this case, we have information about the proportion of sentinel birds producing an alarm call during a control trial. During a control trial, a researcher would stand at the same distance as in a raptor trial from the bird flock and carry out the same gesture as if he/she was releasing a trained raptor. However, there was no raptor involved in the trial. Stop and review the definition of a null hypothesis. Think about why the researcher would simulate the same gesture in a control trial.


If fact, we can use the information from the control trials to build our null hypothesis. If we estimate the proportion of sentinel birds producing an alarm call during a control trial, we can use such proportion as our expected proportion of birds producing alarm calls (\(p_0\)) when a researcher is standing close to the flock, independently of the presence of a raptor.

# proportion of birds producing alarm calls in a control trial
p_null <- sum(control$Alarm_Call)/length(control$RAPTOR)
p_null


Considering our research question, our null and alternative hypotheses are:

\(H_0\): In the presence of raptors, 3.125% of sentinel birds produce an alarm call.

\(H_A\): In the presence of raptors, the proportion of sentinel birds producing an alarm call is not 3.125%.


In R, we can use the function binom.test() to carry out a binomial test. Similar to dbinom(), the three arguments in the function are X, n, and p_null.

# binomial test
binom.test(X, n, p_null)

According to this, the probability of success is not equal to 3.125% and thus, we reject the null hypothesis (p-value < 0.0001).


Questions:

  1. Does the presence of a predator increases the proportion of alarm calls produced by sentinel birds?
  2. Can we make an argument that raptors are a major driver shaping the landscape of fear of Amazonian birds?


Research question 2: Is raptor size a visual cue driving the proportion of sentinel birds producing alarm calls?


Stop, Think, Do: Now, it is your turn to test this hypothesis about raptor size. Stop and review the steps 2-5 you just did. Think about how to manage the “raptor” data set to obtain the data needed to address the research question. Do the analysis following the demonstration codes and answer the research question! Super Hint: Create a new dataframe filtering “raptor” by SIZE==“small” and follow the steps above using the same null hypothesis.


Discussion questions

  1. Define and interpret successes in binomial trials.
  2. For research question 2, state your null hypothesis and estimate the p-value.
  3. How precise is your estimate of the population proportion?


Great Work!