gam
which is a generalized additive
fit of the model.
gam(formula = formula(data), family = gaussian, data = <<see below>>, weights = <<see below>>, subset = <<see below>>, na.action = na.fail, start = <<see below>>, control = gam.control(...), trace = F, model = F, x = F, y = T, qr = F, method = "qr", contrasts = NULL, ...)
s
for
smoothing splines or
lo
for
loess
smooth terms.
Additional smoothers can be added by creating the appropriate interface.
Interactions with nonparametric smooth terms are not fully supported,
but will not produce errors; they will simply
produce the usual parametric interaction.
link
and
variance
functions, initialization, and iterative weights.
Families supported are
gaussian
,
binomial
,
poisson
,
Gamma
,
inverse.gaussian
and
quasi
.
Functions such as
binomial
produce a family object, but can
be given without the parentheses.
Family functions can take arguments, as in
binomial(link=probit)
.
model.frame
after
any
subset
argument has been used.
The default (with
na.fail
) is to create an error
if any missing values are found.
A possible alternative is
na.exclude
, which deletes observations
that contain one or more missing values.
gam.control
for their names and default values.
These can also be set as arguments to
gam
itself.
TRUE
, then the status during each iteration of
the fitting is reported.
TRUE
, then the
x
matrix is returned as component
x
.
TRUE
, then the response is returned as component
y
.
TRUE
, then the function returns additional information from that method. Default =
FALSE
.
qr
,
svd
, or
chol
.
lm
can be given
including
weights
,
subset
and
na.action
.
gam
is returned, which inherits from both
glm
and
lm
.
See
gam.object
for details.
Components can be extracted using extractor functions
predict
,
fitted
,
residuals
,
deviance
,
formula
, and
family
.
The output can be modified using
update
.
It has all the components of a
glm
object, with a few more.
The response variable must conform with the definition of
family
, for example
factor or binary data if
family=binomial
is declared.
The model is fit using the
local scoringalgorithm, which iteratively fits weighted additive models by
backfitting.The backfitting algorithm is a Gauss-Seidel method for
fitting additive models, by iteratively smoothing partial residuals.
The algorithm separates the parametric from the nonparametric
part of the fit, and fits the parametric part using weighted linear
least squares within the backfitting algorithm.
Although nonparametric smooth terms
lo
and
s
can be mixed in a
formula,
it is faster and less memory intensive to use a single smoothing
method for all the smoothing terms in an additive model.
In this case the entire local scoring algorithm is performed in Fortran,
which, although faster, is not readable or modifiable by the user.
Hastie, T. and Tibshirani, R. (1990). Generalized Additive Models. Chapman and Hall, London.
gam(Kyphosis ~ s(Age,4) + Number, family = binomial, data = kyphosis) gam(ozone^(1/3) ~ lo(radiation) + lo(wind, temperature), data = air) gam(Kyphosis ~ poly(Age, 2) + s(Start), data = kyphosis, subset = Number>5)