[R] Sharp turn in cdf?

David Winsemius dwinsemius at comcast.net
Fri Aug 26 15:12:19 CEST 2011


This arrived without a refers to in its headers and was a follow up to:

On Aug 25, 2011, at 9:33 PM, Jim Silverton wrote:
>> Hi all,
>> I have some data. I want to fit a smooth cdf to the data. Then I  
>> want to
>> find both the value of x  and the % on the y axis for which the the  
>> slope is
>> 1 ( or the point where the slope change is the greatest...hummh  
>> well the
>> part where you can identify where there is a point of  
>> inflection...for want
>> of a better word. Any ideas?
On Aug 26, 2011, at 12:59 AM, Jim Silverton wrote:

> x = c(runif(1000, 0,2.5), runif(100, 2.5, 4))
> plot(ecdf(x))
>
> You will notice a sharp turn around x = 2.5
> How do I get that value of x using R?

So you are not interested in a specific slope or in the inflection  
points (since there is no no inflection in this example but rather in  
the point at which the slope changes. The is a package, structcahange   
that looks at segmented models but in this simple instance I could not  
get it to return resuslts that I thought were consistent with the data.

In a sense it is like a statistical process control problem. Cusums  
are often used to follow measurements that have a random and  
systematic component and which may shift their behavior. This is a  
simple demonstration of the advantages of that approach. Just take the  
median value and track cumulative sums:

csum.x <- cumsum(x-median(x))
  plot( csum.x)
  which.min(csum.x)
#'[1] 999

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list