The GAM Procedure

Selection of Smoothing Parameters

CV and GCV

The smoothers discussed here have a single smoothing parameter. In choosing the smoothing parameter, cross validation can be used. Cross validation works by leaving points left-parenthesis x Subscript i Baseline comma y Subscript i Baseline right-parenthesis out one at a time, estimating the squared residual for smooth function at x Subscript i based on the remaining n minus 1 data points, and choosing the smoother to minimize the sum of those squared residuals. This mimics the use of training and test samples for prediction. The cross validation function is defined as

normal upper C normal upper V left-parenthesis lamda right-parenthesis equals StartFraction 1 Over n EndFraction sigma-summation Underscript i equals 1 Overscript n Endscripts left-parenthesis y Subscript i Baseline minus ModifyingAbove eta With caret Subscript lamda Superscript left-parenthesis negative i right-parenthesis Baseline left-parenthesis x Subscript i Baseline right-parenthesis right-parenthesis squared

where ModifyingAbove eta With caret Subscript lamda Superscript left-parenthesis negative i right-parenthesis Baseline left-parenthesis x Subscript i Baseline right-parenthesis indicates the fit at x Subscript i, computed by leaving out the ith data point. The quantity n normal upper C normal upper V left-parenthesis lamda right-parenthesis is sometimes called the prediction sum of squares, or PRESS (Allen 1974).

All of the smoothers fit by the GAM procedure can be formulated as a linear combination of the sample responses

ModifyingAbove eta With caret left-parenthesis x right-parenthesis equals bold upper A left-parenthesis lamda right-parenthesis bold y

for some matrix bold upper A left-parenthesis lamda right-parenthesis, which depends on lamda. (The matrix bold upper A left-parenthesis lamda right-parenthesis depends on x and the sample data as well, but this dependence is suppressed in the preceding equation.) Let a Subscript i i be the ith diagonal element of bold upper A left-parenthesis lamda right-parenthesis. Then the CV function can be expressed as

normal upper C normal upper V left-parenthesis lamda right-parenthesis equals StartFraction 1 Over n EndFraction sigma-summation Underscript i equals 1 Overscript n Endscripts left-parenthesis StartFraction left-parenthesis y Subscript i Baseline minus ModifyingAbove eta With caret Subscript lamda Baseline left-parenthesis x Subscript i Baseline right-parenthesis right-parenthesis Over 1 minus a Subscript i i Baseline EndFraction right-parenthesis squared

In most cases, it is very time-consuming to compute the quantity a Subscript i i individually. To solve this computational problem, Wahba (1990) has proposed the generalized cross validation function (GCV) that can be used to solve a wide variety of problems involving selection of a parameter to minimize the prediction risk.

The GCV function is defined as

normal upper G normal upper C normal upper V left-parenthesis lamda right-parenthesis equals StartFraction n sigma-summation Underscript i equals 1 Overscript n Endscripts left-parenthesis y Subscript i Baseline minus ModifyingAbove eta With caret Subscript lamda Baseline left-parenthesis x Subscript i Baseline right-parenthesis right-parenthesis squared Over left-parenthesis n minus normal upper T normal r normal a normal c normal e left-parenthesis bold upper A left-parenthesis lamda right-parenthesis right-parenthesis right-parenthesis squared EndFraction

The GCV formula simply replaces the a Subscript i i with normal upper T normal r normal a normal c normal e left-parenthesis bold upper A left-parenthesis lamda right-parenthesis right-parenthesis slash n. Therefore, it can be viewed as a weighted version of CV. In most of the cases of interest, GCV is closely related to CV but much easier to compute. Specify the METHOD=GCV option in the MODEL statement in order to use the GCV function to choose the smoothing parameters.

Degrees of Freedom

The estimated GAM model can be expressed as

ModifyingAbove eta With caret left-parenthesis upper X right-parenthesis equals ModifyingAbove s With caret Subscript 0 Baseline plus sigma-summation Underscript j equals 1 Overscript p Endscripts bold upper A Subscript j Baseline left-parenthesis lamda Subscript j Baseline right-parenthesis upper Y

Because the weights are calculated based on previous iteration during the local scoring iteration, the matrices bold upper A Subscript j might depend on Y for non-Gaussian data. However, for the final iteration, the bold upper A Subscript j matrix for the spline smoothers has the same role as the projection matrix in linear regression; therefore, nonparametric degrees of freedom (DF) for the jth spline smoother can be defined as

normal upper D normal upper F left-parenthesis j normal t normal h normal s normal p normal l normal i normal n normal e normal s normal m normal o normal o normal t normal h normal e normal r right-parenthesis equals normal upper T normal r normal a normal c normal e left-parenthesis bold upper A Subscript j Baseline left-parenthesis lamda Subscript j Baseline right-parenthesis right-parenthesis

For loess smoothers bold upper A Subscript j is not symmetric and so is not a projection matrix. In this case PROC GAM uses

normal upper D normal upper F left-parenthesis j normal t normal h normal l normal o normal e normal s normal s normal s normal m normal o normal o normal t normal h normal e normal r right-parenthesis equals normal upper T normal r normal a normal c normal e left-parenthesis bold upper A Subscript j Baseline left-parenthesis lamda Subscript j Baseline right-parenthesis prime bold upper A Subscript j Baseline left-parenthesis lamda Subscript j Baseline right-parenthesis right-parenthesis

The GAM procedure gives you the option of specifying the degrees of freedom for each individual smoothing component. If you choose a particular value for the degrees of freedom, then during every local scoring iteration the procedure will search for a corresponding smoothing parameter lambda that yields the specified value or comes as close as possible. The final estimate for the smoother during this local scoring iteration will be based on this lambda. Note that for univariate spline and loess components, an additional degree of freedom is used by default to account for the linear portion of the model, so the value displayed in the "Fit Summary" and "Analysis of Deviance" tables will be one less than the value you specify.

Last updated: December 09, 2022