Hello,
Thank you to all those great folks that have helped me in the past
(especially Dennis Murphy).

I have a new challenge. I often generate time-series data sets that look
like the one below, with a variable ("Phase") which has a series of
flat-topped peaks (sample data below with 5 "peaks"). I would like to
calculate the phase value for each peak. It would be great to calculate the
mean value for the peak (possibly using rollmean(), but given the low
variability within the broad peak even just picking one value from the peak
would be sufficient.
I have tried using peaks() from the library(simecol),

peaks(data$Time,data$phase, model="max"),

but because of the flat nature of the peaks and the fact that peaks() looks
for values with lower neighbors I am unable to find all the peaks
(especially the one between time 0.762-0.897). For all my data files the
maximum phase values will fall between 27 and 62 so adding a function which
removes the values below 27 is reasonable and a technique I have used to
eliminate some of the noise between the peaks.


data=
    Time Phase
1  0.000 15.18
2  0.017 13.42
3  0.034 11.40
4  0.051 18.31
5  0.068 25.23
6  0.085 33.92
7  0.102 42.86
8  0.119 42.87
9  0.136 42.88
10 0.153 42.88
11 0.170 42.87
12 0.186 42.88
13 0.203 42.88
14 0.220 42.78
15 0.237 33.50
16 0.254 24.81
17 0.271 17.20
18 0.288 10.39
19 0.305 13.97
20 0.322 16.48
21 0.339 14.75
22 0.356 20.80
23 0.373 25.79
24 0.390 31.25
25 0.407 39.89
26 0.423 40.04
27 0.440 40.05
28 0.457 40.05
29 0.474 40.05
30 0.491 40.05
31 0.508 40.06
32 0.525 40.07
33 0.542 32.23
34 0.559 23.90
35 0.576 17.86
36 0.592 11.63
37 0.609 12.78
38 0.626 13.12
39 0.643 10.93
40 0.660 10.63
41 0.677 10.82
42 0.694 11.84
43 0.711 20.44
44 0.728 27.33
45 0.745 34.22
46 0.762 41.55
47 0.779 41.55
48 0.796 41.55
49 0.813 41.53
50 0.830 41.53
51 0.847 41.52
52 0.864 41.52
53 0.880 41.53
54 0.897 41.53
55 0.914 33.07
56 0.931 25.12
57 0.948 19.25
58 0.965 11.30
59 0.982 12.48
60 0.999 13.85
61 1.016 13.62
62 1.033 12.62
63 1.050 19.39
64 1.067 25.48
65 1.084 31.06
66 1.101 39.49
67 1.118 39.48
68 1.135 39.46
69 1.152 39.45
70 1.169 39.43
71 1.185 39.42
72 1.202 39.42
73 1.219 39.41
74 1.236 39.41
75 1.253 37.39
76 1.270 29.03
77 1.287 20.61
78 1.304 14.07
79 1.321  9.12


I have also tried using the peak finding code from Prof. Ripely, but it
doesn't seem able to find all the peaks either even if I widen the "span."

peaks<-function(series,span=3)
{
z <- embed(series, span)
s <- span%/%2
v<- max.col(z) == 1 + s
result <- c(rep(FALSE,s),v)
result <- result[1:(length(result)-s)]
result
}

Can anyone offer some advice on how to find a series of peaks in a data file
when the peaks are flat-topped and actually less "peaked?"

Thanks so much!
Nate

	[[alternative HTML version deleted]]

