# manova

**Class: **RepeatedMeasuresModel

Multivariate analysis of variance

## Description

also
returns manova results with additional options, specified by one or
more `manovatbl`

= manova(`rm`

,`Name,Value`

)`Name,Value`

pair arguments.

## Input Arguments

`rm`

— Repeated measures model

`RepeatedMeasuresModel`

object

Repeated measures model, returned as a `RepeatedMeasuresModel`

object.

For properties and methods of this object, see `RepeatedMeasuresModel`

.

### Name-Value Arguments

Specify optional pairs of arguments as
`Name1=Value1,...,NameN=ValueN`

, where `Name`

is
the argument name and `Value`

is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.

*
Before R2021a, use commas to separate each name and value, and enclose*
`Name`

*in quotes.*

`WithinModel`

— Model specifying within-subjects hypothesis test

`'separatemeans'`

(default) | model specification using formula | *r*-by-*nc* matrix

Model specifying the within-subjects hypothesis test, specified as one of the following:

`'separatemeans'`

— Compute a separate mean for each group, and test for equality among the means.Model specification — This is a model specification in the within-subject factors. Test each term in the model. In this case,

`tbl`

contains a separate manova for each term in the formula, with the multivariate response equal to the vector of coefficients of that term.An

*r*-by-*nc*matrix,*C*, specifying*nc*contrasts among the*r*repeated measures. If*Y*represents the matrix of repeated measures you use in the repeated measures model`rm`

, then the output`tbl`

contains a separate manova for each column of*Y***C*.

**Example: **`'WithinModel','separatemeans'`

**Data Types: **`single`

| `double`

| `char`

| `string`

`By`

— Single between-subjects factor

character vector | string scalar

Single between-subjects factor, specified as the comma-separated pair consisting of
`'By'`

and a character vector or string scalar.
`manova`

performs a separate test of the
within-subjects model for each value of this factor.

For example, if you have a between-subjects factor, Drug, then you can specify that factor to perform manova as follows.

**Example: **`'By','Drug'`

**Data Types: **`char`

| `string`

## Output Arguments

`manovatbl`

— Results of multivariate analysis of variance

table

Results of multivariate analysis of variance for the repeated
measures model `rm`

, returned as a `table`

.

`manova`

uses these methods to measure the
contributions of the model terms to the overall covariance:

Wilks’ Lambda

Pillai’s trace

Hotelling-Lawley trace

Roy’s maximum root statistic

For details, see Multivariate Analysis of Variance for Repeated Measures.

`manova`

returns the results for these tests
for each group. `manovatbl`

contains the following
columns.

Column Name | Definition |
---|---|

`Within` | Within-subject terms |

`Between` | Between-subject terms |

`Statistic` | Name of the statistic computed |

`Value` | Value of the corresponding statistic |

`F` | F-statistic value |

`RSquare` | Measure for variance explained |

`df1` | Numerator degrees of freedom |

`df2` | Denominator degrees of freedom |

`pValue` | p-value for the corresponding F-statistic
value |

**Data Types: **`table`

`A`

— Specification based on between-subjects model

matrix | cell array

Specification based on the between-subjects model, returned
as a matrix or a cell array. It permits the hypothesis on the elements
within given columns of `B`

(within time hypothesis).
If `manovatbl`

contains multiple hypothesis tests, `A`

might
be a cell array.

**Data Types: **`single`

| `double`

| `cell`

`C`

— Specification based on within-subjects model

matrix | cell array

Specification based on the within-subjects model, returned as
a matrix or a cell array. It permits the hypotheses on the elements
within given rows of `B`

(between time hypotheses).
If `manovatbl`

contains multiple hypothesis tests, `C`

might
be a cell array.

**Data Types: **`single`

| `double`

| `cell`

`D`

— Hypothesis value

0

Hypothesis value, returned as 0.

## Examples

### Perform Multivariate Analysis of Variance

Load the sample data.

`load fisheriris`

The column vector `species`

consists of iris flowers of three different species: setosa, versicolor, virginica. The double matrix `meas`

consists of four types of measurements on the flowers: the length and width of sepals and petals in centimeters, respectively.

Store the data in a table array.

