Special panel functions 01
Description
Specialist panel functions for use with lattice and loa plots.
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  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,
kernel.fun = NULL, 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 
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 9780387759685
(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:673686.
Also http://www.maths.bath.ac.uk/~sw283/
See Also
In loa
: panelPal
In lattice
: xyplot
, levelplot
,
panel.contourplot
, lrect
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58  ## 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)
## Example 3
## (not run)
## 3a. Specialist kernel density panel example
#a < rnorm(1000)
#b < rnorm(1000)
#c < rnorm(1000)
#compare:
#xyplot(a~b, panel = panel.kernelDensity, at = 0:5*5)
#loaPlot(~a*b, panel = panel.kernelDensity)
# Note 1:
# at sets col.regions for the color surface, but, as this is calculated
# inpanel, this is not known at time of call. So, you need to set when
# using specialist panels with standard lattice plots.
# (Same is true for any panel where plot attributes that are set inpanel
# and is needed to be known in all panels and keys for consistent output.)
# loa panels include separate process and plot steps that panelPal can
# use to track these.
# Note 2:
# By default, the panel ignores z data.
#
# compare:
# loaPlot(c~a*b, panel = panel.kernelDensity) #where z term (c) ignored
# loaPlot(c~a*b, panel = panel.kernelDensity, n=100) #finer surface resolution
#but z term STILL ignored
## 3b. Specialist bin plot panel example
# By default, the panel bins supplied z case as mean
# modify by supplying alternative as statistic
#loaPlot(c~a*b, panel = panel.binPlot)
#loaPlot(c~a*b, panel = panel.binPlot, statistic=max)
# Note:
# If z is not supplied, statistic defaults to length to give a count
# loaPlot(~a*b, panel = panel.binPlot) #where z term not supplied
#etc.
