[R] Identifying peaks (or offsets) in a time series

From: Tauber, Dr E. <et22_at_leicester.ac.uk>
Date: Tue 25 Jul 2006 - 01:16:07 EST


Dear R-users,

We are monitoring the activity of animals during a few days period. The data from each animal (crossing of infra-red beam) are collected as a time series (in 30 min bins). An example is attached below.

y <-
c(0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,3,28,27,46,76,77,60,19,35,55,59,48
,87,20,38,82,62,60,85,105,69,109,102,100,101,116,126,119,63,27,25,15,8,0
,0,3,0,0,3,0,0,5,3,0,0,6,1,29,73,56,56,57,92,34,51,30,76,30,38,47,87,22,

0,68,76,94,101,119,114,115,111,116,134,125,76,23,19,30,2,8,0,3,0,0,0,7,0

,0,0,0,4,0,7,0,21,4,49,51,56,43,55,55,34,48,16,0,61,22,94,63,102,47,100,
96,113,93,109,123,120,124,115,94,96,76,36,3,0,0,0,0,0,0,2,5,0,0,0,0,2,10
,33,34,15,0,47,22,20,33,52,4,41,45,0,21,18,38,32,21,78,82,72,102,103,118
,116,118,114,82,18,5,21,4,0,14,0,5,2,0,0,2,2,0,0,3,0,2,7,16,13,17,50,0,4
8,16,19,34,39,33,3,67,0,68,34,65,84,61,100,85,108,124,141,139,134,96,54, 91,54,12,0,0,0,0,0,0,0,0,0,0,0,4,11,0,19,27,15,12,20)

We would like to have an automatic way, using R, to identify the time point of offset of each bout of activity (i.e. when activity goes down to a minimum value, for a defined duration). In the example above the offset times (the element number) should be approximately: 53, 99, 146, 191, 239, 283, 330 (the last bout of activity can be ignores).  

Any help or advice will be greatly appreciated,

Many thanks, Eran  

Eran Tauber (PhD)
Lecturer in Molecular Evolution
Dept. of Genetics
University of Leicester
University Rd, Leicester LE1 7RH
England



Phone: 44 (0)116 252-3455, 252-3421 (lab) Fax: 44 (0)116 252-3378 www.le.ac.uk/genetics/et22

R-help@stat.math.ethz.ch 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. Received on Tue Jul 25 01:37:31 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 25 Jul 2006 - 18:24:10 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.