Stata 15 help for stepwise

[R] stepwise -- Stepwise estimation

Syntax

stepwise [, options] : command

options Description ------------------------------------------------------------------------- Model * pr(#) significance level for removal from the model * pe(#) significance level for addition to the model

Model2 forward perform forward-stepwise selection hierarchical perform hierarchical selection lockterm1 keep the first term lr perform likelihood-ratio test instead of Wald test

Reporting display_options control columns and column formats and line width ------------------------------------------------------------------------- * At least one of pr(#) or pe(#) must be specified. by and xi are allowed; see prefix. Weights are allowed if command allows them; see weight. All postestimation commands behave as they would after command without the stepwise prefix; see the postestimation manual entry for command.

Menu

Statistics > Other > Stepwise estimation

Description

stepwise performs stepwise estimation. Typing

. stepwise, pr(#): command

performs backward-selection estimation for command. The stepwise selection method is determined by the following option combinations:

options Description ------------------------------------------------------------------------- pr(#) backward selection pr(#) hierarchical backward hierarchical selection pr(#) pe(#) backward stepwise

pe(#) forward selection pe(#) hierarchical forward hierarchical selection pr(#) pe(#) forward forward stepwise -------------------------------------------------------------------------

command defines the estimation command to be executed. The following Stata commands are supported by stepwise.

betareg, clogit, cloglog, glm, intreg, logistic, logit, nbreg, ologit, oprobit, poisson, probit, qreg, regress, scobit, stcox, stcrreg, stintreg, streg, tobit

stepwise expects command to have the following form:

command_name [depvar] term [term ...] [if] [in] [weight] [, command_options]

where term is either varname or (varlist) (a varlist in parentheses indicates that this group of variables is to be included or excluded together). depvar is not present when command_name is stcox, stcrreg, stintreg, or streg; otherwise, depvar is assumed to be present. For intreg, depvar is actually two dependent variable names (depvar1 and depvar2).

sw is a synonym for stepwise.

Options

+-------+ ----+ Model +------------------------------------------------------------

pr(#) specifies the significance level for removal from the model; terms with p>=pr() are eligible for removal.

pe(#) specifies the significance level for addition to the model; terms with p<pe() are eligible for addition.

+--------+ ----+ Model2 +-----------------------------------------------------------

forward specifies the forward-stepwise method and may be specified only when both pr() and pe() are also specified. Specifying both pr() and pe() without forward results in backward-stepwise selection. Specifying only pr() results in backward selection, and specifying only pe() results in forward selection.

hierarchical specifies hierarchical selection.

lockterm1 specifies that the first term be included in the model and not be subjected to the selection criteria.

lr specifies that the test of term significance be the likelihood-ratio test. The default is the less computationally expensive Wald test; that is, the test is based on the estimated variance-covariance matrix of the estimators.

+-----------+ ----+ Reporting +--------------------------------------------------------

display_options: noci, nopvalues, cformat(%fmt), pformat(%fmt), sformat(%fmt), and nolstretch; see [R] estimation options.

Examples

Setup . sysuse auto . generate weight2 = weight^2

Backward selection . stepwise, pr(.2): regress mpg weight weight2 displ gear turn headroom foreign price

Backward selection; consider engine displacement and gear ratio together . stepwise, pr(.2): regress mpg weight weight2 (displ gear) turn headroom foreign price

Backward selection; force weight to be included in model . stepwise, pr(.2) lockterm1: regress mpg weight weight2 displ gear turn headroom foreign price

Backward selection; force weight and weight2 to be included in model . stepwise, pr(.2) lockterm1: regress mpg (weight weight2) displ gear turn headroom foreign price

Backward hierarchical selection . stepwise, pr(.2) hierarchical: regress mpg weight weight2 displ gear turn headroom foreign

Forward selection . stepwise, pe(.2): regress mpg weight weight2 displ gear turn headroom foreign price

Forward hierarchical selection . stepwise, pe(.2) hierarchical: regress mpg weight weight2 displ gear turn headroom foreign price

Programming for stepwise

stepwise requires that command_name follow standard Stata syntax and allow the if qualifier. Furthermore, command_name must have sw or swml as a program property; see [P] program properties. If command_name has swml as a property, command_name must store the log-likelihood value in e(ll) and model degrees of freedom in e(df_m).

Stored results

stepwise stores whatever is stored by the underlying estimation command.

Also, stepwise stores stepwise in e(stepwise).


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index