STAT3006: Tutorial 2
STAT3006: Tutorial 2
Tutorial 2
1. In introductory statistics courses, you would have come across rules to explain
what happens to the mean and variance under linear combinations of univariate
random variables.
You have likely seen the following.
Given random variables X1 and X2 and constants a and b, consider the linear
combination,
Y = aX1 + bX2 .
The mean of the linear combination is the linear combination of the means,
Derive corresponding expressions for the mean and variance of linear combina-
tions of arbitrary p-dimensional random variables (assume dependent): A X + B Y .
Hints: let Z = (X T Y T )T , consider a suitable matrix C and the properties of
C Z. Assume E(X) = µX , E(Y ) = µY , Cov(X, X) = ΣXX , Cov(Y, Y ) = ΣY Y ,
Cov(X, Y ) = ΣXY .
1
So that we don’t have to think about scaling of one variable relative to another,
it is often desirable to make the covariance matrix a correlation matrix. That is,
have all the variance terms equal to 1, or have all the diagonal entries equal to
1. Then we could fill in all the upper triangular terms with, for example, values
drawn from a standard normal distribution N(0, 1). We could reject any values
with magnitude above 1 since these cannot be part of a correlation matrix. We
could also draw from the continuous uniform distribution U[−1, 1]. Having then
copied these values to the lower triangle, we would have a symmetric matrix, but
one with a low chance of being a valid correlation or covariance matrix.
However, this can be corrected, albeit at the expense of not knowing the distri-
bution of the resulting matrices or their elements. Assume that the symmetric
matrix produced so far is B. This matrix will have eigenvalues and eigenvectors.
λ is an eigenvalue of B and v is an eigenvector of B if
Bv = λv
(B + aI)v = Bv + av = λv + av = (λ + a)v
(a) Randomly generate three valid 3×3 correlation matrices. These will be used
as the covariance matrices of three components in a mixture.
(b) Draw three random three-dimensional vectors where each element is drawn
from a standard normal distribution. These will be the means of the three
components.
2
(c) Draw one observation from a Dirichlet distribution to use as the mixture
proportions. The Dirichlet distribution is the multivariate analogue of the
beta distribution - it produces a set of values which sum to 1. The following
code should work.
install.packages("MCMCpack")
library(MCMCpack)
props = rdirichlet(1, c(1,1,1) )