# Diagnostic Residual statistics and plots from spatial analyses

## !SPATIAL

!SPATIAL
increases the amount of information reported on the residuals
obtained from the analysis of a two dimensional regular grid field trial.
The information
is written to the
.res
file.
## Variogram

The variogram has been suggested as a useful diagnostic for assisting
with the identification of appropriate variance models for spatial
data (Cressie, 1991). Gilmour ` et al.` (1997) demonstrate its
usefulness for the identification of the sources of variation in the
analysis of field experiments. If the elements of the data vector (and
hence the residual vector) are indexed by a vector of spatial
coordinates, then the ordinates of the
sample variogram are given by the half the variance of the difference
between the residuals.
The sample variogram reported by ASReml has two forms depending on
whether the spatial coordinates represent a complete rectangular
lattice (as typical of a field trial) or not.
In the lattice case,
the sample variogram is calculated from the triple `(L`_{i}1,Ll_{i}2,v_{i}) where
`L`_{i}1
and `L`_{i}2 are the displacements in the two directions. As there
will be many `v`_{i} with the same displacements,
ASReml calculates the means for each displacement pair `L`_{i}1, L_{i}2
either ignoring the signs (default) or separately
for same sign and opposite sign ( !TWOWAY),
after grouping the larger displacements: 9-10, 11-14, 15-20, ....
The result is displayed
as a perspective plot of the one or two surfaces
by absolute displacement group.
this case, the two directions may be on different scales.
Otherwise ASReml forms a variogram based on radial coordinates.
It calculates the distance between points `d`_{i}=
sqrt`(L`_{i}1^{2}+ L_{i}2^{2}) and an angle
`theta`_{i} subtended by the line from (0,0) to
(`L`_{i}1, L_{i}2)
with the x-axis (`-180lt theta`_{i} lt 180).
The angle can be calculated as `theta`_{i} =
arctan`(L`_{i}1/L_{i}2)
choosing (`0lt theta`_{i}lt 180) since there is radial
symmetry (the numbers are the same for `ij`
and `ji`).
The variogram presented averages the `v`_{i} within
12 distance classes and 4, 6 or 8
sectors (selected using a
!VGSECTORS qualifier)
centred on an angle of `(i-1)*180/s (i=1,...s)`.
A figure is produced which
reports the trends in average(`v`_{i}) with increasing distance for each sector.
ASReml also

computes the variogram from predictors of random effects which appear to have a
variance structures defined in terms of distance.
The variogram details are reported in the .res file.
#### !TWOWAY

!TWOWAY
modifies the appearance of the variogram calculated from
the residuals obtained from a two dimensional field trial.
The default form is based on absolute 'distance' in each direction.
This form distinguishes same sign and different sign distances
and plots the variances separately as two layers in the same figure.
#### !VGSECTORS

!VGSECTORS [`s`]

requests that the variogram formed from the BLUPs
predicted for a
fac(`X`,`Y`)
term be based on `s` (=4, 6 or 8)
sectors of size `180/s`. The appropriate sectors are
centred on the `X` and `Y` directions. The details are written
to the
.res
file as well as creating a figure.
**Return to start**