np.den | R Documentation |
Estimates a multidimensional probability density function (and its first derivatives) using local polynomial kernel smoothing of linearly binned data.
np.den(x, ...)
## Default S3 method:
np.den(
x,
nbin = NULL,
h = NULL,
degree = 1 + as.numeric(drv),
drv = FALSE,
ncv = 0,
...
)
## S3 method for class 'bin.den'
np.den(x, h = NULL, degree = 1 + as.numeric(drv), drv = FALSE, ncv = 0, ...)
## S3 method for class 'bin.data'
np.den(x, h = NULL, degree = 1 + as.numeric(drv), drv = FALSE, ncv = 0, ...)
## S3 method for class 'svar.bin'
np.den(x, h = NULL, degree = 1 + as.numeric(drv), drv = FALSE, ncv = 0, ...)
x |
a (data) object used to select a method. |
... |
further arguments passed to or from other methods. |
nbin |
vector with the number of bins on each dimension. |
h |
(full) bandwidth matrix (controls the degree of smoothing; only the upper triangular part of h is used). |
degree |
degree of the local polynomial used. Defaults to 1 (local linear estimation). |
drv |
logical; if |
ncv |
integer; determines the number of cells leaved out in each dimension. Defaults to 0 (the full data is used) and it is not normally changed by the user in this setting. See "Details" below. |
Standard generic function with a default method (interface to the
fortran routine lp_data_grid
), in which argument x
is a vector or matrix of covariates (e.g. spatial coordinates).
In this case, the data are binned (calls bin.den
) and the local fitting
procedure is applied to the scaled bin counts (calls np.den.bin.den
).
If parameter nbim
is not specified is set to rep(25, ncol(x))
.
A multiplicative triweight kernel is used to compute the weights.
If ncv > 1
, estimates are computed by leaving out cells with indexes within
the intervals [x_i - ncv + 1, x_i + ncv - 1]
, at each dimension i, where x
denotes the index of the estimation position.
Returns an S3 object of class np.den
(locpol den + bin den + grid par.).
A bin.den
object with the additional (some optional) 3 components:
est |
vector or array (dimension |
locpol |
a list with 6 components:
|
deriv |
(if requested) matrix of first derivatives. |
Wand, M.P. and Jones, M.C. (1995) Kernel Smoothing. Chapman and Hall, London.
bin.den
, binning
, h.cv
,
data.grid
.
bin.den <- binning(earthquakes[, c("lon", "lat")], nbin = c(30,30))
h.den <- h.cv(bin.den)
den <- np.den(bin.den, h = h.den$h)
plot(den, main = 'Estimated log(density)')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.