[R] Kernel density estimate plot for 3-dimensional data

Duncan Murdoch murdoch.duncan at gmail.com
Tue May 4 17:17:39 CEST 2010


On 04/05/2010 11:03 AM, Pascal Martin wrote:
> #B <- pp3(runif(300), runif(300), runif(300), box3(c(0,1)))
> creates a 3d pattern with random points.
> But I want it to create a Kernel density estimate plot with my coordinates.
> I show it in an example:
>
> > x<- scan()
> 1: 1 2 3 4 5 6 7 8 9 10
> 11: 
> Read 10 items
> > y<- scan()
> 1: 10 9 8 7 6 5 4 3 2 1 
> 11: 
> Read 10 items
> > z<- scan()
> 1: 6 5 7 4 8 3 9 2 10 1
> 11: 
> Read 10 items
> > B<- pp3(x,y,z, c(0,10), c(0,10), c(0,10))
>
> >  x <- unclass(B$data)$df
> > H <- Hpi(x)
>
> From this point, it shows an error in chol.default(S12)
> and accordingly the rest does not go on.
>   

Those points all lie in a plane (y = 11-x); I imagine that causes the 
density estimate to overflow.  I get the same problem with your data, 
but not
with non-planar data.

Duncan Murdoch
> > fhat <- kde(x, H=H)
>
> > plot(fhat)
> > plot(fhat, axes=FALSE, box=FALSE, drawpoints=TRUE); axes3d(c('x','y','z'))
>
>
>
> ________________________________
> Von: Duncan Murdoch <murdoch.duncan at gmail.com>
> An: Pascal Martin <pascal15martin at yahoo.de>
> CC: r-help at r-project.org
> Gesendet: Dienstag, den 4. Mai 2010, 16:46:03 Uhr
> Betreff: Re: [R] Kernel density estimate plot for 3-dimensional data
>
> On 04/05/2010 10:33 AM, Pascal Martin wrote:
> > Hi!
> >
> > I have a problem with Kernel density estimate plot for 3-dimensional data in ks-package.
> > Here the example:
> >
> > # load ks, spatstat
> > # three-dimensional kernel density of B
> > B <- pp3(runif(300), runif(300), runif(300), box3(c(0,1)))
> > x <- unclass(B$data)$df
> > H <- Hpi(x)
> > fhat <- kde(x, H=H)
> > plot(fhat)
> > plot(fhat, axes=FALSE, box=FALSE, drawpoints=TRUE); axes3d(c('x','y','z'))
> >
> > If I try to insert my own coordinates instead of the artificial 3D-pattern, it does not work.
> > It would be great, if anybody could help me!
>
> You need to be more explicit about what "does not work" means.  The 
> example above works (though I don't like the axes in the first plot; I 
> prefer what you get
> with plot(fhat, box=FALSE)).  What problem are you having?
>
> Duncan Murdoch
>
>
>
>



More information about the R-help mailing list