binning | R Documentation |
Discretizes the data into a regular grid (computes a binned approximation) using the multivariate linear binning technique described in Wand (1994).
binning(x, y = NULL, nbin = NULL, set.NA = FALSE, window = NULL, ...)
as.bin.data(object, ...)
## S3 method for class 'data.grid'
as.bin.data(object, data.ind = 1, weights.ind = NULL, ...)
## S3 method for class 'bin.data'
as.bin.data(object, ...)
## S3 method for class 'SpatialGridDataFrame'
as.bin.data(object, data.ind = 1, weights.ind = NULL, ...)
x |
vector or matrix of covariates (e.g. spatial coordinates). Columns correspond with covariates (coordinate dimension) and rows with data. |
y |
vector of data (response variable). |
nbin |
vector with the number of bins on each dimension. |
set.NA |
logical. If |
window |
spatial window (values outside this window will be masked), currently an sp-object of class
extending |
... |
further arguments passed to |
object |
(gridded data) used to select a method. |
data.ind |
integer (or character) with the index (or name) of the component containing the bin averages. |
weights.ind |
integer (or character) with the index (or name) of the component
containing the bin counts/weights (if not specified, they are set to
|
If parameter nbin
is not specified is set to pmax(25, rule.binning(x))
.
Setting set.NA = TRUE
(equivalent to biny[binw == 0] <- NA
)
may be useful for plotting the binned averages $biny
(the hat matrix should be handled with care when using locpol
).
If y != NULL
, an S3 object of class
bin.data
(gridded binned data; extends bin.den
) is returned.
A data.grid
object with the following 4 components:
biny |
vector or array (dimension |
binw |
vector or array (dimension |
grid |
a |
data |
a list with 3 components:
|
If y == NULL
, bin.den
is called and a
bin.den
-class
object is returned.
Wand M.P. (1994) Fast Computation of Multivariate Kernel Estimators. Journal of Computational and Graphical Statistics, 3, 433-445.
data.grid
, locpol
, bin.den
,
h.cv
.
with(earthquakes, spoints(lon, lat, mag, main = "Earthquake data"))
bin <- binning(earthquakes[, c("lon", "lat")], earthquakes$mag, nbin = c(30,30), set.NA = TRUE)
simage(bin, main = "Binning averages")
with(earthquakes, points(lon, lat, pch = 20))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.