I'd like to fit mixed models for polar coordinates. Each point represents the outcome of a trial in an experiment. Items and subjects will be crossed random effects. Fitting a model for the radius component is business as usual but I don't know how to approach the azimuth component. The problem is that 2pi and 0 specify the same point on a circle and that the difference between 2pi-0.1 and 0.1 is 0.2 rather than ~6.08. Is there a way to deal with that in lme4? R-seek didn't yield anything useful, maybe I used bad search terms. Thanks in advance for any advice! Best, Titus
Modeling polar coordinates
6 messages · Luciano Selzer, Luca Borger, Titus von der Malsburg +1 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20100818/609280eb/attachment.pl>
On Wed, Aug 18, 2010 at 12:37:23PM -0300, Luciano Selzer wrote:
I don't know if there's anything to deal with that builtin in lme4. But perhaps you could transform your polar coordinates to cartesian coordinates??
Hi Luciano. Thanks for the suggestion but using cartesian coordinates is unfortunately not possible. I have one map for each experimental item. Each subject contributes one point to each map. The maps where derived using multi-dimensional scaling (MDS) and the solutions of MDS are invariant to rotation. This means that x- and y-axis do not mean the same on those maps. One goal of modeling the polar coordinates is to find out how I have to rotate the maps in order to align them. The amount I have to rotate the maps would be given by the random intercept for items. Titus
Hello, unless I'm misunderstanding, isn't this one of those cases were you need to use circular regression methods? e.g. for an example: S. Rao Jammalamadaka and Ulric J. Lund (2006) "The effect of wind direction on ozone levels - a case study". Environmental and Ecological Statistics 13(3): 287-298 so to analyse a variable like day of the year you need to multiply it by 2*pi/365, then you can model it as a combination of sin and cos terms of the circualr variable in mixed effects models (please check the details for the polar coordinates - I think you can look up the examples where wind direction is modeled?). HTH Cheers, Luca ----- Original Message ----- From: "Titus von der Malsburg" <malsburg at gmail.com> To: "Luciano Selzer" <luciano.selzer at gmail.com> Cc: <r-sig-mixed-models at r-project.org> Sent: Wednesday, August 18, 2010 12:00 PM Subject: Re: [R-sig-ME] Modeling polar coordinates
On Wed, Aug 18, 2010 at 12:37:23PM -0300, Luciano Selzer wrote:
I don't know if there's anything to deal with that builtin in lme4. But perhaps you could transform your polar coordinates to cartesian coordinates??
Hi Luciano. Thanks for the suggestion but using cartesian coordinates is unfortunately not possible. I have one map for each experimental item. Each subject contributes one point to each map. The maps where derived using multi-dimensional scaling (MDS) and the solutions of MDS are invariant to rotation. This means that x- and y-axis do not mean the same on those maps. One goal of modeling the polar coordinates is to find out how I have to rotate the maps in order to align them. The amount I have to rotate the maps would be given by the random intercept for items. Titus
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
5 days later
Luca, thanks for these suggestions. Your pointers led me to two
packages that provide regression modeling for circular dependent
variables: CircStat and circular. The latter seems to be the
successor of the former. Unfortunately, these packages don't solve my
problem as they model a circular variable only as a function of one
circular or linear independent variable. The paper that you mention
uses CircStat.
Following the references in the documentation I found some papers by
statisticians that discuss possible solutions for the problem. E.g:
NI Fisher and AJ Lee, Regression Models for an Angular Response.
Biometrics, Vol. 48, No. 3 (Sep., 1992), pp. 665-677.
Unfortunately, my knowledge of the theory of generalized linear models
is insufficient to turn the information in those papers into a
solution. Please forgive me if the following is nonsense: The
proposed solution seems to come down to define an appropriate link
function that maps the linear predictor to the circular dependent
variable. However, as far as I can see, lmer only allows you to
select among a set of predefined link functions, none of which does
what I want, and I don't see how I can plug in custom link functions.
Your suggestion about using sin and cos combinations sounds
interesting, but your description is a bit too terse for me. Could
you please elaborate your idea a little bit? To make sure we're on
the same page: the circular variable is my dependent variable. The
predictors are linear.
Is this roughly what you propose?:
# This is the circular variable ranging from 0 to 2*pi:
x <- rnorm(100, pi, 0.5)
mer.cos <- lmer(cos(x) ~ 1 + factor + (1|subject), my.data.frame)
mer.sin <- lmer(sin(x) ~ 1 + factor + (1|subject), my.data.frame)
This is of course modulo some transformation that makes the residuals
being normally distributed. (Which would that be?)
Many thanks again,
Titus
On Wed, Aug 18, 2010 at 12:16:32PM -0400, Luca Borger wrote:
unless I'm misunderstanding, isn't this one of those cases were you need to use circular regression methods? e.g. for an example: S. Rao Jammalamadaka and Ulric J. Lund (2006) "The effect of wind direction on ozone levels - a case study". Environmental and Ecological Statistics 13(3): 287-298 so to analyse a variable like day of the year you need to multiply it by 2*pi/365, then you can model it as a combination of sin and cos terms of the circualr variable in mixed effects models (please check the details for the polar coordinates - I think you can look up the examples where wind direction is modeled?).
On Tue, 24 Aug 2010, Titus von der Malsburg wrote:
Your [Luca's] suggestion about using sin and cos combinations sounds interesting, but your description is a bit too terse for me. mer.cos <- lmer(cos(x) ~ 1 + factor + (1|subject), my.data.frame) mer.sin <- lmer(sin(x) ~ 1 + factor + (1|subject), my.data.frame) This is of course modulo some transformation that makes the residuals being normally distributed. (Which would that be?)
I can't see it being that simple. AFAICT (Song, Correlated Data Analysis), the Fisher and Lee model uses a tan(z/2) link function for the mean, *and* 1/2 sec^2(z/2) for the dispersion. You might be able to directly maximize the wrapped normal likelihood (from the circular package) for your model. Just 2c, David Duffy.
| David Duffy (MBBS PhD) ,-_|\ | email: davidD at qimr.edu.au ph: INT+61+7+3362-0217 fax: -0101 / * | Epidemiology Unit, Queensland Institute of Medical Research \_,-._/ | 300 Herston Rd, Brisbane, Queensland 4029, Australia GPG 4D0B994A v