\Header{variogram}{Compute Spatial Variogram}
\keyword{spatial}{variogram}
\begin{Description}\relax
Compute spatial (semi-)variogram of spatial data or residuals.
\end{Description}
\begin{Usage}
\begin{verbatim}
variogram(krig, nint, plotit = TRUE, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{krig}] trend-surface or kriging object with columns \code{x}, \code{y}, and \code{z}

\item[\code{nint}] number of bins used

\item[\code{plotit}] logical for plotting

\item[\code{...}] parameters for the plot

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Divides range of data into \code{nint} bins, and computes the average squared
difference for pairs with separation in each bin.  Returns results for
bins with 6 or more pairs.
\end{Details}
\begin{Value}
\code{x} and \code{y} coordinates of the variogram and \code{cnt},
the number of pairs averaged per bin.
\end{Value}
\begin{Section}{Side Effects}
Plots the variogram if \code{plotit = TRUE}
\end{Section}
\begin{References}\relax
Ripley, B. D. (1981) \emph{Spatial Statistics.} Wiley.

Venables, W. N. and Ripley, B. D. (2002)
\emph{Modern Applied Statistics with S.} Fourth edition.  Springer.
\end{References}
\begin{SeeAlso}\relax
\code{\Link{correlogram}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(topo, package="MASS")
topo.kr <- surf.ls(2, topo)
variogram(topo.kr, 25)
\end{ExampleCode}
\end{Examples}

