Introduction

This is a Tidy Tuesday project using data from the weekly social data project. This data tract 100 domesticated cats in the United Kingdom. It documents behavior such as hunting patterns, times indoors, age of cat, and several other characteristics. Using this data, we are looking to compare the hunting success of the cat and see if their age influences their success as hunters.

Domestic cats are natural hunters, and their tendency to catch prey can vary widely between individuals. One factor that may influence a cat’s hunting behavior is age. As cats grow older, their physical abilities, energy levels, and motivation to hunt can change. Younger cats, for example, may be more active and agile, making them more effective hunters. In contrast, older cats may hunt less frequently due to decreased stamina or health-related limitations.

Understanding how age affects hunting behavior in cats can provide valuable insights into feline research. It also helps explain some of the variation observed in prey-catching behavior across the cat population. In this study, we investigated the relationship between a cat’s age and the number of prey it catches, using data collected from domestic cats in the United Kingdom. Our goal is to better understand how this biological factor influences one of the most instinctive behaviors in domestic cats. The response variable is the hunting success of the cat and the explanatory variable is the age of the cat.

We were interested in the topic because we both really like cats and live in Philadelphia where there is a large amount of street cats. Although we looked at the data of domestic cats this still was of interest to us.

! Domestic Shorthair Cat catching it’s Prey

Set Up and Loading Data

knitr::opts_chunk$set(
    echo = TRUE,
    message = TRUE,
    warning = TRUE
)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
tuesdata <- tidytuesdayR::tt_load('2023-01-31')
## ---- Compiling #TidyTuesday Information for 2023-01-31 ----
## --- There are 2 files available ---
## 
## 
## ── Downloading files ───────────────────────────────────────────────────────────
## 
##   1 of 2: "cats_uk.csv"
##   2 of 2: "cats_uk_reference.csv"
tuesdata <- tidytuesdayR::tt_load(2023, week = 5)
## ---- Compiling #TidyTuesday Information for 2023-01-31 ----
## --- There are 2 files available ---
## 
## 
## ── Downloading files ───────────────────────────────────────────────────────────
## 
##   1 of 2: "cats_uk.csv"
##   2 of 2: "cats_uk_reference.csv"
cats_uk <- tuesdata$cats_uk
cats_uk_reference <- tuesdata$cats_uk_reference
cats_uk_reference
## # A tibble: 101 × 16
##    tag_id   animal_id animal_taxon deploy_on_date      deploy_off_date     hunt 
##    <chr>    <chr>     <chr>        <dttm>              <dttm>              <lgl>
##  1 Tommy-T… Tommy     Felis catus  2017-06-03 01:02:09 2017-06-10 02:10:52 TRUE 
##  2 Athena   Athena    Felis catus  2017-06-24 01:02:13 2017-06-30 23:59:32 TRUE 
##  3 Ares     Ares      Felis catus  2017-06-24 01:03:57 2017-06-30 23:58:01 NA   
##  4 Lola     Lola      Felis catus  2017-06-24 01:18:49 2017-06-30 09:04:40 TRUE 
##  5 Maverick Maverick  Felis catus  2017-06-25 01:04:35 2017-07-03 09:10:07 TRUE 
##  6 Coco     Coco      Felis catus  2017-06-28 01:02:22 2017-07-05 06:50:04 TRUE 
##  7 Charlie  Charlie   Felis catus  2017-06-28 01:03:33 2017-07-04 07:08:31 TRUE 
##  8 Jago     Jago      Felis catus  2017-06-28 04:10:59 2017-07-04 02:50:05 TRUE 
##  9 Morpheu… Morpheus  Felis catus  2017-07-01 01:02:18 2017-07-09 06:39:05 TRUE 
## 10 Nettle-… Nettle    Felis catus  2017-07-01 01:05:50 2017-07-08 00:05:12 TRUE 
## # ℹ 91 more rows
## # ℹ 10 more variables: prey_p_month <dbl>, animal_reproductive_condition <chr>,
## #   animal_sex <chr>, hrs_indoors <dbl>, n_cats <dbl>, food_dry <lgl>,
## #   food_wet <lgl>, food_other <lgl>, study_site <chr>, age_years <dbl>
cats_uk <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2023/2023-01-31/cats_uk.csv')
## Rows: 18215 Columns: 11
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (2): tag_id, study_name
## dbl  (5): event_id, location_long, location_lat, ground_speed, height_above_...
## lgl  (3): visible, algorithm_marked_outlier, manually_marked_outlier
## dttm (1): timestamp
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
cats_uk_reference <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2023/2023-01-31/cats_uk_reference.csv')
## Rows: 101 Columns: 16
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (6): tag_id, animal_id, animal_taxon, animal_reproductive_condition, an...
## dbl  (4): prey_p_month, hrs_indoors, n_cats, age_years
## lgl  (4): hunt, food_dry, food_wet, food_other
## dttm (2): deploy_on_date, deploy_off_date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
cats.df<- cats_uk_reference

Make Histograms and Testing for Normality

hist(cats.df$prey_p_month, main = "Prey Per Month Histogram", xlab = "Prey (per month)")

qqnorm(cats_uk_reference$prey_p_month)
qqline(cats_uk_reference$prey_p_month)

hist(cats.df$age_years, main = "Age of Cat", xlab = "Age of Cat (years)")

qqnorm(cats_uk_reference$age_years)
qqline(cats_uk_reference$age_years)

Making histograms and qqplots of the prey and age data to evaluate the normality of the data. The histogram of the prey data is very right skewed and not normally distributed. The qqplot of this data is also not normally distributed as it has this step-wise pattern and a majority of the points do not align with the qqline. The histogram of the age data is very right skewed as well and is not normally distributed. The qqplot of this data is also not normally distributed and has a similar step-wise pattern as the prey qqplot. Let’s see if a log transformation makes this data a little more normal!

