[R] Circular variables within a GLM, GLM-GEE or GAM

Simon Wood s.wood at bath.ac.uk
Mon Jan 31 12:34:44 CET 2011


Clare, 

`gamm' with an nlme correlation structure uses a gee approach to correlation 
in the generalized case (it's just likelihood in the gaussian additive case, 
of course). See the `gamm' help files for examples. However this will usually 
run out of memory for datasets of size a few hundred to a thousand, unless 
you can split the data into smaller independent blocks (as in the last 
example in my book, ref in ?gam)

Simon

On Friday 21 January 2011 09:36, Clare Embling wrote:
> Hi Simon,
>
> Thanks for that!  Yes the circular variable is a predictor variable - great
> that it can be done using GAMs. I actually would like to do a GAM-GEE model
> - do you know if I can do this within R yet?  I'm using GLM-GEEs because I
> can't do GAM-GEEs (I have data collected over the same survey route
> repeatedly over time, so want to take into account the fact that my data
> are not independent - I'm modelling my correlation structure using an ar-1
> autoregressive correlation structure within a GEE). That way too, I can
> include my circular variables with circular smoothing functions as you
> suggested.
>
> Best wishes & thanks,
> Clare
>
> ________________________________________
> From: Simon Wood [s.wood at bath.ac.uk]
> Sent: 18 January 2011 17:58
> To: r-help at r-project.org
> Cc: Clare Embling
> Subject: Re: [R] Circular variables within a GLM, GLM-GEE or GAM
>
> Is the variable to be used as a predictor? If so mgcv::gam has a couple of
> circular smoother built in...
>
> s(x,bs="cc") or s(x,bs="cp")
>
> (if the range of x is less than the full  [0, 360] then you can supply a
> `knots' argument to gam to force the x range to go from 0 to 360, otherwise
> s(min(x), bs="c*") will be identical to s(max(x),bs="c*"), which may not be
> matching in the right place).
>
> Simon
>
> On Tuesday 18 January 2011 12:07, Clare Embling wrote:
> > Hi,
> >
> > I have a variable (current speed direction) which is circular (0=360
> > degrees), and I'd like my GLM to include the variable as a circular
> > variable.  Can I do this?  And what is the code?
> >
> > I'm actually doing a GLM-GEE using the 'geepack' package, so want to use
> > it in that, but also interested in whether it can also be used in GLMs
> > and GAMs (I use the 'mgcv' package for GAMs).
> >
> > Any help would be gratefully received,
> > Thanks in advance,
> >
> > :o) Clare
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html and provide commented,
> > minimal, self-contained, reproducible code.
>
> --
>
> > Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> > +44 1225 386603  www.maths.bath.ac.uk/~sw283

-- 
> Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> +44 1225 386603  www.maths.bath.ac.uk/~sw283



More information about the R-help mailing list