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

\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}

\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{\Link{trmat}}, \code{\Link{surf.gls}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
library(MASS)  # for eqscplot
data(topo, package="MASS")
topo.kr <- surf.ls(2, topo)
trsurf <- trmat(topo.kr, 0, 6.5, 0, 6.5, 50)
eqscplot(trsurf, type = "n")
contour(trsurf, add = TRUE)
points(topo)

eqscplot(trsurf, type = "n")
contour(trsurf, add = TRUE)
plot(topo.kr, add = TRUE)
title(xlab= "Circle radius proportional to Cook's influence statistic")
\end{ExampleCode}
\end{Examples}

