For maximal numerical stability the method is based on orthogonal decomposition methods, and attempts to deal with numerical rank deficiency gracefully using a truncated singular value decomposition approach.
magic(y,X,sp,S,off,rank=NULL,H=NULL,C=NULL,w=NULL,
gamma=1,scale=1,gcv=TRUE,ridge.parameter=NULL,
control=list(maxit=50,tol=1e-6,step.half=25,
rank.tol=.Machine$double.eps^0.5))
S
. Any that are negative are autoinitialized, otherwise they are taken as supplying
starting values. A supplied starting value will be reset to a default startiS[[i]]
is the ith penalty matrix, but note
that it is not stored as a full matrix, but rather as the smallest square matrix including all
the non-zero elements of the penalty matrix. Element 1,1 of S[[
S[[i]]
.y
. If w
is an array then
it is taken as the diagonal of this matrix, or simply the weight for eachTRUE
if GCV is to be used, FALSE
for UBRE.b
is given by rV%*%t(rV)*scale
.TRUE
if the method converged by satisfying the convergence criteria, and FALSE
if it coverged
by failing to decrease the score along the search direction.}
TRUE
if the hessian of the UBRE or GCV score was positive definite at convergence.}
magic.post.proc
.The $\theta_i$ are chosen to minize either the GCV score:
$$V_g = \frac{n\|{\bf W}({\bf y} - {\bf Ay})\|^2}{[tr({\bf I} - \gamma {\bf A})]^2}$$
or the UBRE score:
$$V_u=\|{\bf W}({\bf y}-{\bf Ay})\|^2/n-2 \phi tr({\bf I}-\gamma {\bf A})/n + \phi$$
where $\gamma$ is gamma
the inflation factor for degrees of freedom (usually set to 1) and $\phi$
is scale
, the scale parameter. $\bf A$ is the hat matrix (influence matrix) for the fitting problem (i.e
the matrix mapping data to fitted values). Dependence of the scores on the smoothing parameters is through $\bf A$.
The method operates by Newton or steepest descent updates of the logs of the $\theta_i$. A key aspect of the method is stable and economical calculation of the first and second derivatives of the scores w.r.t. the log smoothing parameters. Because the GCV/UBRE scores are flat w.r.t. very large or very small $\theta_i$, it's important to get good starting parameters, and to be careful not to step into a flat region of the smoothing parameter space. For this reason the algorithm rescales any Newton step that would result in a $log(\theta_i)$ change of more than 5. Newton steps are only used if the Hessian of the GCV/UBRE is postive definite, otherwise steepest descent is used. Similarly steepest descent is used if the Newton step has to be contracted too far (indicating that the quadratic model underlying Newton is poor). All initial steepest descent steps are scaled so that their largest component is 1. However a step is calculated, it is never expanded if it is successful (to avoid flat portions of the objective), but steps are successively halved if they do not decrease the GCV/UBRE score, until they do, or the direction is deemed to have failed. (Given the smoothing parameters the optimal $\bf b$ parameters are easily found.)
The method is coded in C
with matrix factorizations performed using LINPACK and LAPACK routines.
magic.post.proc
,
mgcv
,
gam
,