\HeaderA{gam.outer}{Minimize GCV or UBRE score of a GAM using `outer' iteration}{gam.outer}
\keyword{models}{gam.outer}
\keyword{smooth}{gam.outer}
\keyword{regression}{gam.outer}
\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.

This routine optimizes a GCV or UBRE score in this way. Basically the GCV or
UBRE score is evaluated for each trial set of smoothing parameters by
estimating the GAM for those smoothing parameters. The score is minimized
w.r.t. the parameters numerically, using \code{newton} (default), \code{bfgs}, \code{optim} or \code{nlm}. Exact
(first and second) derivatives of the score can be used by fitting with
\code{\LinkA{gam.fit3}{gam.fit3}}. This
improves efficiency and reliability relative to relying on finite
difference derivatives.  

Not normally called directly, but rather a service routine for \code{\LinkA{gam}{gam}}.
\end{Description}
\begin{Usage}
\begin{verbatim}
gam.outer(lsp,fscale,family,control,method,gamma,G,...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{lsp}] The log smoothing parameters.
\item[\code{fscale}] Typical scale of the GCV or UBRE/AIC score.
\item[\code{family}] the model family.
\item[\code{control}] control argument to pass to \code{\LinkA{gam.fit}{gam.fit}} if pure
finite differencing is being used.
\item[\code{method}] method list returned from \code{\LinkA{gam.method}{gam.method}}. This defines
the optimization method to use.
\item[\code{gamma}] The degree of freedom inflation factor for the GCV/UBRE/AIC score.
\item[\code{G}] List produced by \code{\LinkA{gam.setup}{gam.setup}}, containing most of what's
needed to actually fit a GAM.
\item[\code{...}] other arguments, typically for passing on to \code{gam.fit3} (ultimately).
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
See Wood (2008) for full details on `outer iteration'.
\end{Details}
\begin{Author}\relax
Simon N. Wood \email{simon.wood@r-project.org}
\end{Author}
\begin{References}\relax
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}

