stepwisefit
statistics: stepwisefit (X, y)
statistics: b = stepwisefit (X, y)
statistics: b, se, pval, finalmodel, stats, nextstep, history = stepwisefit (X, y, varargin)
Perform stepwise linear regression using conditional p-value criteria.
stepwisefit fits a linear regression model to response vector
y using predictor matrix X and performs stepwise variable
selection based on hypothesis tests for individual regression coefficients.
At each iteration, predictors not currently in the model are tested for inclusion using partial F- or t-tests. The predictor with the smallest p-value below the entry threshold is added. Predictors currently in the model (excluding forced predictors) are then tested for removal, and the predictor with the largest p-value exceeding the removal threshold is removed. The procedure repeats until the model stabilizes or the maximum number of iterations is reached.
After variable selection, the final regression model is refit using
regress to compute coefficient estimates and inferential statistics
for both included and excluded predictors.
"InModel"Logical row vector of length p specifying predictors that are initially included in the model.
"Keep"Logical row vector of length p specifying predictors that must remain in the model and are never removed during stepwise selection.
"PEnter" Scalar significance level in the open interval (0,1) specifying the maximum
p-value required for a predictor to enter the model. Default is 0.05.
"PRemove" Scalar significance level in the open interval (0,1) specifying the minimum
p-value required for a predictor to be removed from the model. If not
specified, a default value greater than or equal to "PEnter" is used.
"MaxIter" Positive integer specifying the maximum number of stepwise iterations.
Default is Inf.
"Scale" Either "on" or "off". When enabled, predictors are
standardized prior to stepwise selection only. Final regression
coefficients are always reported on the original data scale.
"Display" Either "on" or "off". Accepted for compatibility but
currently does not affect output.
See also: regress
Source Code: stepwisefit