[R] Circular Mean Question

Michael Peckford michael.peckford at acadiau.ca
Tue Jun 28 19:34:33 CEST 2005


Hi, a question about the circular mean function in the package
CircStats:

Can anyone shed some light on why the circ mean function seems to make
sense for the first 2 set of bearings and then the mean of 225 and 45
degrees gives an unexpected 180 deg. 

> deg(circ.mean(c(rad(222),rad(45))))%%360
[1] 133.5
> deg(circ.mean(c(rad(224),rad(45))))%%360
[1] 134.5
> deg(circ.mean(c(rad(225),rad(45))))%%360
[1] 180
> deg(circ.mean(c(rad(226),rad(45))))%%360
[1] 315.5

Can anyone explain this???

This problem was first detected when I was trying to take the circ
weighted means of my data:

With 2 groups of bearings:
x <- c(270,180)
y <- c(45,270)

the circular mean of these bearings gives:
> deg(circ.mean(c(rad(x),rad(y))))%%360
[1] 257.2356

When finding the weighted means I get this:
> meany <- circ.mean(rad(y))
> meanx <- circ.mean(rad(x))

> deg(circ.weighted.mean(c(meanx,meany),c(2,2)))%%360
[1] 281.25

The function for weighted mean I am using:

circ.weighted.mean <- function (x,w) 
{
    sinr <- sum(w*sin(x))
    cosr <- sum(w*cos(x))
    circmean <- atan(sinr, cosr)
    circmean
}

I am assuming that the problem that mention above is the cause of the
different mean bearings.

Am I missing something fundamental here?

Thanks,
Mike




More information about the R-help mailing list