Skip to content

lowess + turnpoints = doubling integers?

1 message · Bob Porter

#
Hello Philippe:

Thank you for your interest.  I have explored this and it appears to happen with
sequences in which small differences between successive occurrences, somewhere
in
turnpoints, but I have not tracked it down exactly.  The following is a cobbled
together demo based on the original code.  m b, Bob

***********************************************
foo<-rnorm(n=1200,mean=23.02, sd=34.14) #based on stat of actual data
xx<-lowess(foo,f=.04) #note that changing f or length of foo (equivalent,
actually) changes the result
yy<- turnpoints(xx$y)

onsets<-seq(1:yy$nturns)
peaks<-seq(1:yy$nturns)
offsets<-seq(1:yy$nturns)
ievent<-1


istart<-1
if(yy$firstispeak) istart<-2 #always start with a pit
i<-istart
adj<-1 #dummy adjustment, means something in original code

while(i<=yy$nturns-istart-adj)
    {
            # points are processed in sets of three pit-peak-pit events,
starting with a pit

        onsets[ievent]<-yy$tppos[i+1]-yy$tppos[i]#i is the onset point for this
event, this calculates its duration
        peaks[ievent]<-yy$tppos[i+1] #i+1 is the location of the peak point
        offsets[ievent]<-yy$tppos[i+2]-yy$tppos[i+1] #calculate the offset
duration but subtracting peak point from offset point
        i<-i+2 #set i to the offset point WHICH IS ALSO THE ONSET POINT FOR THE
NEXT EVENT
        ievent<-ievent+1
        #cat(i,"  ",ievent,"// ")
    }

events<-onsets+offsets

cat("\n",events,"events n=", nevents,"\n")
cat(onsets,"onsets\n")
cat(offsets,"offsets\n","\n")
*****************************************

----- Original Message -----
From: "Philippe Grosjean" <phgrosjean at sciviews.org>
To: "Bob Porter" <rjporter at mindspring.com>
Cc: <r-help at stat.math.ethz.ch>
Sent: Tuesday, December 31, 2002 4:55 AM
Subject: RE: [R] lowess + turnpoints = doubling integers?