[R] Convergence problem in gam(mgcv)

Simon Wood s.wood at bath.ac.uk
Fri Oct 5 10:14:54 CEST 2007

Actually the answers to you questions may well be linked.... 

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.)


> Thank you for your help in advance.
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> 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

More information about the R-help mailing list