\HeaderA{surf.gls}{Fits a Trend Surface by Generalized Least-squares}{surf.gls}
\keyword{spatial}{surf.gls}
\begin{Description}\relax
Fits a trend surface by generalized least-squares.
\end{Description}
\begin{Usage}
\begin{verbatim}
surf.gls(np, covmod, x, y, z, nx = 1000, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{np}] degree of polynomial surface

\item[\code{covmod}] function to evaluate covariance or correlation function

\item[\code{x}] x coordinates or a data frame with columns \code{x}, \code{y}, \code{z}

\item[\code{y}] y coordinates

\item[\code{z}] z coordinates. Will supersede \code{x\$z}

\item[\code{nx}] Number of bins for table of the covariance. Increasing adds accuracy,
and increases size of the object.

\item[\code{...}] parameters for \code{covmod}

\end{ldescription}
\end{Arguments}
\begin{Value}
list with components

\begin{ldescription}
\item[\code{beta}] the coefficients

\item[\code{x}] 
\item[\code{y}] 
\item[\code{z}] and others for internal use only.

\end{ldescription}
\end{Value}
\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{\LinkA{trmat}{trmat}}, \code{\LinkA{surf.ls}{surf.ls}}, \code{\LinkA{prmat}{prmat}}, \code{\LinkA{semat}{semat}}, \code{\LinkA{expcov}{expcov}}, \code{\LinkA{gaucov}{gaucov}}, \code{\LinkA{sphercov}{sphercov}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
library(MASS)  # for eqscplot
data(topo, package="MASS")
topo.kr <- surf.gls(2, expcov, topo, d=0.7)
trsurf <- trmat(topo.kr, 0, 6.5, 0, 6.5, 50)
eqscplot(trsurf, type = "n")
contour(trsurf, add = TRUE)

prsurf <- prmat(topo.kr, 0, 6.5, 0, 6.5, 50)
contour(prsurf, levels=seq(700, 925, 25))
sesurf <- semat(topo.kr, 0, 6.5, 0, 6.5, 30)
eqscplot(sesurf, type = "n")
contour(sesurf, levels = c(22, 25), add = TRUE)
\end{ExampleCode}
\end{Examples}

