[R] weighted kernel density estimate

May, Roel Roel.May at nina.no
Thu Apr 6 15:33:29 CEST 2006

Dear Markus,

I indeed have a data set consisting of 1/2*N*(N-1) unique pairs of
individuals with data

x1 y1 x2 y2 w

I am however not interested in, like you said, the value at x1, y1 of w
summarised by a kernel function  over all x2, y2 (if I understand you
rightly that is...). This sounds like doing a weighted kernel density
estimate as seen from the 'viewpoint' of a certain location/individual.
I know could be done with sm.density in the sm library.

I am interested to create a map depicted the total structuring in the
entire population (both based on geographic and genetic distances). This
means that the evaluation/interpolation at each location have to take
into account both the geographic AND the genetic distance matrix (both
with 1/2*N*(N-1) unique combinations).

To clarify myself a bit more, such a map could show for example
differentiation in the population (of wolverines by the way) because of
large geographic distances OR because of large genetic distances.

I have quickly checked locfit but I am not sure if this would work for


-----Original Message-----
From: Markus Jantti [mailto:markus.jantti at iki.fi] 
Sent: 6. april 2006 14:56
To: r-help at stat.math.ethz.ch
Cc: May, Roel
Subject: Re: [R] weighted kernel density estimate

On Thu, 2006-04-06 at 14:29 +0200, May, Roel wrote:
> Dear R-users,
> I intend to do a spatial analysis on the genetic structuring within a 
> population. For this I had thought to prepare a kernel density 
> estimate map showing the spatial distribution of individuals, while 
> incorporating the genetic distances among individuals. I have a 
> dataset of locations of N unique individuals (XY-coordinates) and an 
> NxN matrix with the genetic distances given as a fraction between 0 
> and 1. As far as I understand the methodology, a kernel density 
> estimate works with the geographic distance matrix. My idea was to 
> somehow incorporate the genetic distance matrix (e.g. as an 
> among-individual-based smoothing
> factor???) in the estimation. Does anyone know if this is possible? To

> me it sounds a logical inclusion which may be interesting for a wide 
> variety of topics (i.e., "not all individuals are equal"). I hope 
> someone knows of any way to proceed. Thanks in advance,

Dear Roel -- it is not entirely clear what you wish to achieve. Sampling
weights associated with a unit can be incorporated at least in the
locfit package, which also allows you to do a 2-dimensional density
estimate, but this does not sound like what you are interested in.

>From your description, it sounds like you have a data set which 
of 1/2*N*(N-1) unique pairs of individuals with data

x1 y1 x2 y2 w

where (x1, y1) and (x2, y2) are the (x,y) coordinates and w is the
genetic distance between the two (there are only 1/2*N*(N-1) on the
assumption that the genetic distance for any i,j individuals is
symmetric so w(i,j) = w(j, i) and w(i, i) = 1).

Are you interested in plotting on a map of (x, y) coordinates some
measure of how genetically related the population at the that coordinate
are with their surroundinds? I.e., value at x1, y1 of w summarised by a
kernel function  over all x2, y2?

Best wishes,


> Cheers Roel May
> Roel May
> Norwegian Institute for Nature Research (NINA) Tungasletta 2, NO-7485 
> Trondheim, Norway Tlf. +47 73 80 14 65, Mob. +47 95 78 59 95 Email 
> roel.may at nina.no Internett www.nina.no, www.jerv.info
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!

Markus Jantti
Abo Akademi University
markus.jantti at iki.fi


This message has been scanned by F-Secure Anti-Virus for Mic...{{dropped}}

More information about the R-help mailing list