The motivation for my question is modelling changes in abundance of a species whose population is estimated from survey data. The challenge for me would be to see if ignoring a food indicator masks any population trend. Especially because I won't have every day surveyed in reality. There are two aspects I want to capture:
- the abundance should change over the year with a summer peak due to a breeding season.
- the abundance should also change with an indicator variable that shows whether the animals were clumped due to the presence of food or not.
What I have so far gets at the second point but not the first:
library(tidyverse) set.seed(123) day <- c(1:365) # day of the year precount <- rpois(365, 5) # basic counts when there's no food indicator <- sample(0:1, 365, replace = TRUE) # presence or absence of food extra <- rpois(365, 20) # additional number of individuals in the presence of food df <- data.frame(cbind(day, precount, indicator, extra)) # group it together df <- df %>% mutate(count = if_else(indicator == 1, precount + extra, precount)) %>% select(day,count,indicator) head(df) df[sample(nrow(df), 20), ] %>% arrange(day) # pick some random days