# User:Timothee Flutre/Notebook/Postdoc/2012/01/02

Project name Main project page
Previous entry      Next entry

## Learn about the multivariate Normal and matrix calculus

(Caution, this is my own quick-and-dirty tutorial, see the references at the end for presentations by professional statisticians.)

• Motivation: when we measure items, we often have to measure several properties for each item. For instance, we extract cells from each individual in our study, and we measure the expression level of all genes. We hence have, for each individual, a vector of measurements (one per gene), which leads us to the world of multivariate statistics.
• Data: we have N observations, noted , each being of dimension . This means that each is a vector belonging to . Traditionally, we record all the data into an matrix named , with samples (observations) in rows and variables (dimensions) in columns. Also, it is usual to assume vectors are in column by default. Therefore, we can write .
• Descriptive statistics: the sample mean is the P-dimensional vector with . The sample covariance is the matrix noted with .
• Model: we suppose that the are independent and identically distributed according to a multivariate Normal distribution . is the P-dimensional mean vector, and the covariance matrix. If is positive definite (which we will assume), the density function for a given observation is: , with denoting the determinant of a matrix M and its transpose.
• Likelihood: as usual, we will start by writing down the likelihood of the data, the parameters being :

As the observations are independent:

It is easier to work with the log-likelihood:

• ML estimation: as usual, to find the maximum-likelihood estimates of the parameters, we need to derive the log-likelihood with respect to each parameter, and then take the values of the parameters at which the log-likelihood is zero. However, in the case of multivariate distributions, this requires knowing a bit of matrix calculus, which is not always straightforward...
• Matrix calculus: some useful formulas

, eg. useful here:

• Technical details: from Magnus and Neudecker (third edition, Part Six, Chapter 15, Section 3, p.353). First, they re-write the log-likelihood, noting that is a scalar, ie. a 1x1 matrix, and is therefore equal to its trace:

As the trace is invariant under cyclic permutations ():

The trace is also a linear map ():

And finally:

As a result:

with

We can now write the first differential of the log-likelihood:

The first-order conditions (ie. when ) are:

and

From which follow:

and:

Note that is a biased estimate of . It is usually better to use the unbiased estimate .

• Sufficient statistics:

From defined above and defined similarly as but with in the denominator, we can write the following:

Thus, by employing the same trick with the trace as above, we now have:

The likelihood depends on the samples only through the pair . Thanks to the Factorization theorem, we can say that this pair of values is a sufficient statistic for .

We can also transform a bit more the formula of the likelihood in order to find the distribution of this sufficient statistic:

The likelihood is only proportional because the first constant is not used in any of the two distributions and a few constants are missing (eg. the Gamma function appearing in the density of the Wishart distribution). This doesn't matter as we usually want to maximize the likelihood or compute a likelihood ratio.

• References:
• Magnus and Neudecker, Matrix differential calculus with applications in statistics and econometrics (2007)
• Wand, Vector differential calculus in statistics (The American Statistician, 2002)