plot.kdde: Plot for kernel density derivative estimate

View source: R/kdde.R

plot.kddeR Documentation

Plot for kernel density derivative estimate

Description

Plot for kernel density derivative estimate for 1- to 3-dimensional data.

Usage

## S3 method for class 'kdde'
plot(x, ...)

Arguments

x

object of class kdde (output from kdde)

...

other graphics parameters:

which.deriv.ind

index of the partial derivative to be plotted (>1-d)

and those used in plot.kde

Details

For kdde objects, the function headers for the different dimensional data are

  ## univariate
  plot(fhat, ylab="Density derivative function", cont=50, abs.cont, alpha=1, ...)

  ## bivariate
  plot(fhat, which.deriv.ind=1, cont=c(25,50,75), abs.cont, display="slice", 
       zlab="Density derivative function", col, col.fun, alpha=1, kdde.flag=TRUE, 
       thin=3, transf=1, neg.grad=FALSE, ...)
  
  ## trivariate 
  plot(fhat, which.deriv.ind=1, display="plot3D", cont=c(25,50,75), abs.cont, 
       colors, col, col.fun, ...)

Value

Plots for 1-d and 2-d are sent to graphics window. Plot for 3-d is sent to graphics/RGL window.

In addition to the display options inherited from plot.kde, the first derivative has display="quiver". This is a quiver plot where the size and direction of the arrow indicates the magnitude/direction of the density gradient. See quiver from the pracma package for more details.

See Also

plot.kde

Examples

## univariate example
data(tempb)
fhat1 <- kdde(x=tempb[,"tmin"], deriv.order=1)   ## gradient [df/dx, df/dy]
plot(fhat1, xlab="Min. temp.", col.cont=4)       ## df/dx
points(20,predict(fhat1, x=20))

## bivariate example
fhat1 <- kdde(x=tempb[,c("tmin", "tmax")], deriv.order=1)
plot(fhat1, display="quiver")
  ## gradient [df/dx, df/dy]

fhat2 <- kdde(x=tempb[,c("tmin", "tmax")], deriv.order=2)
plot(fhat2, which.deriv.ind=2, display="persp", phi=10)
plot(fhat2, which.deriv.ind=2, display="filled.contour")
  ## d^2 f/(dx dy): blue=-ve, red=+ve
s2 <- kcurv(fhat2)
plot(s2, display="filled.contour", alpha=0.5, lwd=1)
  ## summary curvature 

## trivariate example  
data(iris)
fhat1 <- kdde(iris[,2:4], deriv.order=1)
plot(fhat1)

ks documentation built on Sept. 30, 2024, 9:15 a.m.