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:

  1. the abundance should change over the year with a summer peak due to a breeding season.
  2. 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:


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)) %>% 
df[sample(nrow(df), 20), ] %>% arrange(day) # pick some random days

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.