# [R] Convergence problem in gam(mgcv)

Ariyo Kanno 10dimensioner at gmail.com
Fri Oct 5 16:24:31 CEST 2007

```I'm grateful for your kind help.
I've clearly got the idea and am relieved.

As for question 1, the value of mgcv.conv\$rms is small (less than
1.E-5 while GCV being around 1).

For question 2, as I don't have other reasons to doubt the linearity,
I guess the result is OK.

Sincerely,

Ariyo

2007/10/5, Simon Wood <s.wood at bath.ac.uk>:
>
> On Thursday 04 October 2007 22:11, Ariyo Kanno wrote:
> > Dear all,
> >
> > I'm trying to fit a pure additive model of the following formula :
> > fit <- gam(y~x1+te(x2, x3, bs="cr"))
> > ,with the smoothing parameter estimation method "magic"(default).
> >
> > Regarding this, I have two questions :
> >
> > Question 1 :
> > In some cases the value of "mgcv.conv\$fully.converged" becomes
> > "FALSE", which tells me that the method stopped with a "steepest
> > descent step failure".
> --- This is not necessarily a problem. What does the mgcv.conv\$rms.grad tell
> you? If it's near zero then convergence is probably fine. `fully.converged'
> is only set to TRUE if the gcv optimization terminates with a Newton step
> (and +ve definite hessian). In this circumstance you can be sure that it's
> uphill in all directions from the reported optimum. However, there are cases
> where the gcv score is flat (horizontal) in some direction, or nearly so. In
> this case it may be necessary to use steepest descent and the routine may
> terminate by failing to find a better set of smoothing parameters in the
> steepest descent direction.  The GCV score will be flat w.r.t. changes in a
> smoothing parameter that has an optimum value effectively at infinity.
>
> > So I'd like to modify the arguments of magic() to make it easier to
> > converge. But It doesn't seem like that I can do it by modifying the
> > gam defaults through gam.control(). Is there any means to set magic()
> > arguments from outside ?
>
> gam.control arguments mgcv.tol, mgcv.half and rank.tol actually get passed
> through to magic.
>
> > Question 2 :
> > Sometimes the smoothing parameter for x2 is very large (in the order
> > of 1E+8 or 1E+10), while that for x3 is modest(less than 1), and the
> > opposite cases also happen. Does this indicate that something is
> > wrong, or just that the data is actually linear with respect to x2 or
> > x3 ?
>
> --- large smoothing parameters are fairly normal and simply indicate heavy
> penalization, so I would interpret this as indicating linearity w.r.t. x2 or
> x3 rather than a problem (unless there is other reason to suspect a problem,
> of course.)
>
> best,
> Simon
>
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > http://www.R-project.org/posting-guide.html and provide commented, minimal,
> > self-contained, reproducible code.
>
> --
> > Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> > +44 1225 386603  www.maths.bath.ac.uk/~sw283
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help