| 2.1.specialist.panels {loa} | R Documentation |
Special panel functions 01
Description
Specialist panel functions for use with lattice and loa plots.
Usage
panel.loaLevelPlot(x = NULL, y = NULL, z = NULL, ...,
loa.settings = FALSE)
panel.surfaceSmooth(x = NULL, y = NULL, z = NULL,
breaks = 200, x.breaks = breaks, y.breaks = breaks,
smooth.fun = NULL, too.far=0, ...,
plot = TRUE, process = TRUE, loa.settings = FALSE)
panel.kernelDensity(x, y, z = NULL, ..., n = 20,
local.wt = TRUE, kernel.fun = NULL, too.far = 0,
panel.range = TRUE, process = TRUE, plot = TRUE,
loa.settings = FALSE)
panel.binPlot(x = NULL, y = NULL, z = NULL,
breaks=20, x.breaks = breaks, y.breaks = breaks,
x1=NULL, x2=NULL, y1=NULL, y2=NULL,
statistic = mean, pad.grid = FALSE, ...,
plot = TRUE, process = TRUE, loa.settings = FALSE)
Arguments
x, y, z |
|
... |
Additional arguments, typically passed on. See below. |
loa.settings, process, plot |
For |
breaks, x.breaks, y.breaks |
(For |
smooth.fun |
(For |
too.far |
(For |
n |
(For |
local.wt |
(For |
kernel.fun |
(For |
panel.range |
(For |
x1, x2, y1, y2 |
(For |
statistic |
(For |
pad.grid |
For |
Details
panel.loaLevelPlot is intended for plot data structured
for use with the lattice function levelplot,
e.g. regularised (x,y,z) or a matrix:
loaPlot(..., panel = panel.loaLevelPlot)
levelplot(...) #in lattice
Other specialist panel... functions can be used with the
lattice function xyplot:
xyplot(..., panel = panel.kernelDensity)
xyplot(..., n = 50, panel = panel.kernelDensity)
xyplot(..., panel = function(...) panel.kernelDensity(..., n = 50))
#etc
However, they are intended for use with loa plots that incorporate
panelPal. This combination provides a mechanism for the
routine preprocessing of panel data, the association of specialist keys,
and the routine alignment of panel and legend settings in cases where
values are reworked within the panel function call:
loaPlot(..., panel = panel.kernelDensity)
#etc
panel.surfaceSmooth and other similar panel... functions
generate smoothed surfaces using supplied (x,y,z) data and pass
this to panel.loaLevelPlot to plot.
By default, panel.surfaceSmooth uses stats function
loess to generate a surface. Alternative smooths
can be set using the smooth.fun argument, and the surface
range can to controlled using the too.far argument.
panel.kernelDensity generates kernel density estimations
based on the supplied x and y data ranges. Because it is
density plot, it counts the number of z values. So, z values
are ignored. It is intended to be used in the form:
loaPlot(~x*y, ..., panel = panel.kernelDensity)
So, if any z information is supplied, users are warned that it has
been ignored, e.g:
loaPlot(z~x*y, ..., panel = panel.kernelDensity)
#warning generated
panel.binPlot bins supplied z data according to x and
y values and associated break points (set by break arguments),
and then calculates the required statistic for each of these. By default,
this is mean, but alternative functions can be set using the
statistic argument. It is intended to be used in form:
loaPlot(z~x*y, ..., panel = panel.binPlot)
If no z values are supplied, as in:
loaPlot(~x*y, ..., panel = panel.binPlot)
... panel.binPlot resets statistic to length
(again with a warning) and gives a count of the number of elements in
each bin.
Value
As with other panel... functions in this package, output are suitable
for use as the panel argument in loa (and sometimes
lattice) plot calls.
Note
All these panel... functions treat col and col.regions,
etc, as discrete arguments. Typically, col links to lines (contour
lines for surfaces, bin borders for binned data) and col.regions
links any generates surface region.
panel.surfaceSmooth passes additional arguments on to the
smooth.fun to estimate surface smooths and the lattice
function panel.levelplot to generate the associated plot.
If no kernel.fun is supplied in the panel call, the
stats function loess is used to estimate surface smooth.
The too.far argument is based on same in vis.gam
function in the mgcv package.
panel.kernelDensity passes additional arguments on to the
kernel.fun to estimate kerenel density and the lattice
function panel.contourplot to generate the associated plot.
If no kernel.fun is supplied in the panel call, the
MASS function kde2d is used to estimate kernel density.
panel.binPlot passes limited arguments on to lrect.
panel.kernelDensity and panel.binPlot are currently under
review.
Author(s)
Karl Ropkins
References
These function makes extensive use of code developed by others.
lattice: Sarkar, Deepayan (2008) Lattice: Multivariate Data Visualization with R. Springer, New York. ISBN 978-0-387-75968-5
(for panel.kernelDensity) MASS package:
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics
with S. Fourth edition. Springer.
(for panel.surfaceSmooth) mgcv package and too.far argument:
Wood, S.N. (2004) Stable and efficient multiple smoothing parameter
estimation for generalized additive models.Journal of the American
Statistical Association. 99:673-686.
Also http://www.maths.bath.ac.uk/~sw283/
See Also
In loa: panelPal
In lattice: xyplot, levelplot,
panel.contourplot, lrect
Examples
## Example 1
## for data already set up for levelplot
loaPlot(volcano, panel=panel.loaLevelPlot)
## Example 2
## Surface smooth
loaPlot(copper~longitude*latitude, data= lat.lon.meuse,
panel=panel.surfaceSmooth, grid=TRUE,
too.far=0.1, col.regions=3:2)