Let's get started on spatial data visualization. The data we work on
will be data provided with S-PLUS, and the Illinois cancer data. If you have
not already worked with this data, you may want to consult this lab for the details (all the data we need
will be provided here, however).
In this lab we will
- create some visual BW plot from within ArcView (from which you
could calculate BW statistics, if you were really industrious or had lots of
time on your hands - the problem is writing the contiguity matrix, which
describes which counties share boundaries. Vanilla ArcView doesn't do this.)
- run xgobi, and explore some data on the United States (States)
using the techniques of brushing, spinning, symbol size and color choice
- use xgobi to explore the Illinois cancer data set.
- if time allows, and you are interested, use S-PLUS on your
Illinois data, generating some perspective plots, contour plots, and image
plots.
Software Note:
If you don't have
- S-PLUS, you can substitute the free S-PLUS "clone"
R;
- xgobi, then you will need to download it
and install it. Xgobi only works under Unix!
Lab
ArcView
Let's start with ArcView and the project which you just
finished. We're going to practice making a BW plot, and since not all the
cancers are reported for all counties, we'll use population as our
variable. We want to create a BW plot for Illinois of the counties below the
mean in population and those above the mean.
Here's one way to do it:
- click on the Attribute table for the county areas
theme, and click on the Pop1997 variable in that table.
- Now click on the Field menu item, and click
statistics. It will report the mean (and several other) statistics for that
variable.
- You now want to edit your legend, reducing the number
of classes to 2 (use the Classify button), and then setting those
classes to be from 0 to the mean,
and from the mean to some value exceeding all values in the table. To do so,
double click on the legend. You can then double click on the symbol (to
change one symbol to black, and the other to white), and on the Value of
that symbol to set the ranges the way you want.
- What do you think: do crowded counties cluster
together? (Can we answer this question based on the BW plot produced? What
are we ignoring (think about the word "crowded")? Can you correct for it?)
We'll spend the rest of our time today with S-PLUS (or R) and xgobi. The
first thing to do is to telnet to your unix account.
xgobi
We will run xgobi from within S-PLUS, as it allows us to access
S-PLUS's data quite easily.
Begin by launching S-PLUS, from your unix account. This will
require the services of our XWindow Server, eXceed, so you'll need to run it
first (recall how to do this, from our introductory lab. Don't forget to set your
DISPLAY!
The first thing to do is cd to the proper directory. (Do you need a
remind yourself of the basic UNIX commands?)
Although we're going to run S-PLUS, we're actually going to start by playing
around with xgobi on some data provided with S-PLUS. xgobi runs nicely from
within S-PLUS, however.
The directory in which xgobi is installed contains several functions
we will need for the S-PLUS/xgobi link to work properly. The first thing you
should do, therefor, is go to that directory.
At the University of Michigan, the directory is
/group/dengue/xgobi
so we'll use that as our example directory.
Execute the following commands:
cd /group/dengue/xgobi
S-PLUS -e
source("Sfunction")
source("scatmat.s")
to prepare to run xgobi ( unless you're using
R...).
Now you can launch xgobi:
xgobi(state.x77)
When you're done with S-PLUS, you need to quit with the
q()
command (the quit function - not very obvious, is it?!). If you quit and
want to run xgobi again, you'll need to execute the commands above again!
The data (state.x77) is a set of demographic variables for the
States of the U.S. (here's a little meta
data). Try the following from within xgobi:
- Start with an XYPlot of Income versus HS Grad (High School
Graduates). You'll identify a "cluster" of states in the lower left corner.
- Click on the Identify buttom at the top, and have a look at
these points' labels. What observations do you make? (This is also a test of
U.S. Geography!)
- Now we'll brush those points, and inspect them as we cycle
through the variables, to see how well they cluster on other
demographics. Click on Brush, then Persistent (we want the brushed points to
remain brushed). Choose a Color for your brushed points, and a Glyph. Now
move the small colored square over those points you want to brush.
- Now click on the DotPlot button. We'll have a look at the other
variables to see how well this group stays together. Hit the Cycle button
(you can adjust the speed of the cycling by the scroll bar below the Cycle
button).
- Identify another variable on which they cluster fairly
well. Click on Rotate, to do a spinning plot. To choose variables to spin,
click, with the left mouse button, on the circle corresponding to one that
you want removed, and click again with the left mouse button on the one you
want to replace it.
- Try some of the options to the Rotate menu. For example, rather
than Oblique Axis, you can rotate about the X or Y axes. Have you figured
out yet that you can use your mouse to move the axes "by hand"? It can be
maddening to try to get a plot into the position you want! First hit the
Pause button, then try to place it "just so".
The Rock feature is like jittering, especially helpful if you have a
gazillion points (to lend some depth perception). Not as good as stereo by a
mile! (The Pause button has to be off for Rock to work.)
- Click on the Identify button again. As you click on points
you want identified, the labels stick (click again to unstick them). Try
Rotating (or XYPlot, or DotPlot) with the points identified.
- You can use the Scale button to zoom in on selected portions of
the data. Try it now.
- What conclusions do you draw from your exploration?
Now we're ready to read some of the Illinois Cancer data into S-PLUS. I
say "some" because we're only going to look at those cancers which have
non-missing values for all counties. (S-PLUS can handle missing data, but
xgobi cannot.)
First save the two data files illdat and illdat2 to the xgobi directory, or to another
directory in your account, and then save the illdat.S-PLUS file to the same directory
(illdat.S-PLUS is a batch file, which references the two data files).
Once the data is in place, prepare the files for xgobi, and then run
xgobi:
source("illdat.S-PLUS")
xgobi(cancer)
You may now experiment in the same way as you did with the state
data, only this time you have two geographic coordinates (easting and
northing). Note that the synthetic cancer variables (scv variables)
discussed in Jacquez's paper are also
included.
- You can use Scale to reduce the distortion in the data
(you know that Illinois is long and skinny).
- Click on XYPlot. Use the Fix X button on a cancer of
your choice, then hit the Cycle button. This gives you some feeling for the
correlation between your chosen cancer and the rest of the variables.
- Brush an area of Illinois (here you might presumably
choose an area around a Nuclear Site, but for the moment brush in the
vicinity of Chicago, in the North-East part of the state). Explore the
Chicago region using the Rotate plot, DotPlot, and XYPlot. (Alternatively,
you might brush an area of high values for a particular cancer, and examine
it against other variables, and in space).
S-PLUS (or R)
Thus far we haven't used S-PLUS to do anything other than prepare a data set
for use in xgobi. If you have some additional time, and interest, you may
wish to use S-PLUS to interpolate and plot a
cancer variable.
Please
evaluate this lab! We'd like to improve our labs, and value your
suggestions.