# coeftest

## Syntax

## Description

tests the null hypothesis that `tbl`

= coeftest(`maov`

,`A`

)`A`

*`B`

= 0, where `B`

is the matrix of coefficients in
`maov.Coefficients`

. `A`

is an
*a*-by-*p* transform matrix with rank *a* ≤ *p*, and *p* is the number of terms in the MANOVA model for
`maov`

. Use this syntax to test for statistically significant
differences in model coefficients between factor values.

## Examples

### Test Significance of MANOVA Model Coefficients

Load the `carsmall`

data set.

`load carsmall`

The variable `Model_Year`

contains data for the year a car was manufactured, and the variable `Cylinders`

contains data for the number of engine cylinders in the car. The `Acceleration`

and `Displacement`

variables contain data for car acceleration and displacement.

Use the `table`

function to create a table from the data in `Model_Year`

, `Cylinders`

, `Acceleration`

, and `Displacement`

.

data = table(Model_Year,Cylinders,Acceleration,Displacement, ... VariableNames=["Year" "Cylinders" "Acceleration" "Displacement"]);

Perform a two-way MANOVA, using `Model_Year`

and `Cylinders`

as factors, and `Acceleration`

and `Displacement`

as response variables. Display the test statistic used to perform the MANOVA.

maov = manova(data,["Acceleration" "Displacement"]); maov.TestStatistic

ans = "pillai"

The output shows that the function uses Pillai's to compute the MANOVA statistics for `maov`

.

Test the null hypothesis that the model coefficients for `maov`

are not statistically different from zero. By default, `coeftest`

uses the statistic in `maov.TestStatistic`

to perform the test.

tbl = coeftest(maov)

`tbl=`*1×6 table*
TestStatistic Value F DFNumerator DFDenominator pValue
_____________ ______ ______ ___________ _____________ ___________
"pillai" 1.8636 259.68 10 190 4.4695e-105

The *p*-value in the table output is very small, indicating that enough evidence exists to conclude that at least one of the model coefficients is statistically significant.

### Test Significance of MANOVA Model Term

Load the `carsmall`

data set.

`load carsmall`

The variable `Model_Year`

contains data for the year a car was manufactured, and the variable `Cylinders`

contains data for the number of engine cylinders in the car. The `Acceleration`

and `Displacement`

variables contain data for car acceleration and displacement.

Use the `table`

function to create a table from the data in `Model_Year`

, `Cylinders`

, `Acceleration`

, and `Displacement`

.

data = table(Model_Year,Cylinders,Acceleration,Displacement, ... VariableNames=["Year" "Cylinders" "Acceleration" "Displacement"]);

Perform a two-way MANOVA using `Model_Year`

and `Cylinders`

as factors, and `Acceleration`

and `Displacement`

as response variables.

maov = manova(data,["Acceleration" "Displacement"]);

`maov`

is a `manova`

object that contains the results of the two-way MANOVA.

Display the fitted MANOVA model coefficients for `maov`

.

coefs = maov.Coefficients

`coefs = `*5×2*
14.9360 228.5164
-0.8342 4.5054
0.6874 -10.0817
1.5827 -115.6528
1.3065 -7.8655

The first and second columns of the matrix `coefs`

correspond to the car acceleration and car displacement response variables, respectively. Each row corresponds to a term in the MANOVA model, with the first row containing intercept terms.

Display the names of the terms for the fitted coefficients.

maov.ExpandedFactorNames

`ans = `*1x5 string*
"(Intercept)" "Year_70" "Year_76" "Cylinders_4" "Cylinders_6"

The output shows that the last two rows of `coefs`

correspond to the terms for number of engine cylinders.

Test the null hypothesis that, for both response variables, the sum of the coefficients corresponding to the number of engine cylinders is zero.

A = [0 0 0 1 1]; tbl = coeftest(maov,A)

`tbl=`*1×6 table*
TestStatistic Value F DFNumerator DFDenominator pValue
_____________ _______ ______ ___________ _____________ __________
"pillai" 0.81715 210.04 2 94 2.0833e-35

