kde2d.html
来自「本程序是基于linux系统下c++代码」· HTML 代码 · 共 110 行
HTML
110 行
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Two-Dimensional Kernel Density Estimation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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 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>
x coordinate of data
</td></tr>
<tr valign="top"><td><code>y</code></td>
<td>
y coordinate of data
</td></tr>
<tr valign="top"><td><code>h</code></td>
<td>
vector of bandwidths for x and y directions. Defaults to
normal reference bandwidth (see <code><a href="bandwidth.nrd.html">bandwidth.nrd</a></code>).
</td></tr>
<tr valign="top"><td><code>n</code></td>
<td>
Number of grid points in each direction.
</td></tr>
<tr valign="top"><td><code>lims</code></td>
<td>
The limits of the rectangle covered by the grid as <code>c(xl, xu, yl, yu)</code>.
</td></tr>
</table>
<h3>Value</h3>
<p>
A list of three components.
</p>
<table summary="R argblock">
<tr valign="top"><td><code>x, y</code></td>
<td>
The x and y coordinates of the grid points, vectors of length <code>n</code>.
</td></tr>
<tr valign="top"><td><code>z</code></td>
<td>
An <code>n</code> x <code>n</code> matrix of the evaluated density.
</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 align="center">[Package <em>MASS</em> version 7.2-44 <a href="00Index.html">Index]</a></div>
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?