What are ways to deal with circular covariates (e.g. with a GAM)? I'm building a model in which several of my covariates live on a "circle", in the sense that they take values in the interval [0,1), and 0=1.  I'm wondering about techniques for dealing with this situation.  One idea is to represent a circular variable theta as a pair of variables ( sin(theta), cos(theta) ).  Any thoughts on this approach or better approaches?
I'm specifically using the mgcv package GAMs.  Is there a way to tell the model that certain additive pieces should have the same values at the endpoints?  Another package?
Thanks! 
 A: There are two ways of dealing with circular variables, one hacky method would be to manually duplicate your data set on either side of the boundary conditions but the more elegant solution I think would be to use the built-in spline basis functions with periodic boundary conditions !
For example:
bs="cc" specifies a cyclic cubic regression splines (see cyclic.cubic.spline). i.e. a penalized cubic regression splines whose ends match, up to second derivative.
Splines on the sphere
bs="sos". These are two dimensional splines on a sphere. Arguments are latitude and longitude, and they are the analogue of thin plate splines for the sphere. Useful for data sampled over a large portion of the globe, when isotropy is appropriate. See Spherical.Spline for details.
bs="cp" gives a cyclic version of a P-spline
A: You might want to look into Gill and Hangartner (2010). Circular Data in Political Science and How to Handle It. They talk about various models for circular/clock/seasonal data, and Jeff Gill provides R code for the paper which you can look into for inspiration. There should be a presentation version of this material which would weave the methodology and R code together.
