Compare large and small stepwise models
This example shows how to compare models that stepwiselm returns starting from a constant model and starting from a full interaction model.
Load the carbig data and create a table from some of the data.
load carbig
tbl = table(Acceleration,Displacement,Horsepower,Weight,MPG);
Create a mileage model stepwise starting from the constant model.
mdl1 = stepwiselm(tbl,'constant','ResponseVar','MPG')
1. Adding Weight, FStat = 888.8507, pValue = 2.9728e-103
2. Adding Horsepower, FStat = 3.8217, pValue = 0.00049608
3. Adding Horsepower:Weight, FStat = 64.8709, pValue = 9.93362e-15
mdl1 =
Linear regression model:
MPG ~ 1 + Horsepower*Weight
Estimated Coefficients:
Estimate SE tStat pValue
__________ __________ _______ ________