step.gam(object, scope, scale, direction, trace = TRUE, keep, steps, ...)
gam
or any of it's inheritants."both"
, "backward"
, or "forward"
, with a default of "both"
. If scope
is missing, the default for direction
is "backward".TRUE
, information is printed during the running of step.gam()
. This is an encouraging choice in general, since step.gam()
can take some time to compute either for large models or when called with an an extensive <gam
object and the associated "AIC" statistic, and whose output is arbitrary. Typically keep()
will select a subset of the components of the object and return them. The default is not to keep
"anova"
component corresponding to the steps taken in the search, as well as a "keep"
component if the keep=
argument was supplied in the call.
We describe the most general setup, when direction = "both"
.
At any stage there is a current model comprising a single term from each of the term formulas supplied in the scope=
argument.
A series of models is fitted, each corrresponding to a formula obtained by moving each of the terms one step up or down in its regimen, relative to the formula of the current model.
If the current value for any term is at either of the extreme ends of its regimen, only one rather than two steps can be considered.
So if there are p
term formulas, at most 2*p - 1
models are considered.
A record is kept of all the models ever visited (hence the -1
above), to avoid repetition.
Once each of these models has been fit, the "best" model
in terms of the AIC statistic is selected and defines the step.
The entire process is repeated until either the maximum number of steps has been used, or until the AIC criterion can not be decreased by any of the eligible steps.
Hastie, T. and Tibshirani, R. (1990) Generalized Additive Models. London: Chapman and Hall.
step
,glm
, gam
, drop1
, add1
, anova.gam
data(gam.data)
gam.object <- gam(y~x+z, data=gam.data)
step.object <-step.gam(gam.object, scope=list("x"=~1+x+s(x,4)+s(x,6)+s(x,12),"z"=~1+z+s(z,4)))
Run the code above in your browser using DataLab