[R-sig-Geo] Calculate area/volume of kde output from ks package
kalee
kathryn.lee1 at students.mq.edu.au
Mon Jan 16 11:50:43 CET 2012
Hi
I'm trying to calculate the volume of a 3D kernel density estimator that has
been calculated using the kde command from the ks package. So far I'm just
working with the examples given before applying this to my own data so only
have that example data to give (found under "plot" of the package manual):
## trivariate example
library(MASS)
x <- iris[,1:3]
H.pi <- Hpi(x, pilot="samse")
fhat <- kde(x, H=H.pi, compute.cont=TRUE)
plot(fhat, drawpoints=TRUE)
Under a previous post about calculating the 2D spatial area of the kde
output (see full original message at the end) the following was suggested:
"
Michael Sumner-2 wrote
>
> Here's one way:
>
> library(ks)
>
> data(unicef)
> H.scv <- Hscv(x=unicef)
> fhat <- kde(x=unicef, H=H.scv)
> image(fhat$eval.points[[1]], fhat$eval.points[[2]], fhat$estimate)
>
>
> library(sp)
>
>
> spkde <- image2Grid(list(x = fhat$eval.points[[1]], y =
> fhat$eval.points[[2]], z = fhat$estimate))
> contour(spkde, add = TRUE) "
>
> - How would this above method be applied to a 3D kde output? How would you
> calculate the kde output at specific contour levels? Such as the 95% or
> 50% contour levels. The original R-sig-geo post quoted a wiki page that
> seems to have subsequently removed the posting about image2Grid.
>
> Many thanks,
> Kathryn
>
>
>
>
>
> On Sat, Nov 28, 2009 at 7:53 AM, Tyler Dean Rudolph
> <prairie.picker@> wrote:
>> Is there a way to convert a kde object (ks package) into a spatial
>> object
>> (e.g. SpatialPixels, SpatialPolygons) for export into a GIS?
>> Alternatively,
>> is there a way to generate the 2-D spatial area underneath the 3-D
>> utilisation distribution of a kde object? I have explored the package
>> descriptions and help forums and have not yet found a solution....
>>
>> Tyler
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at .ethz
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at .ethz
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Convert-kde-object-into-spatial-object-tp4077448p7192095.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list