The small *p*-value in the table output indicates that enough evidence exists to conclude that the sum of the engine cylinders coefficients is statistically different from zero.

### Test Significance of Coefficients for Each Response Variable

Load the `carsmall`

data set.

`load carsmall`

The variable `Model_Year`

contains data for the year a car was manufactured, and the variable `Cylinders`

contains data for the number of engine cylinders in the car. The `Acceleration`

and `Displacement`

variables contain data for car acceleration and displacement.

Use the `table`

function to create a table from the data in `Model_Year`

, `Cylinders`

, `Acceleration`

, and `Displacement`

.

data = table(Model_Year,Cylinders,Acceleration,Displacement, ... VariableNames=["Year" "Cylinders" "Acceleration" "Displacement"]);

Perform a two-way MANOVA using `Model_Year`

and `Cylinders`

as factors, and `Acceleration`

and `Displacement`

as response variables.

maov = manova(data,["Acceleration" "Displacement"]);

`maov`

is a `manova`

object that contains the results of the two-way MANOVA.

Display the fitted MANOVA model coefficients for `maov`

.

coefs = maov.Coefficients

`coefs = `*5×2*
14.9360 228.5164
-0.8342 4.5054
0.6874 -10.0817
1.5827 -115.6528
1.3065 -7.8655

The first and second columns of the matrix `coefs`

correspond to the car acceleration and car displacement response variables, respectively. Each row corresponds to a term in the MANOVA model, with the first row containing intercept terms.

Test the null hypothesis that the coefficients corresponding to the car acceleration sum to zero for each response variable.

A = [0 0 0 1 1]; C = [1;0]; tbl = coeftest(maov,A,C)

`tbl=`*1×6 table*
TestStatistic Value F DFNumerator DFDenominator pValue
_____________ _______ ______ ___________ _____________ __________
"pillai" 0.33182 47.176 1 95 6.6905e-10

The small *p*-value in the table output indicates that enough evidence exists to conclude that at least one of the sums is statistically different from zero.

## Input Arguments

`maov`

— MANOVA results

`manova`

object

MANOVA results, specified as a `manova`

object.
The properties of `maov`

contain the coefficient estimates and MANOVA
statistics used by `coeftest`

to perform the
*F*-test.

`A`

— Transform matrix

*p*-by-*p* identity matrix (default) | *a*-by-*p* numeric matrix

Transform matrix, specified as a *p*-by-*p*
identity matrix or an *a*-by-*p* numeric matrix, where
*p* is the number of terms in the MANOVA model for
`maov`

. `A`

has rank *a* ≤ *p*.

`coeftest`

uses `A`

to perform an
*F*-test with the null hypothesis `A`

*`B`

*`C`

=
`D`

. `B`

is the matrix of coefficients in
`maov.Coefficients`

, `C`

is a contrast matrix,
and `D`

is a matrix of hypothesized values. Specify
`A`

to test for statistically significant differences in model
coefficients between factor values. For more information, see Multivariate Analysis of Variance for Repeated Measures.

**Example: **`[1 1 3 0;0 0 2 1]`

**Data Types: **`single`

| `double`

`C`

— Contrast matrix

*r*-by-*r* identity matrix (default) | *r*-by-*c* numeric matrix

Contrast matrix, specified as an *r*-by-*r*
identity matrix or an *r*-by-*c* numeric matrix, where
*r* is the number of response variables in the MANOVA model for
`maov`

.

`coeftest`

uses `C`

to perform an
*F*-test with the null hypothesis `A`

*`B`

*`C`

=
`D`

. `B`

is the matrix of coefficients in
`maov.Coefficients`

, `A`

is a transform matrix,
and `D`

is a matrix of hypothesized values. Specify
`C`

to test for statistically significant differences in model
coefficients between response variables. For more information, see Multivariate Analysis of Variance for Repeated Measures.

**Example: **`[0.25 0.4]`

**Data Types: **`single`

| `double`

`D`

— Hypothesized values