t = table(species,meas(:,1),meas(:,2),meas(:,3),meas(:,4),... 'VariableNames',{'species','meas1','meas2','meas3','meas4'}); Meas = table([1 2 3 4]','VariableNames',{'Measurements'});

Fit a repeated measures model where the measurements are the responses and the species is the predictor variable.

rm = fitrm(t,'meas1-meas4~species','WithinDesign',Meas);

Perform multivariate analysis of variance.

manova(rm)

`ans=`*8×9 table*
Within Between Statistic Value F RSquare df1 df2 pValue
________ ___________ _________ _________ ______ _______ ___ ___ ___________
Constant (Intercept) Pillai 0.99013 4847.5 0.99013 3 145 3.7881e-145
Constant (Intercept) Wilks 0.0098724 4847.5 0.99013 3 145 3.7881e-145
Constant (Intercept) Hotelling 100.29 4847.5 0.99013 3 145 3.7881e-145
Constant (Intercept) Roy 100.29 4847.5 0.99013 3 145 3.7881e-145
Constant species Pillai 0.96909 45.749 0.48455 6 292 2.4729e-39
Constant species Wilks 0.041153 189.92 0.79714 6 290 2.3958e-97
Constant species Hotelling 23.051 555.17 0.92016 6 288 4.6662e-155
Constant species Roy 23.04 1121.3 0.9584 3 146 1.4771e-100

Perform multivariate anova separately for each species.

manova(rm,'By','species')

`ans=`*12×9 table*
Within Between Statistic Value F RSquare df1 df2 pValue
________ __________________ _________ ________ ______ _______ ___ ___ ___________
Constant species=setosa Pillai 0.9823 2682.7 0.9823 3 145 9.0223e-127
Constant species=setosa Wilks 0.017698 2682.7 0.9823 3 145 9.0223e-127
Constant species=setosa Hotelling 55.504 2682.7 0.9823 3 145 9.0223e-127
Constant species=setosa Roy 55.504 2682.7 0.9823 3 145 9.0223e-127
Constant species=versicolor Pillai 0.97 1562.8 0.97 3 145 3.7058e-110
Constant species=versicolor Wilks 0.029999 1562.8 0.97 3 145 3.7058e-110
Constant species=versicolor Hotelling 32.334 1562.8 0.97 3 145 3.7058e-110
Constant species=versicolor Roy 32.334 1562.8 0.97 3 145 3.7058e-110
Constant species=virginica Pillai 0.97261 1716.1 0.97261 3 145 5.1113e-113
Constant species=virginica Wilks 0.027394 1716.1 0.97261 3 145 5.1113e-113
Constant species=virginica Hotelling 35.505 1716.1 0.97261 3 145 5.1113e-113
Constant species=virginica Roy 35.505 1716.1 0.97261 3 145 5.1113e-113

### Return Arrays of the Hypothesis Test

Load the sample data.

`load fisheriris`

The column vector `species`

consists of iris flowers of three different species: setosa, versicolor, virginica. The double matrix `meas`

consists of four types of measurements on the flowers: the length and width of sepals and petals in centimeters, respectively.

Store the data in a table array.

t = table(species,meas(:,1),meas(:,2),meas(:,3),meas(:,4),... 'VariableNames',{'species','meas1','meas2','meas3','meas4'}); Meas = dataset([1 2 3 4]','VarNames',{'Measurements'});

Fit a repeated measures model where the measurements are the responses and the species is the predictor variable.

rm = fitrm(t,'meas1-meas4~species','WithinDesign',Meas);

Perform multivariate analysis of variance. Also return the arrays for constructing the hypothesis test.

[manovatbl,A,C,D] = manova(rm)

`manovatbl=`*8×9 table*
Within Between Statistic Value F RSquare df1 df2 pValue
________ ___________ _________ _________ ______ _______ ___ ___ ___________
Constant (Intercept) Pillai 0.99013 4847.5 0.99013 3 145 3.7881e-145
Constant (Intercept) Wilks 0.0098724 4847.5 0.99013 3 145 3.7881e-145
Constant (Intercept) Hotelling 100.29 4847.5 0.99013 3 145 3.7881e-145
Constant (Intercept) Roy 100.29 4847.5 0.99013 3 145 3.7881e-145
Constant species Pillai 0.96909 45.749 0.48455 6 292 2.4729e-39
Constant species Wilks 0.041153 189.92 0.79714 6 290 2.3958e-97
Constant species Hotelling 23.051 555.17 0.92016 6 288 4.6662e-155
Constant species Roy 23.04 1121.3 0.9584 3 146 1.4771e-100

`A=`*2×1 cell array*
{[ 1 0 0]}
{2x3 double}

`C = `*4×3*
1 0 0
-1 1 0
0 -1 1
0 0 -1

D = 0

Index into matrix A.

A{1}

`ans = `*1×3*
1 0 0

A{2}

`ans = `*2×3*
0 1 0
0 0 1

## Tips

The multivariate response for each observation (subject) is the vector of repeated measures.

To test a more general hypothesis

`A*B*C = D`

, use`coeftest`

.

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

# Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)