Next: anovapred() Up: MacAnova Help File Previous: alltrue()   Contents

# anova()

Usage:
 ```anova([Model] [,print:F or silent:T,fstats:T,pvals:T,coefs:F,\ unbalanced:T, marginal:T]) ```

Keywords: glm, anova
```anova(Model) computes and prints an ANOVA table for the linear model in
the CHARACTER variable Model.

Examples (y a REAL vector, a and b factors, x a variate):
anova("y = a")                    One-way ANOVA of y
anova("y = a+b")                  Two-way ANOVA of y with no
interaction
anova("y = x+a+b+a.b")            Two-way analysis of covariance of
y with interaction and covariate x
anova("{log10(y)} = {sqrt(x)}+a") One-way analysis of covariance of
log10(y) with covariate sqrt(x)

All variables referred to in Model must be REAL vectors or factors and
have the same lengths.

See topic 'models' for more information on how to specify Model.

anova(Model,weights:Wts) does an analysis using weighted least squares.
Wts must be a REAL vector with no negative elements, with the same
length as the response vector.

When you omit Model (anova() or anova(,...)), the model used by the most
recent GLM command such as anova(), regress() or poisson() is used.

When the previous GLM command was regress(), no new computations are
done.  The ANOVA table is based on what was previously computed.

When there haven't been previous GLM commands, but CHARACTER variable
STRMODEL exists, anova() uses STRMODEL as Model.

Side effect variables created are RESIDUALS, HII, DF, SS, DEPVNAME,
TERMNAMES, and STRMODEL.

When weights are specified, RESIDUALS = Response - Fitted and
WTDRESIDUALS = sqrt(Wts)*RESIDUALS is an additional side effect vector.
You should use WTDRESIDUALS rather than RESIDUALS in residual plots or
other diagnostic procedures.

Other keyword phrases that can be used with anova() are 'unbalanced:T',
'print:T', 'silent:T', 'fstats:T', 'pvals:T', 'coefs:F' and marginal:T'.
See topic 'glm_keys' for details.  See 'options' for information on
changing the default values of 'fstats' and 'pvals'.

No design with MISSING values, weights or non-factor variables is ever
considered to be balanced.  This is true, even when all the weights are
1 and the non-MISSING values make up a balanced design.

Otherwise MacAnova recognizes balance in only two cases:
(1) The design is completely balanced, that is, all cells have the
same number of cases.
(2) The design is a balanced main effect design such as a Latin
square.

In these cases, computations are done by a fast method which uses
marginal totals, quite analogous to the usual hand computations for a
balanced analysis of variance.  Otherwise, the analysis is done by
explicitly constructing the design matrix and doing modified Gram-
Schmidt orthogonalization.

You can force an unbalanced computation for balanced data by
'unbalanced:T'.

For non-balanced designs or with 'unbalanced:T', unless 'marginal:T' is
an argument, sums of squares are computed sequentially and an advisory
message to that effect is printed.

This means that, in an unbalanced ANOVA, to get all the sums of squares
useful for testing hypotheses, you may need to run anova() several
times, with the terms in the model in different orders.  For example,
the A main effect sum of squares in a two way unbalanced ANOVA is the
sum of squares for 'a' from anova("y=b+a") and the B main effect sum of
squares is the sum of squares for 'b' from anova("y=a+b").

In many cases, use of 'marginal:T' can simplify things.  For example the
A and B sums of squares produced by anova("y=a+b",marginal:T) are the A
sums of squares from anova("y=b+a") and the B sums of squares from
anova("y=a+b").

When the previous GLM command was regress() the behavior of anova() with
Model missing is slightly modified -- it uses the results from the
previous computation instead of computing things afresh, even if the
variables in the previous model have been changed or deleted.
Specifically, any factors in the model are treated as variates (with 1
degree of freedom) and, if the previous GLM command was regress() with
weights specified by keyword 'weights' or 'wts', the entries in the
ANOVA table pertain to the weighted regression.

For example, even when a, b, and c are factors, the commands

Cmd> regress("y=a+b+c",weights:w); anova()

print a summary of the weighted multiple regression, followed by an
weighted regression ANOVA table with 1 degree of freedom for each of a,
b and c.  This is different from anova("y=a+b+c") which computes an
unweighted factorial ANOVA with no interactions.

See also coefs(), cellstats(), contrast(), factor(), fastanova(),
modelinfo(), predtable(), regress(), secoefs(), xvariables().
```

Gary Oehlert 2003-01-15