\Header{residuals.gam}{Generalized Additive Model residuals}
\keyword{models}{residuals.gam}
\keyword{smooth}{residuals.gam}
\keyword{regression}{residuals.gam}
\begin{Description}\relax
Returns residuals for a fitted \code{gam} model
object. Pearson, deviance, working and response residuals are
available.
\end{Description}
\begin{Usage}
\begin{verbatim}
residuals.gam(object, type = c("deviance", "pearson","scaled.pearson", "working", "response"),...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{object}] a \code{gam} fitted model object. 
\item[\code{type}] the type of residuals wanted. 
\item[\code{...}] other arguments.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Response residuals are the raw residuals (data minus fitted
values). Scaled Pearson residuals are raw residuals divided by the standard
deviation of the data according to the model mean variance
relationship and estimated scale parameter. Pearson residuals are the same, but multiplied by the square root 
of the scale parameter (so they are independent of the scale parameter):
(\eqn{(y-\mu)/\sqrt{V(\mu)}}{(y-m)/V(m)^0.5}, where  \eqn{y}{y} is data \eqn{\mu}{m} 
is model fitted value and \eqn{V}{V} is model mean-variance relationship.). Both are provided since not all texts 
agree on the definition of Pearson residuals. Deviance residuals simply
return the deviance residuals defined by the model family. Working
residuals are the residuals returned from model fitting at convergence.

There is  a special function for \code{gam} objects because of a bug
in the calculation of Pearson residuals in some earlier versions of
\code{residual.glm}.
\end{Details}
\begin{Value}
An array of residuals.
\end{Value}
\begin{Author}\relax
Simon N. Wood \email{simon@stats.gla.ac.uk}
\end{Author}
\begin{SeeAlso}\relax
\code{\Link{gam}}
\end{SeeAlso}

