Christoph Goebel
2010-Nov-19 20:56 UTC
[R] Sampling from multi-dimensional kernel density estimation
Hi, I'd like to use a three-dimensional dataset to build a kernel density and then sample from the distribution. I already used the npudens function in the np package to estimate the density and plot it: fit<-npudens(~x+y+z) plot(fit) It takes some time but appears to work well. How can I use this to evaluate the fitted function at a certain point, e.g. (x=1, y=1, z=1)? Does R provide methods for sampling from the fitted function? Thanks, Christoph [[alternative HTML version deleted]]
Greg Snow
2010-Nov-23 20:49 UTC
[R] Sampling from multi-dimensional kernel density estimation
Generating new data from a kernel density estimate is equivalent to choosing a point from your data at random, then generating a point from your kernel centered at the chosen point. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Christoph Goebel > Sent: Friday, November 19, 2010 1:56 PM > To: r-help at r-project.org > Subject: [R] Sampling from multi-dimensional kernel density estimation > > Hi, > > > > I'd like to use a three-dimensional dataset to build a kernel density > and > then sample from the distribution. > > > > I already used the npudens function in the np package to estimate the > density and plot it: > > > > fit<-npudens(~x+y+z) > > plot(fit) > > > > It takes some time but appears to work well. > > > > How can I use this to evaluate the fitted function at a certain point, > e.g. > (x=1, y=1, z=1)? Does R provide methods for sampling from the fitted > function? > > > > Thanks, > > > > Christoph > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.