Rev 8553 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{gam.control}\alias{gam.control}%- Also NEED an `\alias' for EACH other topic documented here.\title{Setting GAM fitting defaults}\description{ This is an internal function of package \code{mgcv} which allowscontrol of the numerical options for fitting a GAM.Typically users will want to modify the defaults if model fitting fails toconverge, or if the warnings are generated which suggest aloss of numerical stability during fitting. To change the defaultchoise of fitting method, see \code{\link{gam}} arguments \code{method} and \code{optimizer}.}\usage{gam.control(nthreads=1,ncv.threads=1,irls.reg=0.0,epsilon = 1e-07,maxit = 200,mgcv.tol=1e-7,mgcv.half=15, trace = FALSE,rank.tol=.Machine$double.eps^0.5,nlm=list(),optim=list(),newton=list(),idLinksBases=TRUE,scalePenalty=TRUE,efs.lspmax=15,efs.tol=.1,keepData=FALSE,scale.est="fletcher",edge.correct=FALSE)}\arguments{\item{nthreads}{Some parts of some smoothing parameter selection methods (e.g. REML) can use someparallelization in the C code if your R installation supports openMP, and \code{nthreads} is set tomore than 1. Note that it is usually better to use the number of physical cores here, rather than thenumber of hyper-threading cores.}\item{ncv.threads}{The computations for neighbourhood cross-validation (NCV) typically scale better than the rest of the GAM computations and are worth parallelizing. \code{ncv.threads} allows you to set the number of theads to use separately.}\item{irls.reg}{For most models this should be 0. The iteratively re-weighted least squares methodby which GAMs are fitted can fail to converge in some circumstances. For example, data with many zeroes can causeproblems in a model with a log link, because a mean of zero corresponds to an infinite range of linear predictorvalues. Such convergence problems are caused by a fundamental lack of identifiability, but do not show up aslack of identifiability in the penalized linear model problems that have to be solved at each stage of iteration.In such circumstances it is possible to apply a ridge regression penalty to the model to impose identifiability, and\code{irls.reg} is the size of the penalty.}\item{epsilon}{This is used for judging conversion of the GLM IRLS loop in\code{\link{gam.fit3}}.}\item{maxit}{Maximum number of IRLS iterations to perform.}\item{mgcv.tol}{The convergence tolerance parameter to use in GCV/UBRE optimization.}\item{mgcv.half}{If a step of the GCV/UBRE optimization method leadsto a worse GCV/UBRE score, then the step length is halved. This isthe number of halvings to try before giving up.}\item{trace}{Set this to \code{TRUE} to turn on diagnostic output.}\item{rank.tol}{The tolerance used to estimate the rank of the fittingproblem.}\item{nlm}{list of control parameters to pass to \code{\link{nlm}} if this isused for outer estimation of smoothing parameters (not default). See details.}\item{optim}{list of control parameters to pass to \code{\link{optim}} if thisis used for outer estimation of smoothing parameters (not default). See details.}\item{newton}{list of control parameters to pass to default Newton optimizerused for outer estimation of log smoothing parameters. See details.}%- \item{outerPIsteps}{The number of performance interation steps used to%- initialize outer iteration.}\item{idLinksBases}{If smooth terms have their smoothing parameters linked viathe \code{id} mechanism (see \code{\link{s}}), should they also have the samebases. Set this to \code{FALSE} only if you are sure you know what you are doing(you should almost surely set \code{scalePenalty} to \code{FALSE} as well in thiscase).}\item{scalePenalty}{\code{\link{gamm}} is somewhat sensitive to the absolute scalingof the penalty matrices of a smooth relative to its model matrix. This option rescalesthe penalty matrices to accomodate this problem. Probably should be set to \code{FALSE}if you are linking smoothing parameters but have set \code{idLinkBases} to \code{FALSE}.}\item{efs.lspmax}{maximum log smoothing parameters to allow under extended Fellner Schallsmoothing parameter optimization.}\item{efs.tol}{change in REML to count as negligible when testing for EFS convergence. If thestep is small and the last 3 steps led to a REML change smaller than this, then stop.}\item{keepData}{Should a copy of the original \code{data} argument be kept in the \code{gam}object? Strict compatibility with class \code{glm} would keep it, but it wastes space todo so. }\item{scale.est}{How to estimate the scale parameter for exponential family models estimatedby outer iteration. See \code{\link{gam.scale}}.}\item{edge.correct}{With RE/ML smoothing parameter selection in \code{gam} using the default Newton RE/ML optimizer, it is possible to improve inference at the`completely smooth' edge of the smoothing parameter space, by decreasingsmoothing parameters until there is a small increase in the negative RE/ML (e.g. 0.02). Set to \code{TRUE} or to a number representing the target increase to use. Only changes the corrected smoothing parameter matrix, \code{Vc}.}}\details{Outer iteration using \code{newton} is controlled by the list \code{newton}with the following elements: \code{conv.tol} (default1e-6) is the relative convergence tolerance; \code{maxNstep} is the maximumlength allowed for an element of the Newton search direction (default 5);\code{maxSstep} is the maximum length allowed for an element of the steepestdescent direction (only used if Newton fails - default 2); \code{maxHalf} isthe maximum number of step halvings to permit before giving up (default 30).If outer iteration using \code{\link{nlm}} is used for fitting, then the control list\code{nlm} stores control arguments for calls to routine\code{\link{nlm}}. The list has the following named elements: (i) \code{ndigit} isthe number of significant digits in the GCV/UBRE score - by default this isworked out from \code{epsilon}; (ii) \code{gradtol} is the tolerance used tojudge convergence of the gradient of the GCV/UBRE score to zero - by defaultset to \code{10*epsilon}; (iii) \code{stepmax} is the maximum allowable logsmoothing parameter step - defaults to 2; (iv) \code{steptol} is the minimumallowable step length - defaults to 1e-4; (v) \code{iterlim} is the maximumnumber of optimization steps allowed - defaults to 200; (vi)\code{check.analyticals} indicates whether the built in exact derivativecalculations should be checked numerically - defaults to \code{FALSE}. Any ofthese which are not supplied and named in the list are set to their defaultvalues.Outer iteration using \code{\link{optim}} is controlled using list\code{optim}, which currently has one element: \code{factr} which takesdefault value 1e7.}\references{Wood, S.N. (2011) Fast stable restricted maximum likelihoodand marginal likelihood estimation of semiparametric generalized linearmodels. Journal of the Royal Statistical Society (B) 73(1):3-36Wood, S.N. (2004) Stable and efficient multiple smoothing parameter estimation forgeneralized additive models. J. Amer. Statist. Ass.99:673-686.}\author{ Simon N. Wood \email{simon.wood@r-project.org}}\seealso{\code{\link{gam}}, \code{\link{glm.control}} }\keyword{models} \keyword{smooth} \keyword{regression}%-- one or more ..