bin.den: Linear binning for density estimation

View source: R/np.den.R

bin.denR Documentation

Linear binning for density estimation

Description

Creates a bin.den-class (gridded binned density) object with simple or linear binning counts.

Usage

bin.den(x, nbin = NULL, type = c("linear", "simple"))

as.bin.den(object, ...)

## S3 method for class 'data.grid'
as.bin.den(object, weights.ind = 1, ...)

## S3 method for class 'bin.den'
as.bin.den(object, ...)

Arguments

x

vector or matrix of covariates (e.g. spatial coordinates). Columns correspond with dimensions and rows with observations.

nbin

vector with the number of bins on each dimension.

type

character, binning method: "linear" (default) or "simple".

object

(gridded data) used to select a method.

...

further arguments passed to or from other methods.

weights.ind

integer or character with the index or name of the component containing the bin counts/weights.

Details

If parameter nbin is not specified is set to pmax(25, rule.binning(x)).

Value

Returns an S3 object of class bin.den (extends data.grid). A list with the following 3 components:

binw

vector or array (dimension nbin) with the bin counts (weights).

grid

a grid.par-class object with the grid parameters.

data

a list with a component $x with argument x.

See Also

binning,np.den, h.cv, bin.data, locpol, rule.binning.

Examples

binden <- bin.den(earthquakes[, c("lon", "lat")], nbin = c(30,30))
bindat <- binning(earthquakes[, c("lon", "lat")], earthquakes$mag, nbin = c(30,30))
all.equal(binden, as.bin.den(bindat))

rubenfcasal/npsp documentation built on Nov. 13, 2024, 4:48 p.m.