Documentation |
Interactive stepwise regression
stepwise
stepwise(X,y)
stepwise(X,y,inmodel,penter,premove)
stepwise uses the sample data in hald.mat to display a graphical user interface for performing stepwise regression of the response values in heat on the predictive terms in ingredients.
The upper left of the interface displays estimates of the coefficients for all potential terms, with horizontal bars indicating 90% (colored) and 95% (grey) confidence intervals. The red color indicates that, initially, the terms are not in the model. Values displayed in the table are those that would result if the terms were added to the model.
The middle portion of the interface displays summary statistics for the entire model. These statistics are updated with each step.
The lower portion of the interface, Model History, displays the RMSE for the model. The plot tracks the RMSE from step to step, so you can compare the optimality of different models. Hover over the blue dots in the history to see which terms were in the model at a particular step. Click on a blue dot in the history to open a copy of the interface initialized with the terms in the model at that step.
Initial models, as well as entrance/exit tolerances for the p-values of F-statistics, are specified using additional input arguments to stepwise. Defaults are an initial model with no terms, an entrance tolerance of 0.05, and an exit tolerance of 0.10.
To center and scale the input data (compute z-scores) to improve conditioning of the underlying least-squares problem, select Scale Inputs from the Stepwise menu.
You proceed through a stepwise regression in one of two ways:
Click Next Step to select the recommended next step. The recommended next step either adds the most significant term or removes the least significant term. When the regression reaches a local minimum of RMSE, the recommended next step is "Move no terms." You can perform all of the recommended steps at once by clicking All Steps.
Click a line in the plot or in the table to toggle the state of the corresponding term. Clicking a red line, corresponding to a term not currently in the model, adds the term to the model and changes the line to blue. Clicking a blue line, corresponding to a term currently in the model, removes the term from the model and changes the line to red.
To call addedvarplot and produce an added variable plot from the stepwise interface, select Added Variable Plot from the Stepwise menu. A list of terms is displayed. Select the term you want to add, and then click OK.
Click Export to display a dialog box that allows you to select information from the interface to save to the MATLAB^{®} workspace. Check the information you want to export and, optionally, change the names of the workspace variables to be created. Click OK to export the information.
stepwise(X,y) displays the interface using the p predictive terms in the n-by-p matrix X and the response values in the n-by-1 vector y. Distinct predictive terms should appear in different columns of X.
Note: stepwise automatically includes a constant term in all models. Do not enter a column of 1s directly into X. |
stepwise treats NaN values in either X or y as missing values, and ignores them.
stepwise(X,y,inmodel,penter,premove) additionally specifies the initial model (inmodel) and the entrance (penter) and exit (premove) tolerances for the p-values of F-statistics. inmodel is either a logical vector with length equal to the number of columns of X, or a vector of indices, with values ranging from 1 to the number of columns in X. The value of penter must be less than or equal to the value of premove.