Stepwise Linear Regression

One step in the modeling process is determining what variables to include in the regression model. Stepwise regression uses automatic variable selection procedures to suggest what model to use. The user supplies formulas representing the simplest (Lower Formula) and most complex (Upper Formula) models to consider, and the stepwise regression procedure alternates between adding terms to and deleting terms from the model until no further changes are appropriate.

To perform stepwise linear regression

Choose Statistics __image\arrow5.gif Regression __image\arrow5.gif Stepwise. The dialog shown below appears.

Model Page

__image\stepreg1.gif

In the Stepwise Linear Regression dialog, the Model page contains the following options:

Data

Data Set

Select a data set from the dropdown list or type the name of a data set. You can also type into the Data Set edit field any expression that evaluates to a data set.

Weights

Enter the column that specifies weights to be applied to all observations used in the analysis. To weight all rows equally, leave this blank.

Subset Rows

Enter an S-PLUS expression that identifies the rows to use in the analysis. To use all the rows in the data set, leave this field blank.

Omit Rows with Missing Values

Select this box to omit from the analysis any rows in the data set that contain missing values for any of the variables in the model.

Models Scope

Upper Formula

Enter the upper formula (with the most terms) that defines an upper limit for all the models to be tried in the model search.

Lower Formula

Enter the lower formula (with the fewest terms) that defines a lower limit for all the models to be tried in the model search. The default is the NULL model.

Create Formula

Click the Create Formula button to open a formula builder dialog used to construct a formula specifying the desired model. See the online Help section Building Formulas for more information.

Stepping Options

Stepping Direction

Select the mode of stepwise search: both, backward, or forward.

Print a Trace of All Fits

Select to print information for all the fits in the stepwise search.

Save Model Object

Save Model Object

In the Save As field, enter the name for the object in which to save the results of the analysis. If an object with this name already exists, its contents are overwritten. The model object can be used in later functions such as plotting.

Results page

On the Results page, choose the type of printed results. To select or clear an option, click the check box.

__image\stepreg2.gif

In the Stepwise Linear Regression dialog, the Results page contains the following options:

Printed Results

Short Output for Stepwise Regression

Select this to display a short summary of the model fit. This includes the model formula, the regression coefficients, the residual standard error and the degrees of freedom.

Long Output for Stepwise Regression

Select this to display a more detailed summary of the model fit.

ANOVA Table

Display an analysis of variance table. The sums-of-squares in the table are for the terms added sequentially (Type I sums-of-squares).

Correlation Matrix of Estimates

Display the correlation matrix of the regression coefficients. This option is available only if Long Output is selected.

Related S-Plus language functions

lm, step, add1, drop1, menuStep