[R] Identifying peak periods of observations in circular yearly data
David L Carlson
dcarlson at tamu.edu
Wed May 27 18:02:02 CEST 2015
You can use package circular for this. You have to convert 1-366 to 1-360 by dividing the days by 366 and multiplying by 360 and converting the results back to days by adding 360 if the value is <0 and dividing by 360 and multiplying by 366:
> library(circular)
> degrees <- obsDay/366*360 # convert year to 360 degrees
> # Create a circular object
> circ <- circular(degrees, units="degrees", template="geographics")
> # Get descriptive stats
> mean(circ)
Circular Data:
Type = angles
Units = degrees
Template = geographics
Modulo = asis
Zero = 1.570796
Rotation = clock
[1] -23.5503
> median(circ)
Circular Data:
Type = angles
Units = degrees
Template = geographics
Modulo = asis
Zero = 1.570796
Rotation = clock
[1] -17.70492
attr(,"medians")
[1] 342.2951
> sd(circ)
[1] 1.28903
> pct80 <- quantile(circ, prob=c(.1, .9))
> pct80
Circular Data:
Type = angles
Units = degrees
Template = geographics
Modulo = asis
Zero = 1.570796
Rotation = clock
10% 90%
59.01639 -135.73770
> # Convert result back to days
> days <- ifelse(pct80<0, pct80+360, pct80)/360*366
> days
10% 90%
60 228
> # Plot the results
> plot(circ, stack=TRUE, axes=FALSE)
> axis <- circular(c(0, 90, 180, 270), units="degrees", template="geographics")
> axis.circular(at=axis, labels=c("Jan", "April", "July", "October"),
+ template="geographics", zero=0, tcl.text=.15)
> arrows.circular(quantile(circ, prob=c(.10, .90)), lwd=2)
-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Daisy Englert Duursma
Sent: Wednesday, May 27, 2015 4:42 AM
To: Jim Lemon
Cc: r-help at R-project.org
Subject: Re: [R] Identifying peak periods of observations in circular yearly data
Thanks for the advice Jim. I did actually play around with this idea, but
for some bird species (emu) the beginning of the breeding season is
actually January while for others it is in July or at other times. Breeding
seasons can be driven by dry season or temperatures, so although there are
generalizations each species need to be assessed.
On Wed, May 27, 2015 at 7:34 PM, Jim Lemon <drjimlemon at gmail.com> wrote:
> Hi Daisy,
> You face a problem similar to one with which I have grappled in
> different fields. The year is designed for the northern hemisphere,
> beginning and ending in less productive biologic states in those
> regions. I have previously argued that since the calendar year is an
> arbitrary progression, it makes more sense to redraw the annual
> boundary when examining things like this in the southern hemisphere.
> That is to say, a "year" is conventionally marked at about the
> northern winter solstice. Down here, this becomes the summer solstice
> and breaks up a lot of things that happen around that time. Have you
> thought of defining a southern bird-watching year as beginning and
> ending at the southern winter solstice? As I am currently writing in
> an entirely different context, it shouldn't really make much
> difference.
>
> Jim
>
>
> On Wed, May 27, 2015 at 4:35 PM, Daisy Englert Duursma
> <daisy.duursma at gmail.com> wrote:
> > Greetings,
> >
> > I am trying to identify at which point during the year 80% of bird
> breeding
> > observations are. typically I would answer a question like this by
> finding
> > the median or quartiles but how do I deal with situations where the 80%
> of
> > the is from day 285 through day 366 (leap year) and extends to day 30?
> >
> > The data is circular and and day 365 is as close to day 366 as day 1.
> >
> > I am reading the manual for CircStats and circular but I could really use
> > some help on this.
> >
> >
> > Here is some dummy data:
> >
> >
> >
> obsDay<-c(rep(1:30,10),rep(45:65,2),65:180,rep(181:265,2),rep(266:330,4),rep(331:366,6))
> >
> > plot(density(obsDay))
> >
> >
> >
> > --
> > Daisy Englert Duursma
> > Department of Biological Sciences
> > Room W19F 135
> > Macquarie University, North Ryde, NSW 2109
> > Australia
> >
> > Tel +61 2 9850 1302
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>
--
Daisy Englert Duursma
Department of Biological Sciences
Room W19F 135
Macquarie University, North Ryde, NSW 2109
Australia
Tel +61 2 9850 1302
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
More information about the R-help
mailing list