[R] How to fit a line through the "Mountain crest", i.e., through the highest density of points - in a "loess-like" fashion.

David Winsemius dwinsemius at comcast.net
Sun Mar 11 01:46:03 CET 2012


On Mar 10, 2012, at 3:55 PM, Emmanuel Levy wrote:

> Hi,
>
> I'm trying to normalize data by fitting a line through the highest  
> density
> of points (in a 2D plot).
> In other words, if you visualize the data as a density plot, the fit  
> I'm
> trying to achieve is the line that goes through the "crest" of the  
> mountain.

Are you familiar with the kde2d  of bkde2D functions in various  
packages? If you then collected the max density for each X and Y you  
might want to see whether that 2-d function would follow a  
sufficiently regular path that would represent the projection of the  
ridge on the z=0 plane.

>
> This is similar yet different to what LOESS does.

Do you want a curve or a line?

> I've been using loess
> before, but it does not exactly that as it takes into account all  
> points.
> Although points farther from the fit have a smaller weight, they  
> result in
> the fit being a bit off the crest.
>
> Do you know a package or maybe even an option in loess that would  
> allow me
> achieve this?

I don't. I happen to have a dataset where I could test it. But you are  
likely to get better responses if you provide a test case.

> Any advice or idea appreciated.
>
> Emmanuel
>
> 	[[alternative HTML version deleted]]

Plain text is preferred.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list