Statistics Toolbox | ![]() ![]() |
Interactive plot for fitting and predicting analysis of covariance models
Syntax
aoctool(x,y,g) aoctool(x,y,g,alpha) aoctool(x,y,g,alpha,xname,yname,gname) aoctool(x,y,g,alpha,xname,yname,gname,'displayopt
') aoctool(x,y,g,alpha,xname,yname,gname,'displayopt
','model
') h = aoctool(...) [h,atab,ctab] = aoctool(...) [h,atab,ctab,stats] = aoctool(...)
Description
aoctool(x,y,g)
fits a separate line to the column vectors, x
and y
, for each group defined by the values in the array g
. These types of models are known as one-way analysis of covariance (ANOCOVA) models. The output consists of three figures:
You can use the figures to change models and to test different parts of the model. More information about interactive use of the aoctool
function appears on The aoctool Demo.
aoctool(x,y,g,alpha)
determines the confidence levels of the prediction intervals. The confidence level is 100*(1-alpha)
%. The default value of alpha
is 0.05.
aoctool(x,y,g,alpha,xname,yname,gname)
specifies the name to use for the x
, y
, and g
variables in the graph and tables. If you enter simple variable names for the x
, y
, and g
arguments, the aoctool function uses those names. If you enter an expression for one of these arguments, you can specify a name to use in place of that expression by supplying these arguments. For example, if you enter m(:,2)
as the x
argument, you might choose to enter 'Col 2'
as the xname
argument.
aoctool(x,y,g,alpha,xname,yname,gname,'
enables the graph and table displays when 'displayopt
')
displayopt
' is 'on'
(default) and suppresses those displays when 'displayopt
' is 'off'
.
aoctool(x,y,g,alpha,xname,yname,gname,'
specifies the initial model to fit. The value of 'displayopt
','model
')
model
' can be any of the following:
'same mean'
- fit a single mean, ignoring grouping
'separate means'
- fit a separate mean to each group
'same line'
- fit a single line, ignoring grouping
'parallel lines'
- fit a separate line to each group, but constrain the lines to be parallel
'separate lines'
- fit a separate line to each group, with no constraints
h = aoctool(...)
returns a vector of handles to the line objects in the plot.
[h,atab,ctab] = aoctool(...)
returns cell arrays containing the entries in ANOVA table (atab
) and the table of coefficient estimates (ctab
). (You can copy a text version of either table to the clipboard by using the Copy Text item on the Edit menu.)
[h,atab,ctab,stats] = aoctool(...)
returns a stats
structure that you can use to perform a follow-up multiple comparison test. The ANOVA table output includes tests of the hypotheses that the slopes or intercepts are all the same, against a general alternative that they are not all the same. Sometimes it is preferable to perform a test to determine which pairs of values are significantly different, and which are not. You can use the multcompare
function to perform such tests by supplying the stats
structure as input. You can test either the slopes, the intercepts, or population marginal means (the heights of the curves at the mean x
value).
Example
This example illustrates how to fit different models non-interactively. First, we load the smaller car dataset and fit a separate-slopes model, then examine the coefficient estimates.
[h,a,c,s] = aoctool(Weight,MPG,Model_Year,0.05,... '','','','off','separate lines'); c(:,1:2) ans = 'Term' 'Estimate' 'Intercept' [45.97983716833132] ' 70' [-8.58050531454973] ' 76' [-3.89017396094922] ' 82' [12.47067927549897] 'Slope' [-0.00780212907455] ' 70' [ 0.00195840368824] ' 76' [ 0.00113831038418] ' 82' [-0.00309671407243]
Roughly speaking, the lines relating MPG
to Weight
have an intercept close to 45.98 and a slope close to -0.0078. Each group's coefficients are offset from these values somewhat. For instance, the intercept for the cars made in 1970 is 45.98-8.58 = 37.40.
Next, we try a fit using parallel lines. (If we had examined the ANOVA table, we would have found that the parallel-lines fit is significantly worse than the separate-lines fit.)
[h,a,c,s] = aoctool(Weight,MPG,Model_Year,0.05,... '','','','off','parallel lines'); c(:,1:2) ans = 'Term' 'Estimate' 'Intercept' [43.38984085130596] ' 70' [-3.27948192983761] ' 76' [-1.35036234809006] ' 82' [ 4.62984427792768] 'Slope' [-0.00664751826198]
Here we again have separate intercepts for each group, but this time the slopes are constrained to be the same.
See Also
anova1
, multcompare
, polytool
![]() | anovan | barttest | ![]() |