1 Cuckoo dataset

The common cuckoo does not build its own nest: it prefers to lay its eggs in another birds’ nest. It is known, since 1892, that the type of cuckoo bird eggs are different between different locations. In a study from 1940, it was shown that cuckoos return to the same nesting area each year, and that they always pick the same bird species to be a “foster parent” for their eggs.

Over the years, this has lead to the development of geographically determined subspecies of cuckoos. These subspecies have evolved in such a way that their eggs look as similar as possible as those of their foster parents.

The cuckoo dataset contains information on 120 Cuckoo eggs, obtained from randomly selected “foster” nests. For these eggs, researchers have measured the length (in mm) and established the type (species) of foster parent. The type column is coded as follows:

  • type=1: Meadow pipit
  • type=2: Tree pipit
  • type=3: Dunnock
  • type=4: European robin
  • type=5: White wagtail
  • type=6: Eurasian wren

2 Goal

The researchers want to test if the type of foster parent has an effect on the average length of the cuckoo eggs.

In theory, they want to study this for all six species. However, a t-test can only be used to study mean differences between two groups. If we want to analyze multiple groups, there are two options.

  1. We perform t-tests on all pairwise combinations of types. This mean we need to perform n*(n-1)/2 = 15 t-tests.

  2. We perform an ANOVA analysis.

The second strategy is much more efficient and has a higher statistical power. We will learn about ANOVA in chapter 7.

In the current tutorial, we will assess a single pairwise comparison, between the European robin and the European wren. In later tutorials, we revisit this dataset and analyse all data.

Load the required libraries

3 Import data

4 Tidy data

For this exercise, we only care about the European robin and the Eurasian wren. Therefore, we can remove the observations of the other types. In addition, it seems that the tpye column rather than a factor. Let’s fix this:

Cuckoo <- Cuckoo %>%
  filter(type %in% c("4","6")) %>%
  mutate(type = as.factor(type))

5 Data exploration

How many birds do we have for each type?

Cuckoo %>%
  count(...)

# in base R, you could use the table function

Visualize the data using a suitable strategy

  1. What do you observe?

  2. How will you model the data?

  3. Translate the research question in a null and alternative hypothesis

  4. Which test will you use to assess the research hypothesis?

  5. Formulate the assumptions of the test and assess the assumptions using diagnostic plots.

  6. If all assumptions to perform the test, complete the analysis and formulate a proper conclusion.

LS0tCnRpdGxlOiAiRXhlcmNpc2UgNS4zOiBIeXBvdGhlc2lzIHRlc3Rpbmcgb24gdGhlIGN1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