step.gam(object, scope, scale, direction, trace = T, keep, steps)
The supplied model object is used as the starting model, and hence there is the requirement that one term from each of the term formulas be present in formula(object). This also implies that any terms in formula(object) not contained in any of the term formulas will be forced to be present in every model considered.
While step.glm uses score-test approximations to speed up the search, step.gam forgoes this speedup in favor of greater generality. 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 corresponding 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 fitted, the best 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.
step(gam.object, scope=list( "Age" = ~ 1 + Age + log(Age), "BP" = ~ 1 + BP + poly(BP,2) + s(BP), "Chol" = ~ s(Chol, df = 4) + s(Chol, df = 7) ))