Im running a few poisson GLMs looking at count data of bats sightings in relation to lunar cycle.
We specifically want to look at how species are affected leading up to and away from new moon/full moons.
I am able to get lunar cycle in both radians as well as categorical variables using the lunar package, however I am bit concerned that using either violates the assumption of poisson models.
Lunar cycle is not ordinal, rather it is cyclical. The radian values for example treat new moons as values between 0-.7 as well as 5.5-6.6 because there is the time period leading up to the new moon and the time period after the new moon.
I could use the radian values, but I think I would run into the same issues? Where a value of 6.6 (Full new moon) is then proceeded by a value of say .01 in real life the next day.
Is there a way to transform the data to represent it in a poisson model accurately?
Reproducible example:
library(lunar)
#Example of a vector of dates passed through lunar
dates = as.Date(c('6/27/2022','6/28/2022','6/29/2022','6/30/2022',
'7/1/2022','7/2/2022','7/3/2022','7/4/2022','7/5/2022','7/6/2022','7/7/2022',
'7/8/2022','7/9/2022','7/10/2022','7/11/2022','7/12/2022','7/13/2022','7/14/2022',
'7/15/2022','7/16/2022','7/17/2022','7/18/2022','7/19/2022','7/20/2022','7/21/2022',
'7/22/2022','7/23/2022','7/24/2022','7/25/2022','7/26/2022','7/27/2022','7/28/2022'),
format = '%m/%d/%Y')
lunar_df <- data.frame(radian = lunar.phase(dates),
phases_4 = lunar.phase(dates, name = 4),
phases_8 = lunar.phase(dates, name = 8))
lunar_df
#example truncated datasets I am working with
df1 <- data.frame(species = rep("A. intermedius",5),
lunar_phase = c("New Moon","Waxing Quarter","Full Moon","Waning Quarter","New Moon"),
lunar_phase_radian = c(.06,1,3,4,5.6),
count = c(10,5,6,8,9))
df2 <- data.frame(species = rep("A. jamaicensis",5),
lunar_phase = c("New Moon","Waxing Quarter","Full Moon","Waning Quarter","New Moon"),
lunar_phase_radian = c(.06,1.9,3.1,4.2,6.6),
count = c(8,2,3,7,10))
df3 <- data.frame(species = rep("C. sowellii",5),
lunar_phase = c("New Moon","Waxing Quarter","Full Moon","Waning Quarter","New Moon"),
lunar_phase_radian = c(.06,1.4,2.5,3.89,5.9),
count = c(12,5,10,7,3))
df <- rbind(df1,df2,df3)
glm(count ~ lunar_phase + species, data = df, family = "poisson")
count ~ cos(lunar_phase) + sin(lunar_phase) + species, and then via the regression you can back this out into amplitude/phase, see Cox, 2006 for example. Hopefully someone comes and gives a better example with your data, offhand looking at the scatterplot not the greatest fit but may be passable (tough with a small sample size). I am sure it has come up before on site, will try to find examples. – Andy W Jul 17 '22 at 13:55sin(lunar_phase_radian)andcos(lunar_phase_radian)as predictors in your glm. Try those suggestions, and then consider posting the result as an answer to your question. That's OK on this site, and will be helpful to future visitors. You can eventually accept your answer (although you have to wait 48 hours). – EdM Jul 17 '22 at 15:22