Transforming Data

cats.df$logprey <- log(cats.df$prey_p_month)
cats.df$logage <- log(cats.df$age_years)
hist(cats.df$logprey)

hist(cats.df$logage)

Uh oh! The log transformation does not appear to fix our normality issue. The data looks more normal than it did prior to the transformation, but it’s still not great. Let’s try bining our variables into categorical variables.

Because we are using our variables as categorical variables for the remainder of the analysis, we are unable to assess our data by the mean, medians, standard deviations, and standard errors.

df2 <- cats_uk_reference[-23,]

cats_uk_reference<- cats_uk_reference %>%
  mutate(prey_p_month = case_when(
    prey_p_month <= 3 ~ "low success",
    prey_p_month >= 4 & prey_p_month < 10 ~ "moderate success",
    prey_p_month >= 10 ~ "high success"
  ))

cats_uk_reference <- cats_uk_reference %>%
  mutate(age_years = case_when(
    age_years <= 3 ~ "Young",
    age_years >= 4 & age_years < 10 ~ "Mature",
    age_years >= 10 ~ "Senior"
  ))

levels(cats_uk_reference$prey_p_month)
## NULL
levels(cats_uk_reference$age_years)
## NULL

Now, prey and age are grouped into 3 levels! These levels are in alphabetical order, let’s reorder them to be from youngest to oldest and lowest to highest hunting success.

is.factor(cats_uk_reference$age_years)
## [1] FALSE
cats_uk_reference$age_years <- as.factor(cats_uk_reference$age_years)
levels(cats_uk_reference$age_years)
## [1] "Mature" "Senior" "Young"
cats_uk_reference$age_years <- factor(cats_uk_reference$age_years, levels = c("Young", "Mature", "Senior"))
levels(cats_uk_reference$age_years)
## [1] "Young"  "Mature" "Senior"
is.factor(cats_uk_reference$prey_p_month)
## [1] FALSE
cats_uk_reference$prey_p_month <- as.factor(cats_uk_reference$prey_p_month)
levels(cats_uk_reference$prey_p_month)
## [1] "high success"     "low success"      "moderate success"
cats_uk_reference$prey_p_month <- factor(cats_uk_reference$prey_p_month, levels = c("low success", "moderate success", "high success"))
levels(cats_uk_reference$prey_p_month)
## [1] "low success"      "moderate success" "high success"

The variables are not recognized as a factor, so we will override these to be factors. Once they are factors, we can override the order using factor + the levels command. We recheck the levels to make sure they are reordered… Looks like it worked! Let’s make these variables into a table for further analysis.

catTable <- table(cats_uk_reference$prey_p_month, cats_uk_reference$age_years)
catTable
##                   
##                    Young Mature Senior
##   low success         26     43     12
##   moderate success     3      5      0
##   high success         7      3      1

Table looks good and the variables are in the correct order! Now, we will run a Chi-Squared test of independence.

Statistical Test (Chi-Squared Test of Independence)

expected_proportions <- c(0.33, 0.33, 0.33)
sum(catTable)
## [1] 100
newexpected <- 100 * expected_proportions
chisq.test(catTable, p = newexpected)
## Warning in chisq.test(catTable, p = newexpected): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  catTable
## X-squared = 5.5466, df = 4, p-value = 0.2357

We chosen the Chi-squared test of independence because it tests between two categorical variables in order to determine if there is a significant relationship. We are testing this data against our null hypothesis: there will be no significant relationship between age and hunting success. Our alternative hypothesis is there will be no significant relationship between age and hunting success.

From this test, we get a X-squared variable of 5.5466 and a p-value of 0.2357.

Plotting a Mosaic Plot

mosaicplot(catTable, color = c("darkred","orange","yellow"), xlab = "Hunting Success", ylab = "Age", main = "Mosaic Plot of Prey per Month vs Cat Age")

Conclusion

Based on the chi-square goodness-of-fit test, there is no statistically significant evidence to suggest that the amount of time domestic cats in the United Kingdom spend indoors affects the number of prey animals they catch (X² = 5.55, df = 4, p = 0.2357). Since the p-value is greater than the significance level (alpha) of 0.05, we fail to reject the null hypothesis that age does not influence hunting success of domestic cats. This suggests that the observed distribution of prey capture does not significantly differ from what would be expected if indoor time had no effect.

This analysis is important because it helps to clarify assumptions about domestic cats’ impact on wildlife based on their habits. Understanding these patterns is valuable for ecologists and pet owners who are concerned about conservation efforts and responsible pet ownership.

However, there are limitations to this analysis. The sample size (n = 100) may not have been large enough to detect smaller effects. Factors like the cats’ hunting experience, age, or local prey availability were not controlled. This could influence prey capture independently of indoor time. Future studies could benefit from a larger, more detailed dataset or increased sample size, and consider other influencing factors, such as type of community hunted (rural vs urban vs suburban

References

Kays R, Dunn RR, Parsons AW, Mcdonald B, Perkins T, Powers S, Shell L, McDonald JL, Cole H, Kikillus H, Woods L, Tindle H, Roetman P (2020) The small home ranges and large local ecological impacts of pet cats. Animal Conservation. doi:10.1111/acv.12563

McDonald JL, Cole H (2020) Data from: The small home ranges and large local ecological impacts of pet cats [United Kingdom]. Movebank Data Repository. doi:10.5441/001/1.pf315732

Pets Theater. (2022, February 15). Cats Catching Birds Video Compilation | Pets Theater. YouTube.https://www.youtube.com/watch?v=A93A2eORFnk

https://www.marsja.se/binning-in-r-create-bins-continuous/