[R-sig-Geo] Kernel smoothing density function
Sarah Goslee
sarah.goslee at gmail.com
Thu Jul 24 22:19:07 CEST 2014
On Thu, Jul 24, 2014 at 4:06 PM, Ferra Xu <ferra.xu at yahoo.com> wrote:
> Dear Sarah
> Thank you for your response. I have attached the data that I'm using. I
> noticed that no estimate and eval.points are generated...Would you please
> take a look at it?
Of course the estimate is generated, just as the help file promised.
hat$estimate
contains the estimate: all the named components given in the Value
section of the helpfile
are part of hat, and you can see that with
names(hat)
Have you read the Introduction to R that comes with your R
installation? Perhaps you should.
> It creates a plot in R environment but the pdf file doesn't work.
>
> Appreciate your help,
Well, ?plot.kde states that for 3D data it produces an interactive RGL
plot, and unlike for 1D and 2D there are no other options.
What do you expect to be printed to PDF when you create an interactive plot?
Reading ?rgl suggests that you might want to look into ?rgl.snapshot
Sarah
>
> On Thursday, July 24, 2014 12:35 PM, Sarah Goslee <sarah.goslee at gmail.com>
> wrote:
>
>
> Hi,
>
> On Thu, Jul 24, 2014 at 1:22 PM, Ferra Xu <ferra.xu at yahoo.com> wrote:
>> Hello all,
>> In order to find the kernel smoothing density function of a 3 dimensional
>> data-set, I wrote this code in R:
>> library(ks)defect <-read.table(file.choose(),sep=",")hat
>> <-kde(defect)pdf("SampleGraph.pdf")plot(hat,drawpoints=TRUE)dev.off()
>> But I have problem in interpretation of the result..I don't see the
>> estimated values for density function (I need to have the values of f to use
>> it in another code). The other problem is that the pdf file is not created
>> correctly..Although the plot is created in R window, when I want to open the
>> pdf file, it says:There was an error opening this document. This file cannot
>> be opened because it has no pages.
>
>> [[alternative HTML version deleted]]
>
>
> See why you shouldn't post HTML to this list?
>
> Trying to parse that, I see that I can't run your example because no
> data are provided (dput() is a good function to know).
>
> When I run the example code given in ?kde it works as expected. Does
> your plot command create a plot on other devices, like the default for
> your OS? Does the example code in ?kde work when you run it? Does it
> create a plot?
>
> As for the estimated values, did you carefully read the Value section
> of the help file?
>
> A kernel density estimate is an object of class ‘kde’ which is a
> list with fields:
>
> x: data points - same as input
>
> eval.points: points at which the estimate is evaluated
>
> estimate: density estimate at ‘eval.points’
>
> If this density estimate is not the estimate you are looking for,
> you'll need to be more specific.
>
> Sarah
>
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-sig-Geo
mailing list