smooth.hexbin {hexbin} R Documentation

Hexagon Bin Smoothing

Description

Compute a discrete kernel smoother that covers seven cells, namely a center cell and its six neighbors. With two iterations effective the kernel covers 1+6+12=19 cells.

Usage

```smooth.hexbin(bin, wts=c(48,4,1))
```

Arguments

 `bin` object of class `"hexbin"`. `wts` numeric vector of length 3 for relative weights of the center, the six neighbor cells, and twelve second neighbors.

Details

This discrete kernel smoother uses the center cell, immediate neighbors and second neighbors to smooth the counts. The counts for each resulting cell is a linear combination of previous cell counts and weights. The weights are
 1 center cell, weight = wts(1) 6 immediate neighbors weight = wts(2) 12 second neighbors weight =wts(3)

If a cell, its immediate and second neighbors all have a value of max(cnt), the new maximum count would be max(cnt)sum(wt). It is possible for the counts to overflow.

The domain for cells with positive counts increases. The hexbin components, xbins, xbnds, ybnds, and dim all reflect this increase. Note the typically dim[2]=xbins+1

The intent was provide a fast, iterated immediate neighbor smoother. However, the current hexbin plotting routines only support shifting even numbered rows to the right. Future work can

(1) can add a shift indicator to hexbin objects that indicates left or right shifting.
(2) generalize plot.hexbin() and hexagons()
(3) provide an iterated kernel.

With wt(3)=0, the smoother only uses the immediate neighbors. With a shift indicator the domain could increase by 2 rows (one bottom and on top) and 2 columns (one left and one right). However the current implementation increases the domain by 4 rows and 4 columns, thus reducing plotting resolution.

Value

an object of class `"hexbin"`, see `hexbin`. The object includes the additional component `wt`.

References

see `hexagons` and `hexbin`.

`hexbin`, `erode.hexbin`, `hcell2xy`, `hcell`, `plot.hexbin`, `hboxplot`, `hdiffplot`, `hmatplot`, `hexagons`, `hex.legend`.

Examples

```x <- rnorm(10000)
y <- rnorm(10000)
bin <- hexbin(x,y)
# show the smooth counts in gray level
smbin  <- smooth.hexbin(bin)
plot.hexbin(smbin)
# Compare the smooth and the origin
smbin1 <- smbin
smbin1\$cnts <- ceiling(smbin\$cnts/sum(smbin\$wts))
plot.hexbin(smbin1)
smbin2 <- smooth.hexbin(bin,wts=c(1,0,0))  # expand the domain for comparability
plot.hexbin(smbin2)
```

[Package hexbin version 1.0.10 Index]