.BG
.FN boxcox
.TL
boxcox: High-Interaction Display of Power Transformations
.CS
boxcox(x, y, powers, xpowers, ypowers)
.PP
.AG x
x-coordinates of data.
The plot will show values of `x^px' along the horizontal axis,
with the value of `px' chosen from `xpowers' by the position of the mouse.
.AG y
y-coordinates of data.
The plot will show values of `y^py' along the vertical axis,
with the value of `py' chosen from `ypowers' by the position of the mouse.
.AG powers
vector of powers to be used for power transformation.
The zero power is the logarithm of the data.
Negative powers are done with a sign reversal of the data to keep
the smallest `x' value at the left of the plot.
Default is a sequence from -4 to 4 by .1.
.AG xpowers
vector of powers to be used for transforming `x'.
Default is `powers'.
.AG ypowers
vector of powers to be used for transforming `y'.
Default is `powers'.
.PP
This function only works on Teletype 5620 terminals.
.PP
When the function is invoked, it computes a table giving plotting positions
for all combinations of `x' and `xpowers', and another table giving
positions for combinations of `y' and `ypowers'.
These tables are then sent to the terminal to be displayed.
The terminal must have storage space available for the tables
and you must wait until the tables are transmitted to the terminal.
Hence it is best to keep the products `len(x)*len(xpowers)'
and `len(y)*len(ypowers)' fairly small (say 10000 or less).
.PP
Once the tables are available in the terminal
two numbers will appear in the upper left side of the graphics layer.
These numbers represent the x and y powers corresponding to the
current mouse position and will 
change with the position of the mouse.
When you press mouse button 1, a plot of the transformed
data will appear.  Two numbers in the upper right of the plot show the
transformation powers corresponding to the current display.
If you hold button 1 down, you will see the display continuously change
as a function of the mouse position.
.PP
Button 3 pops-up a menu that allows you to fix
the current value of the transformation
power for either the x or the y axis.
There is also a menu item on button 3 for exiting.
.PP
Remember that power transformations are not invariant to choice
of centering, hence the
pictures may look different depending on the measurement scales,
e.g., temperature data will look different when it is expressed in
Celsius, Fahrenheit, or Kelvin.
.EX
boxcox(1:20,1:20)   # see what power transformations can do to a line

boxcox(corn.rain,corn.yield)

# it may be useful to use a much finer power grid near 0
boxcox(corn.rain,corn.yield,power=signif(qnorm(ppoints(50)),3))

# try to choose a power such that the transformed data is approximately
# normally distributed
s <- rlnorm(50)
boxcox(qnorm(ppoints(s)),sort(s),xpower=1)  # do not transform normal quantiles
.KW plot*
.KW hplot*
.KW dynamic graphics
.WR
