1. The 'intercept' flag is intended to apply only to the initial model. In other word, you can specify the 'intercept' flag to be 'false' to exclude the intercept term in the initial model. However, the intercept term may still be added to the model during the computation.

2. The 'upper' model is a set of terms that could be added to the model. In other word, you can specify the 'upper' flag to prevent the intercept term being added to the model during the computation.

The following sample code shows an example about how to exclude the intercept term in the end model:

load carsmall

X = [Acceleration,Weight];

y = MPG;

lm = stepwiselm(X,y,...

'upper','y~x1+x2',...

'intercept', false);

lm.Formula

>> y ~ x1 + x2

lm = stepwiselm(X,y,...

'y~-1',...

'upper','y~x1+x2-1');

lm.Formula >> y ~ x1 + x2

If you have many predictors, e.g. 100 predictors, and want the 'upper' to be with no intercept, you can either enter 'y~x1+...+x100-1', or enter a matrix such as 'eye(100,101)', which says to allow all single terms and not an intercept.

For more detailed information about how to use a matrix to specify the terms:

## Best Answer