`0`

(default) | numeric scalar | *a*-by-*c* numeric matrix

Hypothesized values, specified as `0`

, a numeric scalar, or an
*a*-by-*c* numeric matrix. *a* is
the number of rows in the transform matrix `A`

, and
*c* is the number of columns in the contrast matrix
`C`

. If `D`

is a scalar, the function expands it
to be an *a*-by-*c* matrix.

`coeftest`

uses `D`

to perform an
*F*-test with the null hypothesis `A`

*`B`

*`C`

=
`D`

. `B`

is the matrix of coefficients in
`maov.Coefficients`

, `A`

is a transform matrix,
and `C`

is a contrast matrix. Specify `D`

to
determine whether linear combinations of the coefficients estimated for
`maov`

are statistically equal to certain values. For more
information, see Multivariate Analysis of Variance for Repeated Measures.

**Example: **`[0 0 0 0;1 1 1 1;2 2 2 2]`

**Data Types: **`single`

| `double`

`testStat`

— MANOVA test statistics

`maov.TestStatistic`

(default) | `"all"`

| `"pillai"`

| `"hotelling"`

| `"wilks"`

| `"roy"`

MANOVA test statistics, specified as `maov.TestStatistic`

,
`"all"`

, or one or more of the following values.

Value | Test Name | Equation |
---|---|---|

`"pillai"` (default) | Pillai's trace | $$V=trace\left({Q}_{h}{\left({Q}_{h}+{Q}_{e}\right)}^{-1}\right)={\displaystyle \sum {\theta}_{i},}$$ where Q –
_{h}θ(Q +
_{h}Q) = 0.
_{e}Q and
_{h}Q are, respectively, the
hypotheses and the residual sum of squares product matrices. _{e} |

`"hotelling"` | Hotelling-Lawley trace | $$U=trace\left({Q}_{h}{Q}_{e}^{-1}\right)={\displaystyle \sum {\lambda}_{i}},$$ where Q –
_{h}λQ| = 0._{e} |

`"wilks"` | Wilk's lambda |
$$\Lambda =\frac{\left|{Q}_{e}\right|}{\left|{Q}_{h}+{Q}_{e}\right|}={\displaystyle \prod \frac{1}{1+{\lambda}_{i}}}.$$ |

`"roy"` | Roy's maximum root statistic |
$$\Theta =\mathrm{max}\left(eig\left({Q}_{h}{Q}_{e}^{-1}\right)\right).$$ |

If you specify `testStat`

as `"all"`

,
`coeftest`

calculates all the test statistics in the table
above.

**Example: **`TestStatistic`

="hotelling"

**Data Types: **`char`

| `string`

| `cell`

## Output Arguments

`tbl`

— Hypothesis test results

table

Hypothesis test results, returned as a table with the following variables:

`TestStatistic`

— Test statistic used by`coeftest`

to perform the*F*-test.`Value`

— Value of the test statistic.`F`

—*F*-statistic value. To calculate the*F*-statistic,`coeftest`

transforms`Value`

so that it follows an*F*-distribution under the null hypothesis.`DFNumerator`

— Degrees of freedom for the numerator of the*F*-statistic.`DFDenominator`

— Degrees of freedom for the denominator of the*F*-statistic.`pValue`

—*p*-value for the*F*-statistic.

`H`

— Hypothesis matrix

numeric matrix

Hypothesis matrix, returned as a numeric matrix. `coeftest`

uses `H`

to calculate the test statistic. For more information about
`H`

, see *Q _{h}* in Multivariate Analysis of Variance for Repeated Measures.

**Data Types: **`single`

| `double`

`E`

— Error matrix

numeric matrix

Error matrix, returned as a numeric matrix. `coeftest`

uses
`E`

to calculate the test statistic. For more information about
`E`

, see *Q _{e}* in Multivariate Analysis of Variance for Repeated Measures.

**Data Types: **`single`

| `double`

## Version History

**Introduced in R2023b**

## MATLAB-Befehl

Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:

Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.

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)