EVOLUTION-MANAGER
Edit File: kde2d.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Two-Dimensional Kernel Density Estimation</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for kde2d {MASS}"><tr><td>kde2d {MASS}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Two-Dimensional Kernel Density Estimation </h2> <h3>Description</h3> <p>Two-dimensional kernel density estimation with an axis-aligned bivariate normal kernel, evaluated on a square grid. </p> <h3>Usage</h3> <pre> kde2d(x, y, h, n = 25, lims = c(range(x), range(y))) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>x coordinate of data </p> </td></tr> <tr valign="top"><td><code>y</code></td> <td> <p>y coordinate of data </p> </td></tr> <tr valign="top"><td><code>h</code></td> <td> <p>vector of bandwidths for x and y directions. Defaults to normal reference bandwidth (see <code><a href="bandwidth.nrd.html">bandwidth.nrd</a></code>). A scalar value will be taken to apply to both directions. </p> </td></tr> <tr valign="top"><td><code>n</code></td> <td> <p>Number of grid points in each direction. Can be scalar or a length-2 integer vector. </p> </td></tr> <tr valign="top"><td><code>lims</code></td> <td> <p>The limits of the rectangle covered by the grid as <code>c(xl, xu, yl, yu)</code>. </p> </td></tr></table> <h3>Value</h3> <p>A list of three components. </p> <table summary="R valueblock"> <tr valign="top"><td><code>x, y</code></td> <td> <p>The x and y coordinates of the grid points, vectors of length <code>n</code>. </p> </td></tr> <tr valign="top"><td><code>z</code></td> <td> <p>An <code>n[1]</code> by <code>n[2]</code> matrix of the estimated density: rows correspond to the value of <code>x</code>, columns to the value of <code>y</code>. </p> </td></tr></table> <h3>References</h3> <p>Venables, W. N. and Ripley, B. D. (2002) <em>Modern Applied Statistics with S.</em> Fourth edition. Springer. </p> <h3>Examples</h3> <pre> attach(geyser) plot(duration, waiting, xlim = c(0.5,6), ylim = c(40,100)) f1 <- kde2d(duration, waiting, n = 50, lims = c(0.5, 6, 40, 100)) image(f1, zlim = c(0, 0.05)) f2 <- kde2d(duration, waiting, n = 50, lims = c(0.5, 6, 40, 100), h = c(width.SJ(duration), width.SJ(waiting)) ) image(f2, zlim = c(0, 0.05)) persp(f2, phi = 30, theta = 20, d = 5) plot(duration[-272], duration[-1], xlim = c(0.5, 6), ylim = c(1, 6),xlab = "previous duration", ylab = "duration") f1 <- kde2d(duration[-272], duration[-1], h = rep(1.5, 2), n = 50, lims = c(0.5, 6, 0.5, 6)) contour(f1, xlab = "previous duration", ylab = "duration", levels = c(0.05, 0.1, 0.2, 0.4) ) f1 <- kde2d(duration[-272], duration[-1], h = rep(0.6, 2), n = 50, lims = c(0.5, 6, 0.5, 6)) contour(f1, xlab = "previous duration", ylab = "duration", levels = c(0.05, 0.1, 0.2, 0.4) ) f1 <- kde2d(duration[-272], duration[-1], h = rep(0.4, 2), n = 50, lims = c(0.5, 6, 0.5, 6)) contour(f1, xlab = "previous duration", ylab = "duration", levels = c(0.05, 0.1, 0.2, 0.4) ) detach("geyser") </pre> <hr /><div style="text-align: center;">[Package <em>MASS</em> version 7.3-51.4 <a href="00Index.html">Index</a>]</div> </body></html>