[S] plotting residuals in x,y space

Laurie Becker (lbecker@digitalis.net)
Thu, 2 Apr 1998 13:50:16 -0600

Dear SPlus users:

I am a new user to SPlus, using v.4.0 and am halfway between knowing how to
accomplish what I want via scripts and being dependent on the menu system.
My question concerns using Trellis graphics to produce plots of deviance
residuals in x,y space (to look for spatial structure remaining in the

I have a script that produces these plots (included below), but wanted to
find a more expedient/generic way of producing plots for numerous models.

So far I have been able to produce scatter plots of x / y coordinates from
data frame conditioned on the residuals from a gam object using the
following procedures within the menu system of v.4.0:

- select xcrd,ycrd columns from my data frame and produce a scatter plot
- click within the plot to get Graph 2D properties dialog box and choose
Multipanel tab
- enter the following parameters:
panel type: condition
conditioning columns:
column list: resid.deviance
(saved from model run
using menu system)
data set: object.resid
(saved as output from
type: continuous
order type: data

I can choose the # of panels, overlap and the range (only equal range,
equal count or from columns). But I want to divide my residuals up into
quantiles per my script, but have not found a way to do so within the
dialog boxes. Is there a way to do this, or do I need to subdivide my
residuals into quantiles beforehand and write them into separate columns?
I haven't found a way to add extra columns to the residual vector
within the model object because it is a vector and allows only one column.
Also I need to maintain a correspondence between the residual value and
the x and y coordinate for that residual.

If this doesn't seem like an expedient way to produce the plots, could
anyone suggest ways in which to improve the script below to make it more
expedient (and to be able to save the resulting data frame and plot within
model object)? Could I use the Trellis intervals or subset functions and
if so how?
These functions assume that the data is in one data frame, which means that

I would have to create separate data frames of resid, xcrd, ycrd for each
(something I was trying to avoid).

This script uses a file that is created by appending the residuals from a
model with the x and y coordinates of data points from a data frame
(resid, xcrd, ycrd). The residuals are then grouped into 3 separate files
quantiles. Four (4) plots are then produced in x,y space to display the
spatial distribution of the residuals.

par(mfrow=c(2,2), oma=c(0,0,3,0))

lowresid_hold[(hold[,1] < q.25),]
highresid_hold[(hold[,1] > q.75),]
hold2_hold[(hold[,1] >= q.25),]
normresid_hold2[(hold2[,1] <= q.75),]
mtext("Quantiles of residuals for ht2gam3",side=3,outer=T,cex=1.5)

Thank you for any help you may be able to offer.

Laurie Becker

Land Information and Computer Graphics Facility
University of Wisconsin - Madison

This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news