Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

**Class: **GeneralizedLinearModel

Create generalized linear regression model by stepwise regression

`GeneralizedLinearModel.stepwise`

will be removed
in a future release. Use `stepwiseglm`

instead.

`mdl = GeneralizedLinearModel.stepwise(tbl,modelspec)`

mdl = GeneralizedLinearModel.stepwise(X,y,modelspec)

mdl = GeneralizedLinearModel.stepwise(...,modelspec,Name,Value)

creates
a generalized linear model of a table or dataset array `mdl`

= GeneralizedLinearModel.stepwise(`tbl`

,`modelspec`

)`tbl`

,
using stepwise regression to add or remove predictors. `modelspec`

is
the starting model for the stepwise procedure.

creates
a generalized linear model of the responses `mdl`

= GeneralizedLinearModel.stepwise(`X`

,`y`

,`modelspec`

)`y`

to
a data matrix `X`

, using stepwise regression to add
or remove predictors.

creates
a generalized linear model with additional options specified by one
or more `mdl`

= GeneralizedLinearModel.stepwise(...,`modelspec`

,`Name,Value`

)`Name,Value`

pair arguments.

The generalized linear model

`mdl`

is a standard linear model unless you specify otherwise with the`Distribution`

name-value pair.For other methods such as

`devianceTest`

, or properties of the`GeneralizedLinearModel`

object, see`GeneralizedLinearModel`

.

*Stepwise regression* is a systematic method
for adding and removing terms from a linear or generalized linear
model based on their statistical significance in explaining the response
variable. The method begins with an initial model, specified using `modelspec`

,
and then compares the explanatory power of incrementally larger and
smaller models.

MATLAB^{®} uses forward and backward stepwise regression to
determine a final model. At each step, the method searches for terms
to add to or remove from the model based on the value of the `'Criterion'`

argument.
The default value of `'Criterion'`

is `'sse'`

,
and in this case, `stepwiselm`

uses the * p*-value
of an

Here is how stepwise proceeds when `'Criterion'`

is `'sse'`

:

Fit the initial model.

Examine a set of available terms not in the model. If any of these terms have

-values less than an entrance tolerance (that is, if it is unlikely that they would have zero coefficient if added to the model), add the one with the smallest*p*-value and repeat this step; otherwise, go to step 3.*p*If any of the available terms in the model have

-values greater than an exit tolerance (that is, the hypothesis of a zero coefficient cannot be rejected), remove the one with the largest*p*-value and go to step 2; otherwise, end.*p*

At any stage, the function will not add a higher-order term
if the model does not also include all lower-order terms that are
subsets of it. For example, it will not try to add the term `X1:X2^2`

unless
both `X1`

and `X2^2`

are already
in the model. Similarly, the function will not remove lower-order
terms that are subsets of higher-order terms that remain in the model.
For example, it will not examine to remove `X1`

or `X2^2`

if `X1:X2^2`

stays
in the model.

The default for `stepwiseglm`

is `'Deviance'`

and
it follows a similar procedure for adding or removing terms.

There are several other criteria available, which you can specify
using the `'Criterion'`

argument. You can use the
change in the value of the Akaike information criterion, Bayesian
information criterion, R-squared, adjusted R-squared as a criterion
to add or remove terms.

Depending on the terms included in the initial model and the order in which terms are moved in and out, the method might build different models from the same set of potential terms. The method terminates when no single step improves the model. There is no guarantee, however, that a different initial model or a different sequence of steps will not lead to a better fit. In this sense, stepwise models are locally optimal, but might not be globally optimal.

You can also create a stepwise generalized linear model using `stepwiseglm`

.

Use `fitglm`

to create a
model with a fixed specification. Use `step`

, `addTerms`

,
or `removeTerms`

to adjust a fitted model.

[1] Collett, D. *Modeling Binary
Data*. New York: Chapman & Hall, 2002.

[2] Dobson, A. J. *An Introduction
to Generalized Linear Models*. New York: Chapman &
Hall, 1990.

[3] McCullagh, P., and J. A. Nelder. *Generalized
Linear Models*. New York: Chapman & Hall, 1990.

Was this topic helpful?