\HeaderA{gam2objective}{Objective functions for GAM smoothing parameter estimation}{gam2objective}
\aliasA{gam2derivative}{gam2objective}{gam2derivative}
\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/AIC 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/AIC score of a GAM model, given
smoothing parameters, in a manner suitable 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,...)
gam2derivative(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.fit3}{gam.fit3}}.
\item[\code{...}] Other arguments for passing to \code{gam.fit3}.
\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/AIC score and its
derivatives w.r.t. log smoothing parameters.

\code{gam4objective} is an equivalent to \code{gam2objective}, suitable for
optimization by \code{\LinkA{nlm}{nlm}} - derivatives of the GCV/UBRE/AIC 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.

Wood, S.N. (2008) Fast stable direct fitting and smoothness selection for generalized
additive models. J.R.Statist.Soc.B 70(3):495-518

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

