C Peroni wrote:
> I am trying to visualize the surface of a bivariate kernel density
> estimate.
> I have a vector of bivariate observations(x,y), and a function which
> computes the kernel density estimate z corresponding to each
> observation. I cannot generate the (x,y) data in the ascending order
> needed by persp(x,y,z).
That's not a very useful kernel density estimate function. The
kernel2d function in library(splancs) takes some x,y points, a kernel
width, and a number of grid point in x and y and returns something that
you can feed into persp() or image(). Can't you edit your kernel
function to give you values away from the observations?
> I was wondering whether there is an R version of the S function interp.
A simple visualisation can be acheived by plotting the points with a
symbol size related to the value at the point. e.g.
xyz=data.frame(x=runif(10),y=runif(10),z=runif(10)^2)
plot(xyz$x,xyz$y,cex=xyz$z*3)
You'll have to make sure the cex parameter is scaled to a range that
looks good on your graphics device, which is where the '*3' multiplier
comes from in my example. Normal points have cex=1. Points with cex=0
are invisible to you may want to add a small offset.
Barry