[R] How to translate the 2D-density matrix (the output of bkde2D function) into matrix of datapoints' amounts?

David Winsemius dwinsemius at comcast.net
Fri Sep 9 16:30:39 CEST 2011


On Sep 9, 2011, at 8:12 AM, omega1x wrote:

> It is known that function bkde2D (package "KernSmooth") returns a  
> matrix of
> density estimates over the mesh induced by x1 and x2. In Details it is
> written that "... heights of the kernel, scaled by the bandwidths,  
> at each
> datapoint are summed. This sum, after a normalization, is the  
> corresponding
> fhat value in the output".
> There are several questions:
> 1) How to calculate amount (sum) of datapoints from this fhat value?  
> Is it a
> non-normalized matrix of fhat values?

Wouldn't you just use 'cut' or 'findInterval' using the mesh points  
and then 'table' or 'tabulate'?

> 2) Values in fhat matrix are greater than 1 sometimes, why? Values of
> density are normalized and hence must be less than 1, isn't it?

No. One would expect that the normalization is done to get the  
integral equal to 1, not the individual points to have fhat in the  
range of [0,1]. (Failure to understand the difference is a common  
cause of questions on Rhelp, so if you need further explanation and  
many examples then do a search.)

>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-translate-the-2D-density-matrix-the-output-of-bkde2D-function-into-matrix-of-datapoints-amoun-tp3801482p3801482.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list