# mauchly.test

##### Mauchly's Test of Sphericity

Tests whether a Wishart-distributed covariance matrix (or transformation thereof) is proportional to a given matrix.

- Keywords
- multivariate, models, htest

##### Usage

```
mauchly.test(object, ...)
# S3 method for mlm
mauchly.test(object, ...)
# S3 method for SSD
mauchly.test(object, Sigma = diag(nrow = p),
T = Thin.row(proj(M) - proj(X)), M = diag(nrow = p), X = ~0,
idata = data.frame(index = seq_len(p)), ...)
```

##### Arguments

- object
object of class

`SSD`

or`mlm`

.- Sigma
matrix to be proportional to.

- T
transformation matrix. By default computed from

`M`

and`X`

.- M
formula or matrix describing the outer projection (see below).

- X
formula or matrix describing the inner projection (see below).

- idata
data frame describing intra-block design.

- …
arguments to be passed to or from other methods.

##### Details

Mauchly's test test for whether a covariance matrix can be assumed to be proportional to a given matrix.

This is a generic function with methods for classes `"mlm"`

and
`"SSD"`

.

The basic method is for objects of
class `SSD`

the method for `mlm`

objects just extracts the
SSD matrix and invokes the corresponding method with the same options
and arguments.

The `T`

argument is used to transform the observations prior to
testing. This typically involves transformation to intra-block
differences, but more complicated within-block designs can be
encountered, making more elaborate transformations necessary. A
matrix `T`

can be given directly or specified as
the difference between two projections onto the spaces spanned by
`M`

and `X`

, which in turn can be given as matrices or as
model formulas with respect to `idata`

(the tests will be
invariant to parametrization of the quotient space `M/X`

).

The common use of this test is in repeated measurements designs, with
`X = ~1`

. This is almost, but not quite the same as testing for
compound symmetry in the untransformed covariance matrix.

Notice that the defaults involve `p`

, which is calculated
internally as the dimension of the SSD matrix, and a couple of hidden
functions in the stats namespace, namely `proj`

which
calculates projection matrices from design matrices or model formulas
and `Thin.row`

which removes linearly dependent rows from a
matrix until it has full row rank.

##### Value

An object of class `"htest"`

##### Note

The p-value differs slightly from that of SAS because a second order term is included in the asymptotic approximation in R.

##### References

T. W. Anderson (1958). *An Introduction to Multivariate
Statistical Analysis.* Wiley.

##### See Also

##### Examples

`library(stats)`

```
# NOT RUN {
utils::example(SSD) # Brings in the mlmfit and reacttime objects
### traditional test of intrasubj. contrasts
mauchly.test(mlmfit, X = ~1)
### tests using intra-subject 3x2 design
idata <- data.frame(deg = gl(3, 1, 6, labels = c(0,4,8)),
noise = gl(2, 3, 6, labels = c("A","P")))
mauchly.test(mlmfit, X = ~ deg + noise, idata = idata)
mauchly.test(mlmfit, M = ~ deg + noise, X = ~ noise, idata = idata)
# }
```

*Documentation reproduced from package stats, version 3.6.1, License: Part of R 3.6.1*