Statistics Toolbox | ![]() ![]() |
Example: aoctool with Sample Data
The Statistics Toolbox has a small data set named carsmall
with information about cars. It is a good sample data set to use with aoctool
. You can also use aoctool
with your own data.
To start the demonstration, load the data set.
load carsmall who Your variables are: Acceleration Horsepower Model_Year Cylinders MPG Origin Displacement Model Weight
Suppose we want to study the relationship between the weight of a car and its mileage, and whether this relationship has changed over the years.
[h,atab,ctab,stats] = aoctool(Weight,MPG,Model_Year); Note: 6 observations with missing values have been removed.
The graphical output consists of the following main window, plus a table of coefficient estimates and an analysis of variance table.
The group of each data point is coded by its color and symbol, and the fit for each group has the same color as the data points.
The initial fit models the y variable, MPG
, as a linear function of the x variable, Weight
. Each group has a separate line. The coefficients of the three lines appear in the figure titled ANOCOVA Coefficients. You can see that the slopes are roughly -0.0078, with a small deviation for each group:
Model year 70: |
![]() |
Model year 76: |
![]() |
Model year 82: |
![]() |
Notice that the three fitted lines have slopes that are roughly similar. Could they really be the same? The Model_Year*Weight
interaction expresses the difference in slopes, and the ANOVA table shows a test for the significance of this term. With an F statistic of 5.23 and a p-value of 0.0072, the slopes are significantly different.
To examine the fits when the slopes are constrained to be the same, return to the ANOCOVA Prediction Plot window and use the Model pop-up to select a Parallel Lines model. The window updates to show the graph below.
Though this fit looks reasonable, we know it is significantly worse than the Separate Lines model. Use the Model pop-up again to return to the original model.
The following sections focus on two other interesting aspects of aoctool
:
![]() | The aoctool Demo | Confidence Bounds | ![]() |