This routine estimates a GAM given log smoothing paramaters, and evaluates the first derivative of the GCV and UBRE scores of the model with respect to the log smoothing parameters. Calculation of exact derivatives is generally faster than approximating them by finite differencing, as well as generally improving the reliability of GCV/UBRE score minimization.
Not normally called directly, but rather a service routine for gam
.
gam.fit2(x, y, sp, S=list(),rS=list(),off, H=NULL,
weights = rep(1, nobs), start = NULL, etastart = NULL,
mustart = NULL, offset = rep(0, nobs), family = gaussian(),
control = gam.control(), intercept = TRUE,deriv=TRUE,
gamma=1,scale=1,pearson=FALSE,printWarn=TRUE)
off[i]
indicates which parameter is the first one penalized
by S[[i]]
.off[i]
indicates which parameter S[[i]][1,1]
relates to.gaussian()
glm.control
TRUE
or
FALSE
TRUE
or FALSE
FALSE
to suppress some warnings. Useful in
order to ensure that some warnings are only printed if they apply to the final
fitted model, rather than an intermediate used in optimization.glm.fit
with some
modifications to allow (i) for quadratic penalties on the log likelihood;
(ii) derivatives of the model coefficients with respect to
log smoothing parameters to be obtained (by updating alongside the P-IRLS
iteration) and (iii) derivatives of the GAM GCV and UBRE scores to be
evaluated at convergence. In addition the routine applies step halving to any step that increases the penalized deviance substantially.
The most costly parts of the calculation are performed by calls to compiled C code (which in turn calls LAPACK routines) in place of the compiled code that would usually perform least squares estimation on the working model in the IRLS iteration.
Estimation of smoothing parameters by optimizing GCV scores obtained at convergence of the P-IRLS iteration was proposed by O'Sullivan et al. (1986), and is here termed `outer' iteration.
Note that use of non-standard families with this routine requires modification
of the families as described in fix.family.link
.
gam.fit
, gam
, mgcv
, magic