\HeaderA{gam2objective}{Objective functions for GAM smoothing parameter estimation}{gam2objective}
\aliasA{gam2derivative}{gam2objective}{gam2derivative}
\aliasA{gam3objective}{gam2objective}{gam3objective}
\keyword{models}{gam2objective}
\keyword{smooth}{gam2objective}
\keyword{regression}{gam2objective}
\begin{Description}\relax
Estimation of GAM smoothing parameters is most stable if
optimization of the UBRE or GCV score is outer to the penalized iteratively
re-weighted least squares scheme used to estimate the model given smoothing 
parameters. These functions evaluate the GCV/UBRE score of a GAM model, given
smoothing parameters, in a manner sutable for use by \code{\LinkA{optim}{optim}} or \code{\LinkA{nlm}{nlm}}.
Not normally called directly, but rather service routines for \code{\LinkA{gam.outer}{gam.outer}}.
\end{Description}
\begin{Usage}
\begin{verbatim}
gam2objective(lsp,args,printWarn=FALSE,...)
gam2derivative(lsp,args,...)
gam3objective(lsp,args,...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{lsp}] The log smoothing parameters.
\item[\code{args}] List of arguments required to call \code{\LinkA{gam.fit2}{gam.fit2}}.
\item[\code{printWarn}] Should \code{\LinkA{gam.fit2}{gam.fit2}} print some warnings? Used to
suppress warnings that are only of interest for the final fitted model, until
that model is reached.
\item[\code{...}] Other arguments for passing to \code{gam.fit2}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{gam2objective} and \code{gam2derivative} are functions suitable
for calling by \code{\LinkA{optim}{optim}}, to evaluate the GCV/UBRE score and it's
derivatives w.r.t. log smoothing parameters.

\code{gam3objective} is an equaivalent to \code{gam2objective}, suitable for
optimization by \code{\LinkA{nlm}{nlm}} - derivatives of the GCV/UBRE function are
calculated and returned as attributes.

The basic idea of optimizing smoothing parameters `outer' to the P-IRLS loop
was first proposed in O'Sullivan et al. (1986).
\end{Details}
\begin{Author}\relax
Simon N. Wood \email{simon.wood@r-project.org}
\end{Author}
\begin{References}\relax
O 'Sullivan, Yandall \& Raynor (1986) Automatic smoothing of regression
functions in generalized linear models. J. Amer. Statist. Assoc. 81:96-103.

\url{http://www.maths.bath.ac.uk/~sw283/}
\end{References}
\begin{SeeAlso}\relax
\code{gam.fit2},  \code{\LinkA{gam}{gam}}, \code{\LinkA{mgcv}{mgcv}}, \code{\LinkA{magic}{magic}}
\end{SeeAlso}

