Categories &

Functions List

Function Reference: gamtrain

statistics: Mdl = gamtrain (X, Y, Knots, Order, Method, Inter, P1, P2)

Fit a generalized additive model of smoothing splines.

Mdl = gamtrain (X, Y, Knots, Order, Method, Inter, P1, P2) fits one univariate spline per column of X and returns the additive model as a structure. It is the fitting engine shared by ClassificationGAM and RegressionGAM, and it is not meant to be called directly.

  • X is an NxP numeric matrix of predictors. A missing value is not an error: the observation is left out of the affected predictor’s spline and its prediction from that term is NaN.
  • Y is an Nx1 numeric vector of responses. For Method 1 it must hold zeros and ones.
  • Knots is a 1xP vector giving the number of spline pieces for each predictor, and Order a 1xP vector giving the degree of the polynomial on each piece. A spline of K pieces and degree D spans a space of K + D dimensions.
  • Method selects the fitting scheme: 1 boosts the log-odds by gradient descent, as a classifier is fitted, and 2 backfits the partial residuals, as a regression is fitted.
  • Inter is the intercept the fit starts from: a proportion for Method 1, which is stored as its log-odds, and the response mean for Method 2. A proportion of zero or one is not an error: its log-odds is infinite, the gradient is zero throughout and every additive term stays at zero, which is the fit a single-class response has.
  • P1 and P2 are the scheme’s two parameters. For Method 1 they are the learning rate and the number of boosting iterations; for Method 2 the convergence tolerance and the maximum number of backfitting cycles.

Mdl is a structure with the following fields.

  • Intercept, the constant term the additive terms are added to.
  • Parameters, a 1xP structure array of piecewise polynomials in the form ppval consumes, one per predictor.
  • Iterations, the number of iterations performed.
  • Residuals, the Nx1 residual vector at the last iteration.
  • RSS, the scalar residual sum of squares for Method 1 and the 1xP per-term criterion the backfitting stops on for Method 2.

See also: gampredict, ClassificationGAM, RegressionGAM, fitcgam, fitrgam

Source Code: gamtrain