This function creates a density estimate from data in one, two or three dimensions. In two dimensions a variety of graphical displays can be selected, and in three dimensions a contour surface can be plotted. A number of other features of the construction of the estimate, and of its display, can be controlled.
rpanel package is available, an interactive panel can be
activated to control various features of the plot.
rgl package is also available, rotatable plots are
available for the two- and three-dimensional cases. (For
three-dimensional data, the
misc3d package is also required.)
a vector, or a matrix with two or three columns, containing the data.
a vector of length one, two or three, defining the smoothing parameter.
A normal kernel function is used and
This argument applies only with one-dimensional data. Its default value
a vector of integers representing frequencies of individual observations.
Use of this parameter is incompatible with binning; hence
a vector of groups indicators (numeric or character values) or a factor.
other optional parameters are passed to the
see Chapters 1, 2 and 6 of the reference below.
In the three-dimensional case, the contours of the density estimate are
constructed by the
contour3d function in the
package of Feng & Tierney.
a list containing the values of the density estimate at the evaluation points,
the smoothing parameter, the smoothing parameter weights and the kernel
weights. For one- and two-dimensional data, the standard error of the estimate
(on the square root scale, where the standard error is approximately constant)
and the upper and lower ends of a variability band are also supplied. Less
information is supplied when the smoothing parameter weights
or kernel weights are not all 1, or when
positive is set to
a plot is produced, unless the option
display="none" is set.
Bowman, A.W. and Azzalini, A. (1997). Applied Smoothing Techniques for Data Analysis: the Kernel Approach with S-Plus Illustrations. Oxford University Press, Oxford.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# A one-dimensional example y <- rnorm(50) sm.density(y, model = "Normal") # sm.density(y, panel = TRUE) # A two-dimensional example y <- cbind(rnorm(50), rnorm(50)) sm.density(y, display = "image") # sm.density(y, panel = TRUE) # A three-dimensional example # y <- cbind(rnorm(50), rnorm(50), rnorm(50)) # sm.density(y)
Package 'sm', version 2.2-5.6: type help(sm) for summary information Warning message: no DISPLAY variable so Tk is not available Warning messages: 1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display 2: 'rgl_init' failed, running with rgl.useNULL = TRUE 3: .onUnload failed in unloadNamespace() for 'rgl', details: call: fun(...) error: object 'rgl_quit' not found 4: loading Rplot failed
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.