[R] Periodic regression - lunar percent cover

Tim Clark mudiver1200 at yahoo.com
Fri Apr 30 01:49:52 CEST 2010


Dear List,

I am trying include a lunar variable in a model and am having problems figuring out the correct way to include it.  I want to convert the percent lunar illumination (fraction of moon showing) to a combination of sin and cos variables to account for the periodic nature of the lunar cycle.  Would someone let me know if I am doing this correctly?  I have included the first 20 variables from my dataset as an example.  Y is count data and lp is the lunar percent cover.  The lunar period is 29.53.

y<-c(1, 3, 0, 0, 0, 0, 2, 4, 0, 1, 0, 5, 3, 2, 4, 2, 0, 1, 3, 5)
lp<-c(0.80, 0.88, 0.62, 0.19, 0.21, 0.01, 0.70, 1.00, 0.88, 0.04, 0.70, 0.93, 0.23, 0.99, 0.19, 0.79, 1.00, 0.03, 0.01, 0.00)
g1<-glm(y~cos((2*pi*lp)/29.530589)+sin((2*pi*lp)/29.530589))

Thanks,

Tim




Tim Clark
Department of Zoology 
University of Hawaii



More information about the R-help mailing list