2.1.specialist.panels: Special panel functions 01

2.1.specialist.panelsR 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

lattice function arguments passed down to individual panels.

...

Additional arguments, typically passed on. See below.

loa.settings, process, plot

For panel... functions that intended to be handled using panelPal. loa.settings, a logical indicating if the safe mode setting should be returned. process and plot, logicals, indicating if the process and plot sections of the panel function should be run. See below and panelPal help documents for further details.

breaks, x.breaks, y.breaks

(For panel.surfaceSmooth and panel.binPlot) How many break points to introduce when smoothing a surface or binning data. breaks can be used to set the same number of breaks on both axes, while x.breaks and y.breaks can be used to set these separately.

smooth.fun

(For panel.surfaceSmooth) A function that can fit a surface estimate to (x,y,z) data. See notes below for further details.

too.far

(For panel.surfaceSmooth and panel.kernelDensity) The distance from original data at which to stop predicting surface values. See notes below for further details.

n

(For panel.kernelDensity) the number of x and y cases to estimate when estimating density.

local.wt

(For panel.kernelDensity) A logical (default TRUE) indicating if kernel density estimates should be weighed relative to other groups, panels, etc.

kernel.fun

(For panel.kernelDensity) A function that can estimate kernel densities.

panel.range

(For panel.kernelDensity) A logical (default FALSE) indicating if the kernel density estimation data range should be forced to the full panel range. See Below.

x1, x2, y1, y2

(For panel.binPlot) Vectors giving the bin cell dimensions used when binning x and y elements. Typically ignored and calculated within the plot call.

statistic

(For panel.binPlot) the function to use when calculating z values for each set of binned. By default, this is mean. So, if a z element is supplied in the plot call, the data is binned according to x and y values, and the mean of z values within each bin reported/plotted. If z is not supplied, statistic is reset to length to generate a frequency plot and a warning generated.

pad.grid

For panel.binPlot, Logical, should empty bins be reported? If TRUE, they are reported as NAs; if FALSE, they are not reported.

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)


loa documentation built on Nov. 23, 2023, 3:02 p.m.