anova
statistics: anova
Object-oriented interface for analysis of variance.
The anova class provides a MATLAB-compatible object interface for
analysis of variance. It stores factors, response data, model
specification, and fitted results in one object. The class chooses the
narrowest compatible backend, delegates the numeric computation to the
existing ANOVA functions, and exposes common follow-up operations such as
stats, groupmeans, boxchart,
plotComparisons, varianceComponent, and
multcompare.
Models are fitted lazily. Methods that need fitted results call
fit internally when necessary, so users may construct an object and
immediately call inspection or post-hoc methods.
See also: anova1, anova2, anovan, multcompare, fitlm, LinearModel
Source Code: anova
The anova class contains the following properties:
Numeric response vector (or matrix, for the one-way column form) used to fit the ANOVA model. This property is read-only.
Table whose variables are the factors used to fit the ANOVA model, with
one column per factor named after FactorNames and one row per
observation. This property is read-only.
Character vector describing the fitted ANOVA model formula. (MATLAB returns a formula object; Octave returns the equivalent character vector.) This property is read-only.
Cell array of character vectors used as factor names in the fitted ANOVA table. This property is read-only.
Cell array of character vectors naming the model coefficients when the selected backend exposes them, otherwise an empty cell array. This property is read-only.
Character vector selecting 'one', 'two',
'three', or 'hierarchical' sums of squares. This
property is read-only.
Positive integer indices of random factors. This property is read-only.
Character vector 'all' or positive integer indices of factors
treated as categorical. This property is read-only.
Character vector used as the response name in formula display. This property is read-only.
Scalar number of response observations used by the model. This property is read-only.
Numeric coefficient table returned by the fitted anovan backend,
or derived from a LinearModel object. This property is read-only.
Table with variables Raw (observed minus fitted values) and
Pearson (raw residuals scaled by the root mean squared error)
when the selected backend exposes residuals, otherwise empty. This
property is read-only.
Table with variables MSE, RMSE, SSE, SSR,
SST, RSquared, and AdjustedRSquared summarising the
fitted model. This property is read-only.
The anova class offers the following public methods:
anova: obj = anova (Y)
anova: obj = anova (factors, Y)
anova: obj = anova (…, name, value)
anova: obj = anova (mdl)
Y is a non-empty numeric response vector or matrix.
factors contains grouping variables for vector responses and may
be a grouping vector, a matrix of grouping variables, or a cell array of
grouping vectors. If factors is omitted and Y is a matrix,
columns of Y are treated as groups following anova1 matrix
syntax.
Supported name-value arguments include 'ModelSpecification',
'SumOfSquaresType', 'FactorNames',
'CategoricalFactors', 'RandomFactors',
'ResponseName', 'Alpha', and 'Display'.
Passing 'Reps' selects the balanced two-way anova2
backend when Y is a non-vector matrix.
mdl may be a LinearModel object, in which case the ANOVA
object is populated from the fitted linear model’s public properties.
anova: disp (obj)
The display includes the selected backend, fit state, number of factors, sum-of-squares type, and significance level.
anova: s = stats (obj)
anova: s = stats (obj, type)
The model is fitted first if needed. The optional type argument
is accepted for MATLAB syntax compatibility; currently both
'component' and 'summary' return the backend ANOVA
table.
anova: means = groupmeans (obj)
anova: means = groupmeans (obj, factors)
The returned value is a table with one row per factor-level
combination and columns for the level, mean, standard error, and
confidence bounds.
anova: boxchart (obj)
anova: h = boxchart (obj, …)
This method uses boxplot as the graphics backend in Octave.
anova: plotComparisons (obj)
anova: h = plotComparisons (obj, …)
The method delegates interval computation to multcompare.
anova: v = varianceComponent (obj)
anova: v = varianceComponent (obj, …)
Random-factor variance component estimates are not yet implemented.
anova: C = multcompare (obj)
anova: [C, M, H, GNAMES] = multcompare (obj, …)
The method fits the object if needed and delegates to the package
function multcompare using the backend Stats structure.
Additional arguments are passed through unchanged.
y = [1; 2; 3; 4; 5; 6; 10; 11; 12]; g = [1; 1; 1; 2; 2; 2; 3; 3; 3]; a = anova (g, y, 'SumOfSquaresType', 'two'); summary (a);
ANOVA TABLE (Type II sums-of-squares, backend = anovan): Source Sum Sq. d.f. Mean Sq. Eta Sq. F Prob>F ------------------------------------------------------------------------------------ X1 126 2 63 0.95455 63 9.3914e-05 Error 6 6 1 Total 132 8 MSE: 1 DFE: 6 Alpha: 0.05
y = [1; 2; 3; 4; 5; 6; 10; 11; 12]; g = [1; 1; 1; 2; 2; 2; 3; 3; 3]; a = anova (g, y, 'SumOfSquaresType', 'two'); C = multcompare (a, 'display', 'off')
C = 1.0000e+00 2.0000e+00 -4.9979e+00 -3.0000e+00 -1.0021e+00 1.0402e-02 -3.6742e+00 6.0000e+00 1.0000e+00 3.0000e+00 -1.0998e+01 -9.0000e+00 -7.0021e+00 9.9474e-05 -1.1023e+01 6.0000e+00 2.0000e+00 3.0000e+00 -7.9979e+00 -6.0000e+00 -4.0021e+00 6.4995e-04 -7.3485e+00 6.0000e+00
y = [10; 12; 11; 14; 16; 15; 9; 8; 10]; g = [1; 1; 1; 2; 2; 2; 3; 3; 3]; a = anova (g, y, 'SumOfSquaresType', 'two'); plotDiagnostics (a);