### Function Reference: `stepwisefit`

statistics: [X_use, b, bint, r, rint, stats] = stepwisefit (y, X, penter = 0.05, premove = 0.1, method = "corr")

Linear regression with stepwise variable selection.

### Arguments

- y is an n by 1 vector of data to fit.
- X is an n by k matrix containing the values of k potential predictors. No constant term should be included (one will always be added to the regression automatically).
- penter is the maximum p-value to enter a new variable into the regression (default: 0.05).
- premove is the minimum p-value to remove a variable from the regression (default: 0.1).
- method sets how predictors are selected at each step, either based on their correlation with the residuals ("corr", default) or on the p values of their regression coefficients when they are successively added ("p").

### Return values

- X_use contains the indices of the predictors included in the final regression model. The predictors are listed in the order they were added, so typically the first ones listed are the most significant.
- b, bint, r, rint, stats are the results of `[b, bint, r, rint, stats] = regress(y, [ones(size(y)) X(:, X_use)], penter);`

### References

1. N. R. Draper and H. Smith (1966). Applied Regression Analysis. Wiley. Chapter 6.

See also: regress

Source Code: stepwisefit