Skip to main content

Forward and Backward Variable Selection

Project description



back (y,X)

This package executes the forward and backward selection procedures to aid in selecting variables for inclusion in an OLS regression model.

The forward selection procedure starts with an equation containing no predictor varaibles, only a constant that must be added by the user. To identify the first variable to include in the equation, the independent variable with the highest simple correlation to the response variable is selected and included in an OLS regression. If An evaluation of the independent variable's p-value is completed, and if the variable proves significantly different from zero, it is retained in the equation and a review for a second variable is initiated. To identify a second variable, a correlation with the remaining variables is completed against the residuals from the previous OLS regression. The independent variable with the highest correlation to the residuals is selected as the second variable, which is included in a subsequent OLS regression. If the p-value of this second variable proves significant from zero, this second variable is retained and the search for a third variable is initiated. This process continues for all available variables.

The backward selection procedure starts with all variables including a constant that must be added by the user, and systematically removes the variable with the smallest t-value in each iteration.

To initiate the function, the user must specify the target variable (y) and the independent variable(s) (X).

The output of this package is a table showing the order in which the variables were evaluated, as well as validation factors used for evaluating variables for inclusion in a model. The user should review the table and make determinations based on their preferences.

This variable selection package was developed based on the procedure as described in Chatterjee, Samprit and Hadi, Ali S (2012). Regression Analysis by Example (5th ed.). Hoboken, New Jersey: John Wiley & Sons, Inc.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

variable-0.0.4.tar.gz (4.2 kB view hashes)

Uploaded source

Built Distribution

variable-0.0.4-py2.py3-none-any.whl (5.5 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page